// File: /workspace/github_c_makefile_star2_O1/seojangho[P]clee/clee.c
// Function: clee
pid_t clee(const char *filename, char *const argv[], char *const envp[], clee_behavior initial_behavior, struct sock_filter *filter, unsigned short len) {
    if (tracing) {
        CLEE_ERROR;
    }
    pid_t pid;
    switch (pid = fork()) {
        case -1:
            /* error */
            CLEE_ERROR;
        case 0:
            if (filter != NULL) {
                if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1) {
                    _exit(1);
                }
                struct sock_fprog prog = {
                    .len = len,
                    .filter = filter,
                };
                if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog) == -1) {
                    _exit(1);
                }
            }
            if (ptrace(PTRACE_TRACEME, NULL, NULL, NULL) == -1)
            {
                /* ptrace error */
                _exit(1);
            }
            execve(filename, argv, envp);   // causes SIGTRAP
            /* execve error */
            _exit(1);
        default: ;
            /* parent */
            int status;
            if (waitpid(pid, &status, 0) == -1)
            {
                /* waitpid error */
                CLEE_ERROR;
            }
            clee_children_add(pid);
            if (WIFSTOPPED(status)) {
                long const options =
                    PTRACE_O_TRACESECCOMP |
                    PTRACE_O_TRACESYSGOOD |
                    PTRACE_O_TRACEFORK |
                    PTRACE_O_TRACEVFORK |
                    PTRACE_O_TRACECLONE;
                if (ptrace(PTRACE_SETOPTIONS, pid, 0, options) == -1) {
                    /* ptrace error */
                    CLEE_ERROR;
                }
                tracing = true;
                default_behavior = initial_behavior;
                ptrace(clee_behavior2request(initial_behavior), pid, NULL, 0);
                clee_main();
                return pid;
            }
            else
            {
                /* fail on child ptrace/execve error */
                CLEE_ERROR;
            }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, (%rsp)
cmpb $0x1, 0x6d69(%rip)      # 0xa110
je 0x3464
movl %r9d, %r14d
movq %r8, %r13
movl %ecx, %ebp
movq %rsi, %r15
movq %rdi, %r12
callq 0x31d0
testl %eax, %eax
je 0x3483
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x34b9
leaq 0x8(%rsp), %rsi
movl %ebx, %edi
xorl %edx, %edx
callq 0x3180
cmpl $-0x1, %eax
je 0x34d8
movl %ebx, %edi
callq 0x3583
cmpb $0x7f, 0x8(%rsp)
jne 0x34f7
movl $0x8f, %ecx
movl $0x4200, %edi           # imm = 0x4200
movl %ebx, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3170
cmpq $-0x1, %rax
je 0x3516
movb $0x1, 0x6cee(%rip)      # 0xa110
movl %ebp, 0x6dc8(%rip)      # 0xa1f0
addl $-0x2, %ebp
movl $0x4207, %edi           # imm = 0x4207
cmpl $0x3, %ebp
ja 0x3441
movl %ebp, %eax
leaq 0x2e0e(%rip), %rcx      # 0x624c
movl (%rcx,%rax,4), %edi
movl %ebx, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3170
callq 0x35e0
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bcd(%rip), %rdi      # 0x6038
leaq 0x2bc8(%rip), %rsi      # 0x603a
leaq 0x2bd9(%rip), %rcx      # 0x6052
movl $0x35, %edx
callq 0x30c0
testq %r13, %r13
jne 0x3535
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3170
cmpq $-0x1, %rax
je 0x3579
movq %r12, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x30f0
jmp 0x3579
leaq 0x2b78(%rip), %rdi      # 0x6038
leaq 0x2b73(%rip), %rsi      # 0x603a
leaq 0x2b84(%rip), %rcx      # 0x6052
movl $0x3b, %edx
callq 0x30c0
leaq 0x2b59(%rip), %rdi      # 0x6038
leaq 0x2b54(%rip), %rsi      # 0x603a
leaq 0x2b65(%rip), %rcx      # 0x6052
movl $0x57, %edx
callq 0x30c0
leaq 0x2b3a(%rip), %rdi      # 0x6038
leaq 0x2b35(%rip), %rsi      # 0x603a
leaq 0x2b46(%rip), %rcx      # 0x6052
movl $0x6e, %edx
callq 0x30c0
leaq 0x2b1b(%rip), %rdi      # 0x6038
leaq 0x2b16(%rip), %rsi      # 0x603a
leaq 0x2b27(%rip), %rcx      # 0x6052
movl $0x63, %edx
callq 0x30c0
movl $0x26, %edi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3140
cmpl $-0x1, %eax
je 0x3579
leaq 0x8(%rsp), %rdx
movw %r14w, (%rdx)
movq %r13, 0x8(%rdx)
movl $0x16, %edi
movl $0x2, %esi
xorl %eax, %eax
callq 0x3140
cmpl $-0x1, %eax
jne 0x348c
movl $0x1, %edi
callq 0x3050