// File: /workspace/github_c_makefile_star2_O1/sos22[P]unexec/unexec.c
// Function: unexec
int unexec(const char * path, struct new_environment * env) {
    long persona;
    persona = personality(0xffffffff);
    if (persona < 0) return -1;
#define NR_SIGS 64
    struct sigaction sigs[64];
    stack_t stack;
    for (int i = 1; i < NR_SIGS; i++) {
        if (validsignr(i) && sigaction(i, NULL, &sigs[i]) < 0) {
            return -1; } }
    if (sigaltstack(NULL, &stack) < 0) return -1;
    int r = unexec_core(path, env);
    if (r == 0) {
        /* XXX not clear if returning an error, with the process
         * half-restored, is the right answer here. Might be cleaner
         * to just abort(). */
        if (personality(persona) < 0) return -1;
        for (int i = 1; i < NR_SIGS; i++) {
            if (validsignr(i) && sigaction(i, &sigs[i], NULL) < 0) {
                return -1; } }
        if (sigaltstack(&stack, NULL) < 0) return -1; }
    return r; }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2778, %rsp           # imm = 0x2778
movq %rsi, %r12
movq %rdi, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1030
testl %eax, %eax
js 0x1415
movq %rbx, -0xe0(%rbp)
cltq
movq %rax, -0xe8(%rbp)
movq $-0x3f, %r14
leaq -0x2708(%rbp), %rbx
movabsq $0x300080200, %r15      # imm = 0x300080200
leaq 0x40(%r14), %rax
cmpl $0x21, %eax
ja 0x1346
movl %eax, %eax
btq %rax, %r15
jae 0x1346
addq $0x98, %rbx
incq %r14
jne 0x1327
jmp 0x135d
leal 0x40(%r14), %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1050
testl %eax, %eax
jns 0x1338
jmp 0x1415
leaq -0x198(%rbp), %rsi
xorl %edi, %edi
callq 0x1170
testl %eax, %eax
js 0x1415
movq %r12, -0xa0(%rbp)
leaq 0x1ce6(%rip), %rdi      # 0x3067
xorl %esi, %esi
xorl %eax, %eax
callq 0x1150
testl %eax, %eax
js 0x141f
movl %eax, %ebx
movl $0x3ff2, %r14d          # imm = 0x3FF2
movl $0x3ff2, %edi           # imm = 0x3FF2
callq 0x25ba
movq %rax, %r15
movl %ebx, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x10d0
movq %rax, %r12
movl %ebx, %edi
cmpq %r14, %rax
jge 0x13d6
callq 0x10b0
testq %r12, %r12
js 0x13f8
movb $0x0, (%r15,%r12)
movq %r14, %r13
movq %r15, -0x58(%rbp)
jmp 0x140b
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
leaq (%r12,%r12), %r13
movq %r15, %rdi
callq 0x126e
movq %r13, %rdi
callq 0x25ba
movq %rax, %r15
jmp 0x140b
movq %r15, %rdi
callq 0x126e
movq %r14, %r13
movq $0x0, -0x58(%rbp)
cmpq %r14, %r12
movq %r13, %r14
jge 0x13a7
jmp 0x1427
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x1d47
movq $0x0, -0x58(%rbp)
movq $-0x1, %r14
movq -0x58(%rbp), %r15
testq %r15, %r15
je 0x1d18
movl $0x1000, %r13d          # imm = 0x1000
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movl $0x10000, %edi          # imm = 0x10000
movl $0x1000, %esi           # imm = 0x1000
movl $0x3, %edx
movl $0x32, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
callq 0x1080
cmpq $-0x1, %rax
je 0x1d22
movq %rax, %rbx
leaq 0x1(%r15), %rax
movq %rax, -0xc0(%rbp)
movb $0x1, %r14b
leaq 0x132(%rip), %rax       # 0x15be
leaq 0x33b(%rip), %rcx       # 0x17ce
subq %rax, %rcx
movq %rcx, -0xb8(%rbp)
leaq 0x121(%rip), %rcx       # 0x15c5
subq %rax, %rcx
movq %rcx, -0xa8(%rbp)
leaq 0x138(%rip), %rcx       # 0x15ed
subq %rax, %rcx
movq %rcx, -0x88(%rbp)
leaq 0x185(%rip), %rcx       # 0x164b
subq %rax, %rcx
movq %rcx, -0x98(%rbp)
leaq 0x1ca(%rip), %rcx       # 0x16a1
subq %rax, %rcx
movq %rcx, -0x80(%rbp)
leaq 0x1db(%rip), %rcx       # 0x16c0
subq %rax, %rcx
movq %rcx, -0x78(%rbp)
leaq 0x2c6(%rip), %rcx       # 0x17b9
subq %rax, %rcx
movq %rcx, -0x70(%rbp)
leal -0x80(%r13), %eax
testb $0x1, %r14b
movl $0x0, %r14d
cmovnel %r14d, %eax
movl %eax, (%rbx)
movl $0xc, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x10f0
movq %rax, 0x8(%rbx)
movl %r14d, 0x4(%rbx)
movl %r14d, 0x20(%rbx)
movb (%r15), %dl
testb %dl, %dl
je 0x154f
xorl %eax, %eax
movq -0xc0(%rbp), %rcx
xorl %esi, %esi
cmpb $0xa, %dl
sete %sil
addl %esi, %eax
movl %eax, 0x20(%rbx)
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x1538
movl 0x20(%rbx), %eax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
movq %rbx, %rsi
callq 0x2621
movq %rax, 0x18(%rbx)
movl 0x4(%rbx), %eax
addl $0xf, %eax
movl %eax, 0x4(%rbx)
cmpl (%rbx), %eax
leaq 0x71(%rbx,%rax), %rax
leaq 0x3b63(%rip), %rcx      # 0x50e0
cmovaq %rcx, %rax
movabsq $0x65732f636f72702f, %rcx # imm = 0x65732F636F72702F
movq %rcx, (%rax)
movabsq $0x6578652f666c65, %rcx # imm = 0x6578652F666C65
movq %rcx, 0x7(%rax)
movq %rax, 0x28(%rbx)
movl $0x1003, %edi           # imm = 0x1003
leaq -0x180(%rbp), %rsi
callq 0x10c0
testl %eax, %eax
js 0x1866
jmp 0x17ce