// File: /workspace/github_c_makefile_star2_O3/seojangho[P]clee/sandbox.c
// Function: main
int main(int argc, char **argv, char **envp) {
    int param_opt;
    while ((param_opt = getopt(argc, argv, "adesh")) != -1) {
        switch (param_opt) {
            case 'a':
                option_showall = true;
                break;
            case 'd':
                option_enforcing = false;
                break;
            case 'e':
                option_enforcing = true;
                break;
            case 's':
                showpolicy();
                exit(0);
                break;
            case 'h':
                showhelp(argv[0]);
                exit(0);
            case '?':
                showhelp(argv[0]);
                exit(1);
        }
    }
    struct sock_filter filter[DENIED_SYSCALLS + 3];
    filter[0].code = (unsigned short)(BPF_LD | BPF_W | BPF_ABS);
    filter[0].jt = filter[0].jf = 0;
    filter[0].k = offsetof(struct seccomp_data, nr);

    int i;
    for (i = 1;; i++) {
        if (forbidden[i-1] == -1) {
            break;
        }
        filter[i].code = (unsigned short)(BPF_JMP | BPF_JEQ | BPF_K);
        filter[i].jt = DENIED_SYSCALLS - i + 1;
        filter[i].jf = 0;
        filter[i].k = forbidden[i-1];
    }

    filter[i].code = (unsigned short)(BPF_RET | BPF_K);
    filter[i].jt = filter[i].jf = 0;
    filter[i].k = SECCOMP_RET_ALLOW;

    i++;
    filter[i].code = (unsigned short)(BPF_RET | BPF_K);
    filter[i].jt = filter[i].jf = 0;
    filter[i].k = SECCOMP_RET_TRACE;

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

    clee_init();
    clee_set_trigger(exited, onExit);
    clee_set_trigger(syscall_exit, onSyscallExit);
    clee_set_trigger(syscall_seccomp, onSeccomp);
    clee(argv[optind], argv + optind, envp, option_showall ? next_syscall : next, filter, sizeof(filter)/sizeof(filter[0]));

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x6a0, %rsp            # imm = 0x6A0
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
leaq 0x1950(%rip), %r15      # 0x718e
leaq 0x159b(%rip), %r12      # 0x6de0
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31b0
cmpl $0x60, %eax
jle 0x5883
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x5892
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movb $0x1, 0x5a82(%rip)      # 0xb2f1
jmp 0x5845
movb $0x1, 0x5a78(%rip)      # 0xb2f0
jmp 0x5845
movb $0x0, 0x5a6f(%rip)      # 0xb2f0
jmp 0x5845
cmpl $-0x1, %eax
je 0x58a1
cmpl $0x3f, %eax
jne 0x5845
jmp 0x597c
cmpl $0x73, %eax
jne 0x5845
callq 0x59bc
jmp 0x5996
movq $0x20, (%rsp)
movl $0xd1, %eax
xorl %ecx, %ecx
leaq 0x1549(%rip), %rdx      # 0x6e00
movw $0x15, 0x8(%rsp,%rcx,2)
movb %al, 0xa(%rsp,%rcx,2)
movb $0x0, 0xb(%rsp,%rcx,2)
movl (%rcx,%rdx), %esi
movl %esi, 0xc(%rsp,%rcx,2)
addq $0x4, %rcx
decq %rax
jne 0x58b7
movl $0x6, 0x690(%rsp)
movabsq $0x67fff0000, %rax      # imm = 0x67FFF0000
movq %rax, 0x694(%rsp)
movl $0x7ff00000, 0x69c(%rsp) # imm = 0x7FF00000
movq 0x56d2(%rip), %r15      # 0xafd8
cmpl %ebp, (%r15)
je 0x597c
xorl %eax, %eax
callq 0x32fc
leaq -0x168(%rip), %rsi      # 0x57b1
movl $0x2, %edi
callq 0x3a79
leaq -0x1b6(%rip), %rsi      # 0x5774
movl $0x1, %edi
callq 0x3a79
leaq -0x166(%rip), %rsi      # 0x57d5
movl $0xa, %edi
callq 0x3a79
movslq (%r15), %rax
leaq (%r14,%rax,8), %rsi
movq (%rsi), %rdi
movzbl 0x599b(%rip), %ecx      # 0xb2f1
addl $0x3, %ecx
movq %rsp, %r8
movq %rbx, %rdx
movl $0xd4, %r9d
callq 0x339e
xorl %eax, %eax
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x599d
movl $0x1, %edi
callq 0x31d0
movq (%r14), %rdi
callq 0x599d
xorl %edi, %edi
callq 0x31d0