clarify the purpose of this project
[nyanglibc.git] / stdlib / getenv.s
blob2be584bbb9832c0b1039623fb3a926752a1919a4
1 .text
2 .p2align 4,,15
3 .globl getenv
4 .hidden getenv
5 .type getenv, @function
6 getenv:
7 pushq %r15
8 pushq %r14
9 pushq %r13
10 pushq %r12
11 pushq %rbp
12 pushq %rbx
13 subq $8, %rsp
14 movq __environ(%rip), %rbp
15 testq %rbp, %rbp
16 je .L10
17 movzbl (%rdi), %eax
18 testb %al, %al
19 je .L10
20 cmpb $0, 1(%rdi)
21 movq 0(%rbp), %rbx
22 jne .L3
23 orb $61, %ah
24 testq %rbx, %rbx
25 jne .L6
26 jmp .L1
27 .p2align 4,,10
28 .p2align 3
29 .L5:
30 addq $8, %rbp
31 movq 0(%rbp), %rbx
32 testq %rbx, %rbx
33 je .L1
34 .L6:
35 cmpw (%rbx), %ax
36 jne .L5
37 addq $2, %rbx
38 .L1:
39 addq $8, %rsp
40 movq %rbx, %rax
41 popq %rbx
42 popq %rbp
43 popq %r12
44 popq %r13
45 popq %r14
46 popq %r15
47 ret
48 .p2align 4,,10
49 .p2align 3
50 .L3:
51 movq %rdi, %r13
52 addq $2, %r13
53 call strlen
54 movzwl -2(%r13), %r12d
55 testq %rbx, %rbx
56 movq %rax, %r15
57 leaq -2(%rax), %r14
58 jne .L8
59 jmp .L1
60 .p2align 4,,10
61 .p2align 3
62 .L7:
63 addq $8, %rbp
64 movq 0(%rbp), %rbx
65 testq %rbx, %rbx
66 je .L1
67 .L8:
68 cmpw (%rbx), %r12w
69 jne .L7
70 leaq 2(%rbx), %rdi
71 movq %r14, %rdx
72 movq %r13, %rsi
73 call strncmp
74 testl %eax, %eax
75 jne .L7
76 cmpb $61, (%rbx,%r15)
77 jne .L7
78 leaq 1(%rbx,%r15), %rbx
79 jmp .L1
80 .p2align 4,,10
81 .p2align 3
82 .L10:
83 xorl %ebx, %ebx
84 jmp .L1
85 .size getenv, .-getenv
86 .hidden strncmp
87 .hidden strlen