// File: /workspace/github_c_makefile_star2_O1/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 0x389f
leaq 0x4(%rsp), %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x3180
movl %eax, %ebp
testl %eax, %eax
jle 0x382c
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 0x36fd
movl $0x0, 0x6b8b(%rip)      # 0xa200
callq 0x3992
jmp 0x37a9
andl $0x7f, %ecx
je 0x36b2
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
cmpl $0x2000000, %ecx        # imm = 0x2000000
jl 0x36cd
movl %ebp, %edi
callq 0x394d
movl 0x4(%rsp), %eax
andl $0x7f, %eax
movl %eax, 0x6b5f(%rip)      # 0xa208
movq 0x6af8(%rip), %rcx      # 0xa1a8
jmp 0x36df
movl %ebp, %edi
callq 0x394d
movzbl 0x5(%rsp), %eax
movl %eax, 0x6b40(%rip)      # 0xa204
movq 0x6ad5(%rip), %rcx      # 0xa1a0
jmp 0x36df
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x3880
movq 0x6ad1(%rip), %rcx      # 0xa1b0
testq %rcx, %rcx
je 0x3802
xorl %eax, %eax
callq *%rcx
jmp 0x3802
movl %ebp, %edi
callq 0x38fc
testq %rax, %rax
je 0x3757
movl 0x6af5(%rip), %eax      # 0xa1f8
movl %eax, 0x6af7(%rip)      # 0xa200
movq 0x6aa8(%rip), %rcx      # 0xa1b8
testq %rcx, %rcx
je 0x37a9
xorl %eax, %eax
callq *%rcx
jmp 0x37a9
movl $0x5, 0x6ad4(%rip)      # 0xa200
sarl $0x8, %eax
addl $0xfffffefb, %eax       # imm = 0xFFFFFEFB
roll $0x18, %eax
cmpl $0x6, %eax
ja 0x3820
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
callq 0x3c3c
movq 0x6a7b(%rip), %rcx      # 0xa1d0
jmp 0x379b
movl 0x6a9b(%rip), %eax      # 0xa1f8
movl %eax, 0x6a9d(%rip)      # 0xa200
movl %ebp, %edi
callq 0x3583
movq 0x6a4f(%rip), %rcx      # 0xa1c0
jmp 0x3710
callq 0x3c3c
movq 0x6a49(%rip), %rcx      # 0xa1c8
jmp 0x379b
callq 0x3c3c
movq 0x6a4b(%rip), %rcx      # 0xa1d8
jmp 0x379b
callq 0x3c3c
movq 0x6a45(%rip), %rcx      # 0xa1e0
testq %rcx, %rcx
je 0x37a4
xorl %eax, %eax
callq *%rcx
callq 0x3c7f
movl 0x6a4d(%rip), %eax      # 0xa1fc
movl $0x4207, %edi           # imm = 0x4207
cmpq $0x5, %rax
ja 0x37eb
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl %ebp, %edi
movl $0x9, %esi
callq 0x3150
jmp 0x3802
movl $0x7, %edi
jmp 0x37eb
movl $0x11, %edi
jmp 0x37eb
movl $0x18, %edi
jmp 0x37eb
movl $0x9, %edi
movl 0x6a0f(%rip), %ecx      # 0xa200
movl %ebp, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3170
cmpq $-0x1, %rax
je 0x3861
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x3180
movl %eax, %ebp
testl %eax, %eax
jg 0x3625
jmp 0x382c
movq 0x69c1(%rip), %rcx      # 0xa1e8
jmp 0x3710
cmpl $-0x1, %ebp
jne 0x383f
callq 0x3040
cmpl $0xa, (%rax)
jne 0x38dd
movb $0x0, 0x68ca(%rip)      # 0xa110
leaq 0x68cb(%rip), %rdi      # 0xa118
callq 0x46ba
testl %eax, %eax
jne 0x38be
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27d0(%rip), %rdi      # 0x6038
leaq 0x27cb(%rip), %rsi      # 0x603a
leaq 0x2848(%rip), %rcx      # 0x60be
movl $0xb6, %edx
callq 0x30c0
leaq 0x27b1(%rip), %rdi      # 0x6038
leaq 0x27ac(%rip), %rsi      # 0x603a
leaq 0x2829(%rip), %rcx      # 0x60be
movl $0xca, %edx
callq 0x30c0
leaq 0x2792(%rip), %rdi      # 0x6038
leaq 0x278d(%rip), %rsi      # 0x603a
leaq 0x280a(%rip), %rcx      # 0x60be
movl $0x75, %edx
callq 0x30c0
leaq 0x2773(%rip), %rdi      # 0x6038
leaq 0x276e(%rip), %rsi      # 0x603a
leaq 0x27eb(%rip), %rcx      # 0x60be
movl $0xd2, %edx
callq 0x30c0
leaq 0x2754(%rip), %rdi      # 0x6038
leaq 0x274f(%rip), %rsi      # 0x603a
leaq 0x27cc(%rip), %rcx      # 0x60be
movl $0xce, %edx
callq 0x30c0