// File: /workspace/github_c_makefile_star2_O2/sos22[P]unexec/tests/iterate.c
// Function: main
int main() {
    for (unsigned x = 0; x < NR_ITERATIONS; x++) {
        dump_maps(x);
        char template[] = "iterateXXXXXX";
        close(mkstemp(template));
        printf("%d: in %s\n", x, template);
        double start  = now();
        int r = unexec(template, NULL);
        if (r < 0) err(1, "unexec");
        if (r == 0) {
            printf("%d: got restored after %f\n", x, now() - start);
            if (unlink(template) < 0) err(1, "unlink %s", template);
            continue; }
        printf("%d: unexec took %f\n", x, now() - start);
        if (chmod(template, 0700) < 0) err(1, "chmod");
        struct stat st;
        if (stat(template, &st) < 0) err(1, "stat %s", template);
        printf("%d: size %zx\n", x, st.st_size);
        execl(template, template, NULL);
        err(1, "execl %s", template); }
    return 0; }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
leaq -0xd0(%rbp), %r12
leaq -0x38(%rbp), %r13
leaq 0xe6e(%rip), %r14       # 0x20a0
xorl %ebx, %ebx
cmpl $0x3e8, %ebx            # imm = 0x3E8
je 0x1326
leaq 0xe47(%rip), %rdi       # 0x208e
leaq 0xe50(%rip), %rsi       # 0x209e
callq 0x10d0
andq $0x0, -0xd0(%rbp)
movq %rax, %r15
andq $0x0, -0x38(%rbp)
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x10e0
movq -0xd0(%rbp), %rdx
testq %rax, %rax
js 0x128b
movq %r14, %rdi
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
jmp 0x1263
movq %rdx, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1050
movabsq $0x58585858585865, %rax # imm = 0x58585858585865
movq %rax, -0x32(%rbp)
movabsq $0x5865746172657469, %rax # imm = 0x5865746172657469
movq %rax, -0x38(%rbp)
movq %r13, %rdi
callq 0x10b0
movl %eax, %edi
callq 0x1080
leaq 0xd51(%rip), %rdi       # 0x201e
movl %ebx, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1060
callq 0x13e4
movsd %xmm0, -0x40(%rbp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x10f0
testl %eax, %eax
js 0x133a
movl %eax, %r15d
callq 0x13e4
subsd -0x40(%rbp), %xmm0
testl %r15d, %r15d
jne 0x1358
leaq 0xd26(%rip), %rdi       # 0x2030
movl %ebx, %esi
movb $0x1, %al
callq 0x1060
movq %r13, %rdi
callq 0x1040
testl %eax, %eax
js 0x1343
incl %ebx
jmp 0x1234
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xce8(%rip), %rsi       # 0x2029
jmp 0x1381
leaq 0xd01(%rip), %rsi       # 0x204b
pushq $0x1
popq %rdi
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x10a0
leaq 0xcf6(%rip), %rdi       # 0x2055
movl %ebx, %esi
movb $0x1, %al
callq 0x1060
leaq -0x38(%rbp), %rdi
movl $0x1c0, %esi            # imm = 0x1C0
callq 0x10c0
testl %eax, %eax
jns 0x138b
leaq 0xce8(%rip), %rsi       # 0x2069
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x10a0
leaq -0x38(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1090
testl %eax, %eax
jns 0x13a8
leaq 0xcc9(%rip), %rsi       # 0x206f
jmp 0x134a
movq -0xa0(%rbp), %rdx
leaq 0xcc1(%rip), %rdi       # 0x2077
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1100
leaq 0xcac(%rip), %rsi       # 0x2085
pushq $0x1
popq %rdi
movq %rbx, %rdx
jmp 0x1351