// File: /workspace/github_c_makefile_star2_O2/seojangho[P]clee/clee.c
// Function: clee_main
void clee_main() {
    if (!tracing) {
        CLEE_ERROR;
    }
    pid_t pid;
    int status;
    while ((pid = waitpid(-1, &status, __WALL)) > 0) {
        event_pid = pid;
        if (WIFSTOPPED(status)) {
            enum __ptrace_request request;
            stopped_cause = WSTOPSIG(status);
            stopped_behavior = default_behavior;
            if (stopped_cause == (SIGTRAP|0x80)) {
                stopped_signal = 0;
                clee_syscall(pid);
            } else if (stopped_cause == SIGTRAP) {
                stopped_signal = stopped_cause;
                const int st = status >> 8;
                if (st == (SIGTRAP | (PTRACE_EVENT_CLONE << 8))) {
                    clee_syscall_regs_get();
                    if (event_handlers.syscall_clone != NULL) {
                        (event_handlers.syscall_clone)();
                    }
                    clee_syscall_regs_set();
                } else if (st == (SIGTRAP | (PTRACE_EVENT_FORK << 8))) {
                    clee_syscall_regs_get();
                    if (event_handlers.syscall_fork != NULL) {
                        (event_handlers.syscall_fork)();
                    }
                    clee_syscall_regs_set();
                } else if (st == (SIGTRAP | (PTRACE_EVENT_VFORK << 8))) {
                    clee_syscall_regs_get();
                    if (event_handlers.syscall_vfork != NULL) {
                        (event_handlers.syscall_vfork)();
                    }
                    clee_syscall_regs_set();
                } else if (st == (SIGTRAP | (PTRACE_EVENT_SECCOMP << 8))) {
                    clee_syscall_regs_get();
                    if (event_handlers.syscall_seccomp != NULL) {
                        (event_handlers.syscall_seccomp)();
                    }
                    clee_syscall_regs_set();
                } else {
                    /* successful exec */
                    if (event_handlers.successful_exec != NULL) {
                        (event_handlers.successful_exec)();
                    }
                }
            } else if (stopped_cause == SIGSTOP && clee_children_lookup(pid) == NULL) {
                stopped_signal = stopped_cause;
                clee_children_add(pid);
                if (event_handlers.new_process != NULL) {
                    (event_handlers.new_process)();
                }
            } else {
                stopped_signal = stopped_cause;
                if (event_handlers.stopped != NULL) {
                    (event_handlers.stopped)();
                }
            }

            if (stopped_behavior == terminate) {
                kill(pid, SIGKILL);
            } else {
                request = clee_behavior2request(stopped_behavior);

                if (ptrace(request, pid, NULL, stopped_signal) == -1) {
                    CLEE_ERROR;
                }
            }
        } else if (WIFEXITED(status)) {
            clee_children_delete(pid);
            exit_code = WEXITSTATUS(status);
            if (event_handlers.exited != NULL) {
                (event_handlers.exited)();
            }
        } else if (WIFSIGNALED(status)) {
            clee_children_delete(pid);
            terminate_cause = WTERMSIG(status);
            if (event_handlers.terminated != NULL) {
                (event_handlers.terminated)();
            }
        } else if (WIFCONTINUED(status)) {
            if (event_handlers.continued != NULL) {
                (event_handlers.continued)();
            }
        } else {
            CLEE_ERROR;
        }
    }
    if (pid == -1 && errno != ECHILD) {
        CLEE_ERROR;
    }
    tracing = false;
    if (list_size(&children) != 0) {
        CLEE_ERROR;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
cmpb $0x0, 0x7b48(%rip)      # 0xb110
je 0x383a
pushq $-0x1
popq %rbx
leaq 0xc(%rsp), %r14
leaq 0x2a27(%rip), %r12      # 0x6004
pushq $0x9
popq %rbp
movl %ebx, %edi
movq %r14, %rsi
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x3180
movl %eax, %r15d
testl %eax, %eax
jle 0x37c4
movl %r15d, 0x7bf3(%rip)     # 0xb1f4
movl 0xc(%rsp), %eax
movl %eax, %ecx
cmpb $0x7f, %al
jne 0x3652
shrl $0x8, %ecx
movzbl %cl, %ecx
movl %ecx, 0x7be1(%rip)      # 0xb1f8
movl 0x7bd3(%rip), %edx      # 0xb1f0
movl %edx, 0x7bd9(%rip)      # 0xb1fc
cmpb $0x5, %cl
je 0x36f8
cmpl $0x13, %ecx
je 0x36c6
cmpl $0x85, %ecx
jne 0x36d9
andl $0x0, 0x7bb8(%rip)      # 0xb200
callq 0x3927
jmp 0x377a
andl $0x7f, %ecx
je 0x3686
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
cmpl $0x2000000, %ecx        # imm = 0x2000000
jl 0x36a2
movl %r15d, %edi
callq 0x38e2
movl 0xc(%rsp), %eax
andl $0x7f, %eax
movl %eax, 0x7b8b(%rip)      # 0xb208
movq 0x7b24(%rip), %rcx      # 0xb1a8
jmp 0x36b4
movl %r15d, %edi
callq 0x38e2
movzbl 0xd(%rsp), %eax
movl %eax, 0x7b6b(%rip)      # 0xb204
movq 0x7b00(%rip), %rcx      # 0xb1a0
jmp 0x36b4
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x381b
movq 0x7afc(%rip), %rcx      # 0xb1b0
testq %rcx, %rcx
je 0x35e0
xorl %eax, %eax
callq *%rcx
jmp 0x35e0
movl %r15d, %edi
callq 0x3895
movl 0x7b24(%rip), %ecx      # 0xb1f8
testq %rax, %rax
je 0x372d
movl %ecx, 0x7b21(%rip)      # 0xb200
movq 0x7ad2(%rip), %rcx      # 0xb1b8
testq %rcx, %rcx
je 0x377a
xorl %eax, %eax
callq *%rcx
jmp 0x377a
movl $0x5, 0x7afe(%rip)      # 0xb200
sarl $0x8, %eax
addl $0xfffffefb, %eax       # imm = 0xFFFFFEFB
roll $0x18, %eax
cmpl $0x6, %eax
ja 0x37b8
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
callq 0x3bc0
movq 0x7aa5(%rip), %rcx      # 0xb1d0
jmp 0x376c
movl %ecx, 0x7acd(%rip)      # 0xb200
movl %r15d, %edi
callq 0x355a
movq 0x7a7e(%rip), %rcx      # 0xb1c0
jmp 0x36e6
callq 0x3bc0
movq 0x7a78(%rip), %rcx      # 0xb1c8
jmp 0x376c
callq 0x3bc0
movq 0x7a7a(%rip), %rcx      # 0xb1d8
jmp 0x376c
callq 0x3bc0
movq 0x7a74(%rip), %rcx      # 0xb1e0
testq %rcx, %rcx
je 0x3775
xorl %eax, %eax
callq *%rcx
callq 0x3c01
movl 0x7a7c(%rip), %edi      # 0xb1fc
testl %edi, %edi
je 0x37a9
callq 0x359b
movl 0x7a71(%rip), %ecx      # 0xb200
movl %eax, %edi
movl %r15d, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3170
cmpq $-0x1, %rax
jne 0x35e0
jmp 0x37fc
movl %r15d, %edi
movl %ebp, %esi
callq 0x3150
jmp 0x35e0
movq 0x7a29(%rip), %rcx      # 0xb1e8
jmp 0x36e6
cmpl $-0x1, %r15d
jne 0x37d8
callq 0x3040
cmpl $0xa, (%rax)
jne 0x3876
movb $0x0, 0x7931(%rip)      # 0xb110
leaq 0x7932(%rip), %rdi      # 0xb118
callq 0x434e
testl %eax, %eax
jne 0x3857
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x281d(%rip), %rdi      # 0x6020
leaq 0x2818(%rip), %rsi      # 0x6022
leaq 0x2895(%rip), %rcx      # 0x60a6
movl $0xb6, %edx
callq 0x30c0
leaq 0x27fe(%rip), %rdi      # 0x6020
leaq 0x27f9(%rip), %rsi      # 0x6022
leaq 0x2876(%rip), %rcx      # 0x60a6
movl $0xca, %edx
callq 0x30c0
leaq 0x27df(%rip), %rdi      # 0x6020
leaq 0x27da(%rip), %rsi      # 0x6022
leaq 0x2857(%rip), %rcx      # 0x60a6
pushq $0x75
popq %rdx
callq 0x30c0
leaq 0x27c2(%rip), %rdi      # 0x6020
leaq 0x27bd(%rip), %rsi      # 0x6022
leaq 0x283a(%rip), %rcx      # 0x60a6
movl $0xd2, %edx
callq 0x30c0
leaq 0x27a3(%rip), %rdi      # 0x6020
leaq 0x279e(%rip), %rsi      # 0x6022
leaq 0x281b(%rip), %rcx      # 0x60a6
movl $0xce, %edx
callq 0x30c0