// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rdi, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1030
testl %eax, %eax
js 0x1347
movq %rbx, -0x48(%rbp)
movslq %eax, %r12
movq $-0x3f, %r14
leaq -0x26f8(%rbp), %rbx
movabsq $0x300080200, %r15      # imm = 0x300080200
leaq 0x40(%r14), %rdi
cmpl $0x21, %edi
ja 0x1339
movl %edi, %eax
btq %rax, %r15
jae 0x1339
addq $0x98, %rbx
incq %r14
jne 0x131a
jmp 0x1352
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1050
testl %eax, %eax
jns 0x132b
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x1c5b
leaq -0x188(%rbp), %rsi
xorl %edi, %edi
callq 0x1170
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x1c5b
movq %r13, -0x88(%rbp)
leaq 0x1ceb(%rip), %rdi      # 0x3067
xorl %r13d, %r13d
xorl %esi, %esi
xorl %eax, %eax
callq 0x1150
testl %eax, %eax
js 0x1c53
movl %eax, %ebx
movq %r12, -0xd8(%rbp)
movl $0x3ff2, %edi           # imm = 0x3FF2
callq 0x2452
movq %rax, %r13
movl $0x3ff2, %edx           # imm = 0x3FF2
movl %ebx, %edi
movq %rax, %rsi
callq 0x10d0
movq %rax, %r15
cmpq $0x3ff2, %rax           # imm = 0x3FF2
jge 0x13c5
movq %r15, %r12
jmp 0x13fe
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
addq %r15, %r15
movq %r13, %rdi
callq 0x126e
movq %r15, %rdi
callq 0x2452
movq %rax, %r13
movl %ebx, %edi
movq %rax, %rsi
movq %r15, %rdx
callq 0x10d0
movq %rax, %r12
cmpq %r15, %rax
movq %rax, %r15
jge 0x13c5
movl %ebx, %edi
callq 0x10b0
testq %r12, %r12
js 0x1c48
movb $0x0, (%r13,%r12)
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 0x1c53
movq %rax, %r12
leaq 0x1(%r13), %rax
movq %rax, -0x80(%rbp)
movb $0x1, %r14b
leaq 0x154(%rip), %rax       # 0x15a9
leaq 0x35d(%rip), %rcx       # 0x17b9
subq %rax, %rcx
movq %rcx, -0x90(%rbp)
leaq 0x143(%rip), %rcx       # 0x15b0
subq %rax, %rcx
movq %rcx, -0xd0(%rbp)
leaq 0x15a(%rip), %rcx       # 0x15d8
subq %rax, %rcx
movq %rcx, -0xc8(%rbp)
leaq 0x1a7(%rip), %rcx       # 0x1636
subq %rax, %rcx
movq %rcx, -0xc0(%rbp)
leaq 0x1ec(%rip), %rcx       # 0x168c
subq %rax, %rcx
movq %rcx, -0xb8(%rbp)
leaq 0x1fa(%rip), %rcx       # 0x16ab
subq %rax, %rcx
movq %rcx, -0xb0(%rbp)
leaq 0x2e2(%rip), %rcx       # 0x17a4
subq %rax, %rcx
movq %rcx, -0xa8(%rbp)
movl $0x1000, %ebx           # imm = 0x1000
movq %rbx, -0x98(%rbp)
leal -0x80(%rbx), %eax
testb $0x1, %r14b
movl $0x0, %ebx
cmovnel %ebx, %eax
movl %eax, (%r12)
movl $0xc, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x10f0
movq %rax, 0x8(%r12)
movl %ebx, 0x4(%r12)
movl %ebx, 0x20(%r12)
movb (%r13), %dl
testb %dl, %dl
je 0x153b
xorl %eax, %eax
movq -0x80(%rbp), %rcx
xorl %esi, %esi
cmpb $0xa, %dl
sete %sil
addl %esi, %eax
movl %eax, 0x20(%r12)
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x1516
movl %eax, %eax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
jmp 0x153d
xorl %edi, %edi
movq %r12, %rsi
callq 0x24b9
movq %rax, 0x18(%r12)
movl 0x4(%r12), %eax
addl $0xf, %eax
movl %eax, 0x4(%r12)
cmpl (%r12), %eax
leaq 0x71(%r12,%rax), %rax
leaq 0x3b79(%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(%r12)
movl $0x1003, %edi           # imm = 0x1003
leaq -0x170(%rbp), %rsi
callq 0x10c0
testl %eax, %eax
js 0x185d
jmp 0x17b9