// File: /workspace/github_c_makefile_star2_O2/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 0x1de0(%rip), %r15      # 0x717e
leaq 0x1a2b(%rip), %r12      # 0x6dd0
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31b0
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x53de
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movb $0x1, 0x5f27(%rip)      # 0xb2f1
jmp 0x53a5
movb $0x1, 0x5f1d(%rip)      # 0xb2f0
jmp 0x53a5
movb $0x0, 0x5f14(%rip)      # 0xb2f0
jmp 0x53a5
cmpl $-0x1, %eax
je 0x53fb
cmpl $0x3f, %eax
je 0x54eb
cmpl $0x73, %eax
jne 0x53a5
callq 0x551a
jmp 0x54e4
movq $0x20, (%rsp)
movl $0xd1, %esi
xorl %eax, %eax
leaq 0x19df(%rip), %rcx      # 0x6df0
movl $0xd1, %edx
subq $0x1, %rdx
jb 0x543d
movw $0x15, 0x8(%rsp,%rax,2)
movb %sil, 0xa(%rsp,%rax,2)
movb $0x0, 0xb(%rsp,%rax,2)
movl (%rax,%rcx), %esi
movl %esi, 0xc(%rsp,%rax,2)
addq $0x4, %rax
movq %rdx, %rsi
jmp 0x5416
movl $0x6, 0x690(%rsp)
movabsq $0x67fff0000, %rax      # imm = 0x67FFF0000
movq %rax, 0x694(%rsp)
movl $0x7ff00000, 0x69c(%rsp) # imm = 0x7FF00000
movq 0x5b6c(%rip), %r15      # 0xafd8
cmpl %ebp, (%r15)
je 0x54eb
xorl %eax, %eax
callq 0x32fc
leaq -0x16e(%rip), %rsi      # 0x5311
pushq $0x2
popq %rdi
callq 0x3a14
leaq -0x1ba(%rip), %rsi      # 0x52d4
pushq $0x1
popq %rdi
callq 0x3a14
leaq -0x168(%rip), %rsi      # 0x5335
pushq $0xa
popq %rdi
callq 0x3a14
movslq (%r15), %rax
leaq (%r14,%rax,8), %rsi
movq (%rsi), %rdi
movzbl 0x5e3b(%rip), %ecx      # 0xb2f1
addl $0x3, %ecx
movq %rsp, %r8
movq %rbx, %rdx
movl $0xd4, %r9d
callq 0x33a4
xorl %eax, %eax
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
callq 0x54fb
xorl %edi, %edi
callq 0x31d0
movq (%r14), %rdi
callq 0x54fb
pushq $0x1
popq %rdi
callq 0x31d0