// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
testb $0x1, 0x8a49(%rip)      # 0xc138
jne 0x3710
leaq 0x49b0(%rip), %rdi      # 0x80a8
leaq 0x49ab(%rip), %rsi      # 0x80aa
movl $0x75, %edx
leaq 0x4a23(%rip), %rcx      # 0x812e
callq 0x30c0
jmp 0x3712
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq -0x8(%rbp), %rsi
movl $0x40000000, %edx       # imm = 0x40000000
callq 0x31b0
movl %eax, -0x4(%rbp)
cmpl $0x0, %eax
jle 0x39eb
movl -0x4(%rbp), %eax
movl %eax, 0x8ae2(%rip)      # 0xc21c
movl -0x8(%rbp), %eax
andl $0xff, %eax
cmpl $0x7f, %eax
jne 0x3931
movl -0x8(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movl %eax, 0x8ac4(%rip)      # 0xc220
movl 0x8ab6(%rip), %eax      # 0xc218
movl %eax, 0x8abc(%rip)      # 0xc224
cmpl $0x85, 0x8aae(%rip)     # 0xc220
jne 0x3788
movl $0x0, 0x8aaa(%rip)      # 0xc228
callq 0x3b40
jmp 0x38c8
cmpl $0x5, 0x8a91(%rip)      # 0xc220
jne 0x3865
movl 0x8a85(%rip), %eax      # 0xc220
movl %eax, 0x8a87(%rip)      # 0xc228
movl -0x8(%rbp), %eax
sarl $0x8, %eax
movl %eax, -0x10(%rbp)
cmpl $0x305, -0x10(%rbp)     # imm = 0x305
jne 0x37d4
callq 0x42c0
cmpq $0x0, 0x8a30(%rip)      # 0xc1f0
je 0x37ca
movb $0x0, %al
callq *0x8a26(%rip)           # 0xc1f0
callq 0x4310
jmp 0x3863
cmpl $0x105, -0x10(%rbp)     # imm = 0x105
jne 0x37fb
callq 0x42c0
cmpq $0x0, 0x8a0e(%rip)      # 0xc1f8
je 0x37f4
movb $0x0, %al
callq *0x8a04(%rip)           # 0xc1f8
callq 0x4310
jmp 0x3861
cmpl $0x205, -0x10(%rbp)     # imm = 0x205
jne 0x3822
callq 0x42c0
cmpq $0x0, 0x89ef(%rip)      # 0xc200
je 0x381b
movb $0x0, %al
callq *0x89e5(%rip)           # 0xc200
callq 0x4310
jmp 0x385f
cmpl $0x705, -0x10(%rbp)     # imm = 0x705
jne 0x3849
callq 0x42c0
cmpq $0x0, 0x89d0(%rip)      # 0xc208
je 0x3842
movb $0x0, %al
callq *0x89c6(%rip)           # 0xc208
callq 0x4310
jmp 0x385d
cmpq $0x0, 0x89bf(%rip)      # 0xc210
je 0x385b
movb $0x0, %al
callq *0x89b5(%rip)           # 0xc210
jmp 0x385d
jmp 0x385f
jmp 0x3861
jmp 0x3863
jmp 0x38c6
cmpl $0x13, 0x89b4(%rip)     # 0xc220
jne 0x38a4
movl -0x4(%rbp), %edi
callq 0x3a60
cmpq $0x0, %rax
jne 0x38a4
movl 0x899e(%rip), %eax      # 0xc220
movl %eax, 0x89a0(%rip)      # 0xc228
movl -0x4(%rbp), %edi
callq 0x3620
cmpq $0x0, 0x8950(%rip)      # 0xc1e8
je 0x38a2
movb $0x0, %al
callq *0x8946(%rip)           # 0xc1e8
jmp 0x38c4
movl 0x8976(%rip), %eax      # 0xc220
movl %eax, 0x8978(%rip)      # 0xc228
cmpq $0x0, 0x8928(%rip)      # 0xc1e0
je 0x38c2
movb $0x0, %al
callq *0x891e(%rip)           # 0xc1e0
jmp 0x38c4
jmp 0x38c6
jmp 0x38c8
cmpl $0x0, 0x8955(%rip)      # 0xc224
jne 0x38e0
movl -0x4(%rbp), %edi
movl $0x9, %esi
callq 0x3170
jmp 0x392c
movl 0x893e(%rip), %edi      # 0xc224
callq 0x3680
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edi
movl -0x4(%rbp), %esi
movl 0x892e(%rip), %ecx      # 0xc228
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x3190
cmpq $-0x1, %rax
jne 0x392a
leaq 0x4796(%rip), %rdi      # 0x80a8
leaq 0x4791(%rip), %rsi      # 0x80aa
movl $0xb6, %edx
leaq 0x4809(%rip), %rcx      # 0x812e
callq 0x30c0
jmp 0x392c
jmp 0x39e6
movl -0x8(%rbp), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
jne 0x3969
movl -0x4(%rbp), %edi
callq 0x3ae0
movl -0x8(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movl %eax, 0x88d7(%rip)      # 0xc22c
cmpq $0x0, 0x886b(%rip)      # 0xc1c8
je 0x3967
movb $0x0, %al
callq *0x8861(%rip)           # 0xc1c8
jmp 0x39e4
movl -0x8(%rbp), %eax
andl $0x7f, %eax
addl $0x1, %eax
movsbl %al, %eax
sarl %eax
cmpl $0x0, %eax
jle 0x39a4
movl -0x4(%rbp), %edi
callq 0x3ae0
movl -0x8(%rbp), %eax
andl $0x7f, %eax
movl %eax, 0x88a0(%rip)      # 0xc230
cmpq $0x0, 0x8838(%rip)      # 0xc1d0
je 0x39a2
movb $0x0, %al
callq *0x882e(%rip)           # 0xc1d0
jmp 0x39e2
cmpl $0xffff, -0x8(%rbp)     # imm = 0xFFFF
jne 0x39c1
cmpq $0x0, 0x8823(%rip)      # 0xc1d8
je 0x39bf
movb $0x0, %al
callq *0x8819(%rip)           # 0xc1d8
jmp 0x39e0
leaq 0x46e0(%rip), %rdi      # 0x80a8
leaq 0x46db(%rip), %rsi      # 0x80aa
movl $0xca, %edx
leaq 0x4753(%rip), %rcx      # 0x812e
callq 0x30c0
jmp 0x39e2
jmp 0x39e4
jmp 0x39e6
jmp 0x3712
cmpl $-0x1, -0x4(%rbp)
jne 0x3a1a
callq 0x3040
cmpl $0xa, (%rax)
je 0x3a1a
leaq 0x46a6(%rip), %rdi      # 0x80a8
leaq 0x46a1(%rip), %rsi      # 0x80aa
movl $0xce, %edx
leaq 0x4719(%rip), %rcx      # 0x812e
callq 0x30c0
movb $0x0, 0x8717(%rip)      # 0xc138
leaq 0x8718(%rip), %rdi      # 0xc140
callq 0x5430
cmpl $0x0, %eax
je 0x3a51
leaq 0x466f(%rip), %rdi      # 0x80a8
leaq 0x466a(%rip), %rsi      # 0x80aa
movl $0xd2, %edx
leaq 0x46e2(%rip), %rcx      # 0x812e
callq 0x30c0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)