// File: /workspace/github_c_makefile_star2_O1/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 $0xb8, %rsp
leaq -0xd8(%rbp), %r12
leaq -0x38(%rbp), %r13
leaq 0xe6e(%rip), %r14       # 0x20a0
xorl %ebx, %ebx
leaq 0xe53(%rip), %rdi       # 0x208e
leaq 0xe5c(%rip), %rsi       # 0x209e
callq 0x10d0
movq %rax, %r15
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x126c
movq -0xd8(%rbp), %rdx
movq %r14, %rdi
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x10e0
testq %rax, %rax
jns 0x1259
movq -0xd8(%rbp), %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 0xd59(%rip), %rdi       # 0x201e
movl %ebx, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1060
movq %r12, %rdi
xorl %esi, %esi
callq 0x1070
xorps %xmm0, %xmm0
cvtsi2sdq -0xd8(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
cvtsi2sdq -0xd0(%rbp), %xmm0
mulsd 0xd08(%rip), %xmm0      # 0x2008
movsd %xmm0, -0x40(%rbp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x10f0
testl %eax, %eax
js 0x139a
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jne 0x13ba
movq %r12, %rdi
xorl %esi, %esi
callq 0x1070
cvtsi2sdq -0xd8(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sdq -0xd0(%rbp), %xmm0
mulsd 0xcb5(%rip), %xmm0      # 0x2008
addsd %xmm1, %xmm0
subsd -0x40(%rbp), %xmm0
leaq 0xccd(%rip), %rdi       # 0x2030
movl %ebx, %esi
movb $0x1, %al
callq 0x1060
movq %r13, %rdi
callq 0x1040
testl %eax, %eax
js 0x13a3
incl %ebx
cmpl $0x3e8, %ebx            # imm = 0x3E8
jne 0x1234
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc88(%rip), %rsi       # 0x2029
jmp 0x1413
leaq 0xca1(%rip), %rsi       # 0x204b
leaq -0x38(%rbp), %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x10a0
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x1070
cvtsi2sdq (%r14), %xmm1
xorps %xmm0, %xmm0
cvtsi2sdq 0x8(%r14), %xmm0
mulsd 0xc27(%rip), %xmm0      # 0x2008
addsd %xmm1, %xmm0
subsd -0x40(%rbp), %xmm0
leaq 0xc64(%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 0x141f
leaq 0xc56(%rip), %rsi       # 0x2069
movl $0x1, %edi
xorl %eax, %eax
callq 0x10a0
leaq -0x38(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1090
testl %eax, %eax
jns 0x143f
leaq 0xc35(%rip), %rsi       # 0x206f
jmp 0x13aa
movq -0xa8(%rbp), %rdx
leaq 0xc2a(%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 0xc15(%rip), %rsi       # 0x2085
movl $0x1, %edi
movq %rbx, %rdx
jmp 0x13b3