// File: /workspace/github_c_makefile_star2_O2/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 $0x2768, %rsp           # imm = 0x2768
movq %rsi, %r12
movq %rdi, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1030
testl %eax, %eax
js 0x13d2
movq %rbx, -0x80(%rbp)
cltq
movq %rax, -0xe0(%rbp)
pushq $-0x3f
popq %r15
leaq -0x26f8(%rbp), %r14
pushq $-0x1
popq %rbx
movabsq $0x300080200, %r13      # imm = 0x300080200
testq %r15, %r15
je 0x1351
leaq 0x40(%r15), %rdi
cmpl $0x21, %edi
ja 0x133e
movl %edi, %eax
btq %rax, %r13
jae 0x133e
incq %r15
addq $0x98, %r14
jmp 0x131c
xorl %esi, %esi
movq %r14, %rdx
callq 0x1050
testl %eax, %eax
jns 0x1332
jmp 0x1c3b
leaq -0x188(%rbp), %rsi
xorl %edi, %edi
callq 0x1170
testl %eax, %eax
js 0x1c3b
leaq 0x1cf9(%rip), %rdi      # 0x3067
xorl %r15d, %r15d
xorl %esi, %esi
xorl %eax, %eax
callq 0x1150
movl %eax, %ebx
pushq $-0x1
popq %rax
movl %eax, -0x60(%rbp)
pushq $-0x1
popq %rax
testl %ebx, %ebx
js 0x1b86
movq %r12, -0x70(%rbp)
movl $0x3ff2, %r12d          # imm = 0x3FF2
movq %r12, %rdi
callq 0x22c1
movq %rax, %r14
movl %ebx, %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x10d0
movq %rax, %r15
cmpq %r12, %rax
jl 0x13da
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
addq %r15, %r15
movq %r14, %rdi
callq 0x126e
movq %r15, %r12
jmp 0x1397
pushq $-0x1
popq %rbx
jmp 0x1c3b
movl %ebx, %edi
callq 0x10b0
testq %r15, %r15
js 0x1ba4
movb $0x0, (%r14,%r15)
movabsq $0x1fffff000, %rax      # imm = 0x1FFFFF000
pushq $0x3
popq %rdx
pushq $0x32
popq %rcx
pushq $-0x1
popq %r8
leaq 0x12a(%rip), %rsi       # 0x1534
leaq 0x333(%rip), %rdi       # 0x1744
subq %rsi, %rdi
movq %rdi, -0xa0(%rbp)
leaq 0x119(%rip), %rdi       # 0x153b
subq %rsi, %rdi
movq %rdi, -0xd8(%rbp)
leaq 0x130(%rip), %rdi       # 0x1563
subq %rsi, %rdi
movq %rdi, -0xd0(%rbp)
leaq 0x17d(%rip), %rdi       # 0x15c1
subq %rsi, %rdi
movq %rdi, -0xc8(%rbp)
leaq 0x1c2(%rip), %rdi       # 0x1617
subq %rsi, %rdi
movq %rdi, -0xc0(%rbp)
leaq 0x1d0(%rip), %rdi       # 0x1636
subq %rsi, %rdi
movq %rdi, -0xb8(%rbp)
leaq 0x2b8(%rip), %rdi       # 0x172f
subq %rsi, %rdi
movq %rdi, -0xb0(%rbp)
xorl %ebx, %ebx
movl %r8d, -0x60(%rbp)
leaq 0x107f(%rbx), %r12
andq %rax, %r12
xorl %r15d, %r15d
movl $0x10000, %edi          # imm = 0x10000
movq %r12, %rsi
xorl %r9d, %r9d
callq 0x1080
cmpq $-0x1, %rax
je 0x1c4f
movq %rbx, %rcx
movq %rax, %rbx
leal -0x80(%r12), %eax
testq %rcx, %rcx
cmovel %r15d, %eax
movl %eax, (%rbx)
callq 0x22b0
movq %rax, 0x8(%rbx)
andl $0x0, 0x4(%rbx)
andl $0x0, 0x20(%rbx)
movq %r14, %rax
movb (%rax), %cl
testb %cl, %cl
je 0x14f0
xorl %edx, %edx
cmpb $0xa, %cl
sete %dl
addl %edx, %r15d
movl %r15d, 0x20(%rbx)
incq %rax
jmp 0x14d6
movl %r15d, %eax
imulq $0x28, %rax, %rdi
movq %rbx, %rsi
callq 0x2320
movq %rax, 0x18(%rbx)
leaq 0x1be3(%rip), %rdi      # 0x30ed
movq %rbx, %rsi
callq 0x236d
movq %rax, 0x28(%rbx)
movl $0x1003, %edi           # imm = 0x1003
leaq -0x170(%rbp), %rsi
callq 0x10c0
testl %eax, %eax
js 0x17ea
jmp 0x1744