// File: /workspace/github_c_makefile_star2_O1/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 0x158b(%rip), %r15      # 0x6e56
leaq 0x1516(%rip), %r13      # 0x6de8
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31a0
cmpl $0x6e, %eax
jg 0x58ff
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x5929
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x1, 0x49ec(%rip)      # 0xa2e9
jmp 0x58d2
cmpl $0x71, %eax
jne 0x591f
movb $0x1, 0x49e0(%rip)      # 0xa2eb
jmp 0x58d2
movb $0x1, 0x49d4(%rip)      # 0xa2e8
jmp 0x58d2
movb $0x1, 0x49cd(%rip)      # 0xa2ea
jmp 0x58d2
cmpl $0x6f, %eax
jne 0x58d2
movb $0x1, %r12b
jmp 0x58d2
cmpl $-0x1, %eax
je 0x5945
cmpl $0x3f, %eax
jne 0x58d2
movq (%r14), %rdi
callq 0x59fd
movl $0x1, %edi
callq 0x31c0
movaps 0x1684(%rip), %xmm0     # 0x6fd0
movaps %xmm0, 0x10(%rsp)
movaps 0x1668(%rip), %xmm0     # 0x6fc0
movaps %xmm0, (%rsp)
movq 0x4675(%rip), %r13      # 0x9fd8
cmpl %ebp, (%r13)
je 0x5933
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x32ec
leaq -0xf3(%rip), %rsi       # 0x5887
movl $0x2, %edi
callq 0x3a6f
leaq -0x21f(%rip), %rsi      # 0x576c
xorl %edi, %edi
callq 0x3a6f
leaq -0x159(%rip), %rsi      # 0x5840
movl $0x1, %edi
callq 0x3a6f
leaq -0x183(%rip), %rsi      # 0x5827
movl $0x6, %edi
callq 0x3a6f
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 0x59fd
xorl %edi, %edi
callq 0x31c0