// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
cmpb $0x0, 0x6b22(%rip)      # 0xa110
je 0x3899
leaq 0x4(%rsp), %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x3180
movl %eax, %ebp
testl %eax, %eax
jle 0x3826
leaq 0x29eb(%rip), %r14      # 0x6004
leaq 0x2a00(%rip), %r15      # 0x6020
leaq 0x4(%rsp), %rbx
movl %ebp, 0x6bc9(%rip)      # 0xa1f4
movl 0x4(%rsp), %eax
movl %eax, %ecx
cmpb $0x7f, %al
jne 0x367f
shrl $0x8, %ecx
movzbl %cl, %ecx
movl %ecx, 0x6bb7(%rip)      # 0xa1f8
movl 0x6ba9(%rip), %edx      # 0xa1f0
movl %edx, 0x6baf(%rip)      # 0xa1fc
cmpb $0x5, %cl
je 0x3722
cmpl $0x13, %ecx
je 0x36f1
cmpl $0x85, %ecx
jne 0x3703
movl $0x0, 0x6b8b(%rip)      # 0xa200
callq 0x398c
jmp 0x37a3
andl $0x7f, %ecx
je 0x36b2
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
cmpl $0x2000000, %ecx        # imm = 0x2000000
jl 0x36cd
movl %ebp, %edi
callq 0x3947
movl 0x4(%rsp), %eax
andl $0x7f, %eax
movl %eax, 0x6b5f(%rip)      # 0xa208
movq 0x6af8(%rip), %rcx      # 0xa1a8
jmp 0x36df
movl %ebp, %edi
callq 0x3947
movzbl 0x5(%rsp), %eax
movl %eax, 0x6b40(%rip)      # 0xa204
movq 0x6ad5(%rip), %rcx      # 0xa1a0
jmp 0x36df
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x387a
movq 0x6ad1(%rip), %rcx      # 0xa1b0
testq %rcx, %rcx
je 0x37fc
xorl %eax, %eax
callq *%rcx
jmp 0x37fc
movl %ebp, %edi
callq 0x38f6
movl 0x6afa(%rip), %ecx      # 0xa1f8
testq %rax, %rax
je 0x3757
movl %ecx, 0x6af7(%rip)      # 0xa200
movq 0x6aa8(%rip), %rcx      # 0xa1b8
testq %rcx, %rcx
je 0x37a3
xorl %eax, %eax
callq *%rcx
jmp 0x37a3
movl $0x5, 0x6ad4(%rip)      # 0xa200
sarl $0x8, %eax
addl $0xfffffefb, %eax       # imm = 0xFFFFFEFB
roll $0x18, %eax
cmpl $0x6, %eax
ja 0x381a
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
callq 0x3c36
movq 0x6a7b(%rip), %rcx      # 0xa1d0
jmp 0x3795
movl %ecx, 0x6aa3(%rip)      # 0xa200
movl %ebp, %edi
callq 0x3583
movq 0x6a55(%rip), %rcx      # 0xa1c0
jmp 0x3710
callq 0x3c36
movq 0x6a4f(%rip), %rcx      # 0xa1c8
jmp 0x3795
callq 0x3c36
movq 0x6a51(%rip), %rcx      # 0xa1d8
jmp 0x3795
callq 0x3c36
movq 0x6a4b(%rip), %rcx      # 0xa1e0
testq %rcx, %rcx
je 0x379e
xorl %eax, %eax
callq *%rcx
callq 0x3c79
movl 0x6a53(%rip), %eax      # 0xa1fc
movl $0x4207, %edi           # imm = 0x4207
cmpq $0x5, %rax
ja 0x37e5
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl %ebp, %edi
movl $0x9, %esi
callq 0x3150
jmp 0x37fc
movl $0x7, %edi
jmp 0x37e5
movl $0x11, %edi
jmp 0x37e5
movl $0x18, %edi
jmp 0x37e5
movl $0x9, %edi
movl 0x6a15(%rip), %ecx      # 0xa200
movl %ebp, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3170
cmpq $-0x1, %rax
je 0x385b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x3180
movl %eax, %ebp
testl %eax, %eax
jg 0x3625
jmp 0x3826
movq 0x69c7(%rip), %rcx      # 0xa1e8
jmp 0x3710
cmpl $-0x1, %ebp
jne 0x3839
callq 0x3040
cmpl $0xa, (%rax)
jne 0x38d7
movb $0x0, 0x68d0(%rip)      # 0xa110
leaq 0x68d1(%rip), %rdi      # 0xa118
callq 0x466d
testl %eax, %eax
jne 0x38b8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27d6(%rip), %rdi      # 0x6038
leaq 0x27d1(%rip), %rsi      # 0x603a
leaq 0x284e(%rip), %rcx      # 0x60be
movl $0xb6, %edx
callq 0x30c0
leaq 0x27b7(%rip), %rdi      # 0x6038
leaq 0x27b2(%rip), %rsi      # 0x603a
leaq 0x282f(%rip), %rcx      # 0x60be
movl $0xca, %edx
callq 0x30c0
leaq 0x2798(%rip), %rdi      # 0x6038
leaq 0x2793(%rip), %rsi      # 0x603a
leaq 0x2810(%rip), %rcx      # 0x60be
movl $0x75, %edx
callq 0x30c0
leaq 0x2779(%rip), %rdi      # 0x6038
leaq 0x2774(%rip), %rsi      # 0x603a
leaq 0x27f1(%rip), %rcx      # 0x60be
movl $0xd2, %edx
callq 0x30c0
leaq 0x275a(%rip), %rdi      # 0x6038
leaq 0x2755(%rip), %rsi      # 0x603a
leaq 0x27d2(%rip), %rcx      # 0x60be
movl $0xce, %edx
callq 0x30c0