clarify the purpose of this project
[nyanglibc.git] / stdlib / getsubopt.s
blob06b57d40f5e3b0c5a7148310a8a3ed0eec9199a7
1 .text
2 .p2align 4,,15
3 .globl getsubopt
4 .type getsubopt, @function
5 getsubopt:
6 pushq %r15
7 pushq %r14
8 pushq %r13
9 pushq %r12
10 pushq %rbp
11 pushq %rbx
12 subq $40, %rsp
13 movq (%rdi), %rbx
14 cmpb $0, (%rbx)
15 je .L10
16 movq %rsi, %r12
17 movq %rdi, 8(%rsp)
18 movl $44, %esi
19 movq %rbx, %rdi
20 movq %rdx, 16(%rsp)
21 call __strchrnul@PLT
22 movq %rax, %rdx
23 movl $61, %esi
24 movq %rbx, %rdi
25 subq %rbx, %rdx
26 movq %rax, %r15
27 movq %rax, (%rsp)
28 call memchr
29 movq (%r12), %r14
30 testq %rax, %rax
31 cmove %r15, %rax
32 movq %rax, 24(%rsp)
33 testq %r14, %r14
34 je .L4
35 movq %rax, %rbp
36 xorl %r15d, %r15d
37 subq %rbx, %rbp
38 .p2align 4,,10
39 .p2align 3
40 .L8:
41 movq %rbp, %rdx
42 movq %r14, %rsi
43 movq %rbx, %rdi
44 call strncmp
45 testl %eax, %eax
46 movl %r15d, %r13d
47 jne .L5
48 cmpb $0, (%r14,%rbp)
49 je .L19
50 .L5:
51 addq $1, %r15
52 movq (%r12,%r15,8), %r14
53 testq %r14, %r14
54 jne .L8
55 .L4:
56 movq 16(%rsp), %rax
57 movq %rbx, (%rax)
58 movq (%rsp), %rax
59 cmpb $0, (%rax)
60 jne .L20
61 .L9:
62 movq 8(%rsp), %rax
63 movq (%rsp), %rcx
64 movl $-1, %r13d
65 movq %rcx, (%rax)
66 .L1:
67 addq $40, %rsp
68 movl %r13d, %eax
69 popq %rbx
70 popq %rbp
71 popq %r12
72 popq %r13
73 popq %r14
74 popq %r15
75 ret
76 .p2align 4,,10
77 .p2align 3
78 .L20:
79 movb $0, (%rax)
80 addq $1, %rax
81 movq %rax, (%rsp)
82 jmp .L9
83 .p2align 4,,10
84 .p2align 3
85 .L19:
86 movq 24(%rsp), %rcx
87 movl $0, %edx
88 movq %rcx, %rsi
89 leaq 1(%rcx), %rax
90 movq (%rsp), %rcx
91 cmpq %rcx, %rsi
92 movq 16(%rsp), %rsi
93 cmove %rdx, %rax
94 movq %rax, (%rsi)
95 cmpb $0, (%rcx)
96 je .L7
97 leaq 1(%rcx), %rax
98 movb $0, (%rcx)
99 movq %rax, (%rsp)
100 .L7:
101 movq 8(%rsp), %rax
102 movq (%rsp), %rcx
103 movq %rcx, (%rax)
104 jmp .L1
105 .L10:
106 movl $-1, %r13d
107 jmp .L1
108 .size getsubopt, .-getsubopt
109 .hidden strncmp
110 .hidden memchr