// File: /workspace/github_c_makefile_star2_O2/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 0x1a1d(%rip), %r15      # 0x6e3e
leaq 0x19a8(%rip), %r13      # 0x6dd0
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31a0
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x5450
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movb $0x1, 0x5e9b(%rip)      # 0xb2e9
jmp 0x5428
cmpl $0x71, %eax
je 0x547b
cmpl $-0x1, %eax
je 0x5489
cmpl $0x6f, %eax
je 0x5484
cmpl $0x3f, %eax
jne 0x5428
jmp 0x553a
movb $0x1, 0x5e78(%rip)      # 0xb2e8
jmp 0x5428
movb $0x1, 0x5e71(%rip)      # 0xb2ea
jmp 0x5428
movb $0x1, 0x5e69(%rip)      # 0xb2eb
jmp 0x5428
movb $0x1, %r12b
jmp 0x5428
movaps 0x1b30(%rip), %xmm0     # 0x6fc0
movaps %xmm0, 0x10(%rsp)
movaps 0x1b14(%rip), %xmm0     # 0x6fb0
movaps %xmm0, (%rsp)
movq 0x5b31(%rip), %r13      # 0xafd8
cmpl %ebp, (%r13)
je 0x553a
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x32ec
leaq -0xe5(%rip), %rsi       # 0x53dd
pushq $0x2
popq %rdi
callq 0x3a04
leaq -0x20d(%rip), %rsi      # 0x52c4
xorl %edi, %edi
callq 0x3a04
leaq -0x149(%rip), %rsi      # 0x5396
pushq $0x1
popq %rdi
callq 0x3a04
leaq -0x171(%rip), %rsi      # 0x537d
pushq $0x6
popq %rdi
callq 0x3a04
movslq (%r13), %rax
leaq (%r14,%rax,8), %rsi
movq (%rsi), %rdi
testb $0x1, %r12b
movq %rsp, %r8
cmoveq %r15, %r8
pushq $0x4
popq %rcx
movq %rbx, %rdx
movl %ecx, %r9d
callq 0x3394
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x554a
xorl %edi, %edi
callq 0x31c0
movq (%r14), %rdi
callq 0x554a
pushq $0x1
popq %rdi
callq 0x31c0