// File: /workspace/github_c_makefile_star2_O2/sos22[P]unexec/tests/environ.c
// Function: main
int main(int argc, char **argv) {
    char buf[] = "environXXXXXX";
    close(mkstemp(buf));
    struct new_environment env;
    int r = unexec(buf, &env);
    if (r < 0) err(1, "unexec");
    if (r == 1) {
        execl(buf, buf, "hello", NULL);
        err(1, "execl %s", buf); }
    assert(env.argc == 2);
    assert(!strcmp(env.argv[0], buf));
    assert(!strcmp(env.argv[1], "hello"));
    assert(argc == 1);
    assert(argv[1] == NULL);
    release_new_environment(&env);
    setenv("foobly", "moo", 1);
    setenv("wibble", "woo", 1);
    if (unlink(buf) < 0) err(1, "unlink");
    r = unexec(buf, &env);
    if (r < 0) err(1, "unexec");
    if (r == 1) {
        char * args[] = {"buf", NULL};
        char * environ[] = {"foobly=baroom", NULL};
        execve(buf, args, environ);
        err(1, "execve %s", buf); }
    assert(!strcmp(getenv("foobly"), "moo"));
    assert(!strcmp(getenv("wibble"), "woo"));
    assert(!strcmp(env.environ[0], "foobly=baroom"));
    assert(env.environ[1] == NULL);
    release_new_environment(&env);
    if (unlink(buf) < 0) err(1, "unlink");
    return 0; }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movl %edi, %r14d
movabsq $0x5858585858586e, %rax # imm = 0x5858585858586E
leaq -0x28(%rbp), %r15
movq %rax, 0x6(%r15)
movabsq $0x586e6f7269766e65, %rax # imm = 0x586E6F7269766E65
movq %rax, (%r15)
movq %r15, %rdi
callq 0x10b0
movl %eax, %edi
callq 0x1070
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
callq 0x10d0
testl %eax, %eax
js 0x138d
cmpl $0x1, %eax
je 0x13a7
cmpl $0x2, -0x40(%rbp)
jne 0x13cd
movq -0x38(%rbp), %r15
movq (%r15), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1090
testl %eax, %eax
jne 0x13e9
movq 0x8(%r15), %rdi
leaq 0xda2(%rip), %rsi       # 0x2019
callq 0x1090
testl %eax, %eax
jne 0x1405
cmpl $0x1, %r14d
jne 0x1421
cmpq $0x0, 0x8(%rbx)
jne 0x143d
leaq -0x40(%rbp), %rdi
callq 0x10c0
leaq 0xe06(%rip), %rdi       # 0x20af
leaq 0xe06(%rip), %rsi       # 0x20b6
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x1050
leaq 0xdf9(%rip), %rdi       # 0x20ba
leaq 0xdf9(%rip), %rsi       # 0x20c1
movl %ebx, %edx
callq 0x1050
leaq -0x28(%rbp), %rdi
callq 0x1040
testl %eax, %eax
js 0x1396
leaq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x10d0
testl %eax, %eax
js 0x138d
cmpl $0x1, %eax
je 0x1459
leaq 0xdaa(%rip), %rdi       # 0x20af
callq 0x1030
leaq 0xda5(%rip), %rsi       # 0x20b6
movq %rax, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1495
leaq 0xd92(%rip), %rdi       # 0x20ba
callq 0x1030
leaq 0xd8d(%rip), %rsi       # 0x20c1
movq %rax, %rdi
callq 0x1090
testl %eax, %eax
jne 0x14ae
movq -0x30(%rbp), %rbx
movq (%rbx), %rdi
leaq 0xd7e(%rip), %rsi       # 0x20d0
callq 0x1090
testl %eax, %eax
jne 0x14c7
cmpq $0x0, 0x8(%rbx)
jne 0x14e0
leaq -0x40(%rbp), %rdi
callq 0x10c0
leaq -0x28(%rbp), %rdi
callq 0x1040
testl %eax, %eax
js 0x1396
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc7e(%rip), %rsi       # 0x2012
jmp 0x139d
leaq 0xd28(%rip), %rsi       # 0x20c5
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x10a0
leaq 0xc6b(%rip), %rdx       # 0x2019
leaq -0x28(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x10e0
leaq 0xc57(%rip), %rsi       # 0x201f
jmp 0x1488
leaq 0xc54(%rip), %rdi       # 0x2028
leaq 0xc5b(%rip), %rsi       # 0x2036
leaq 0xc64(%rip), %rcx       # 0x2046
pushq $0x13
jmp 0x14f7
leaq 0xc6d(%rip), %rdi       # 0x205d
leaq 0xc3f(%rip), %rsi       # 0x2036
leaq 0xc48(%rip), %rcx       # 0x2046
pushq $0x14
jmp 0x14f7
leaq 0xc6b(%rip), %rdi       # 0x2077
leaq 0xc23(%rip), %rsi       # 0x2036
leaq 0xc2c(%rip), %rcx       # 0x2046
pushq $0x15
jmp 0x14f7
leaq 0xc6d(%rip), %rdi       # 0x2095
leaq 0xc07(%rip), %rsi       # 0x2036
leaq 0xc10(%rip), %rcx       # 0x2046
pushq $0x16
jmp 0x14f7
leaq 0xc5b(%rip), %rdi       # 0x209f
leaq 0xbeb(%rip), %rsi       # 0x2036
leaq 0xbf4(%rip), %rcx       # 0x2046
pushq $0x17
jmp 0x14f7
movaps 0x2950(%rip), %xmm0     # 0x3db0
leaq -0x60(%rbp), %rsi
movaps %xmm0, (%rsi)
movaps 0x2952(%rip), %xmm0     # 0x3dc0
leaq -0x50(%rbp), %rdx
movaps %xmm0, (%rdx)
leaq -0x28(%rbp), %rbx
movq %rbx, %rdi
callq 0x1080
leaq 0xc56(%rip), %rsi       # 0x20de
pushq $0x1
popq %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10a0
leaq 0xc4c(%rip), %rdi       # 0x20e8
leaq 0xb93(%rip), %rsi       # 0x2036
leaq 0xb9c(%rip), %rcx       # 0x2046
pushq $0x23
jmp 0x14f7
leaq 0xc54(%rip), %rdi       # 0x2109
leaq 0xb7a(%rip), %rsi       # 0x2036
leaq 0xb83(%rip), %rcx       # 0x2046
pushq $0x24
jmp 0x14f7
leaq 0xc5c(%rip), %rdi       # 0x212a
leaq 0xb61(%rip), %rsi       # 0x2036
leaq 0xb6a(%rip), %rcx       # 0x2046
pushq $0x25
jmp 0x14f7
leaq 0xc6c(%rip), %rdi       # 0x2153
leaq 0xb48(%rip), %rsi       # 0x2036
leaq 0xb51(%rip), %rcx       # 0x2046
pushq $0x26
popq %rdx
callq 0x1060