// File: /workspace/github_c_makefile_star2_O3/seojangho[P]clee/interpose.c
// Function: main
int main(int argc, char **argv, char **envp) {
    int param_opt;
    _Bool seccomp_enabled = false;
    while ((param_opt = getopt(argc, argv, "abcoqh")) != -1) {
        switch (param_opt) {
            case 'a':
                option_write_stdout = true;
                break;
            case 'b':
                option_nullify_stdout = true;
                break;
            case 'c':
                option_write2read = true;
                break;
            case 'q':
                option_print_syscall = false;
                break;
            case 'o':
                seccomp_enabled = true;
                break;
            case 'h':
                showhelp(argv[0]);
                exit(0);
            case '?':
                showhelp(argv[0]);
                exit(1);
        }
    }
    struct sock_filter filter[] = {
        BPF_STMT(BPF_LD | BPF_W | BPF_ABS, (offsetof(struct seccomp_data, nr))),
        BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_open, 1, 0),
        BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
        BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL),
    };

    if (optind == argc) {
        showhelp(argv[0]);
        exit(1);
    }

    clee_init();
    clee_set_trigger(exited, onExit);
    clee_set_trigger(syscall_entry, onSyscallEntry);
    clee_set_trigger(syscall_exit, onSyscallExit);
    clee_set_trigger(new_process, onNew);
    clee(argv[optind], argv + optind, envp, next_syscall, seccomp_enabled ? filter : NULL, 4);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
xorl %r12d, %r12d
leaq 0x1593(%rip), %r15      # 0x6e56
leaq 0x151e(%rip), %r13      # 0x6de8
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31a0
cmpl $0x6e, %eax
jg 0x58f7
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x5921
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x1, 0x49f4(%rip)      # 0xa2e9
jmp 0x58ca
cmpl $0x71, %eax
jne 0x5917
movb $0x1, 0x49e8(%rip)      # 0xa2eb
jmp 0x58ca
movb $0x1, 0x49dc(%rip)      # 0xa2e8
jmp 0x58ca
movb $0x1, 0x49d5(%rip)      # 0xa2ea
jmp 0x58ca
cmpl $0x6f, %eax
jne 0x58ca
movb $0x1, %r12b
jmp 0x58ca
cmpl $-0x1, %eax
je 0x593d
cmpl $0x3f, %eax
jne 0x58ca
movq (%r14), %rdi
callq 0x59f5
movl $0x1, %edi
callq 0x31c0
movaps 0x168c(%rip), %xmm0     # 0x6fd0
movaps %xmm0, 0x10(%rsp)
movaps 0x1670(%rip), %xmm0     # 0x6fc0
movaps %xmm0, (%rsp)
movq 0x467d(%rip), %r13      # 0x9fd8
cmpl %ebp, (%r13)
je 0x592b
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x32ec
leaq -0xf3(%rip), %rsi       # 0x587f
movl $0x2, %edi
callq 0x3a69
leaq -0x21f(%rip), %rsi      # 0x5764
xorl %edi, %edi
callq 0x3a69
leaq -0x159(%rip), %rsi      # 0x5838
movl $0x1, %edi
callq 0x3a69
leaq -0x183(%rip), %rsi      # 0x581f
movl $0x6, %edi
callq 0x3a69
movslq (%r13), %rax
leaq (%r14,%rax,8), %rsi
movq (%rsi), %rdi
testb $0x1, %r12b
movq %rsp, %r8
cmoveq %r15, %r8
movq %rbx, %rdx
movl $0x4, %ecx
movl $0x4, %r9d
callq 0x338e
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x59f5
xorl %edi, %edi
callq 0x31c0