// File: /workspace/github_c_makefile_star2_O1/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 0x1948(%rip), %r15      # 0x718e
leaq 0x1593(%rip), %r12      # 0x6de0
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x31b0
cmpl $0x60, %eax
jle 0x588b
leal -0x61(%rax), %ecx
cmpl $0x7, %ecx
ja 0x589a
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movb $0x1, 0x5a7a(%rip)      # 0xb2f1
jmp 0x584d
movb $0x1, 0x5a70(%rip)      # 0xb2f0
jmp 0x584d
movb $0x0, 0x5a67(%rip)      # 0xb2f0
jmp 0x584d
cmpl $-0x1, %eax
je 0x58a9
cmpl $0x3f, %eax
jne 0x584d
jmp 0x5984
cmpl $0x73, %eax
jne 0x584d
callq 0x59c4
jmp 0x599e
movq $0x20, (%rsp)
movl $0xd1, %eax
xorl %ecx, %ecx
leaq 0x1541(%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 0x58bf
movl $0x6, 0x690(%rsp)
movabsq $0x67fff0000, %rax      # imm = 0x67FFF0000
movq %rax, 0x694(%rsp)
movl $0x7ff00000, 0x69c(%rsp) # imm = 0x7FF00000
movq 0x56ca(%rip), %r15      # 0xafd8
cmpl %ebp, (%r15)
je 0x5984
xorl %eax, %eax
callq 0x32fc
leaq -0x168(%rip), %rsi      # 0x57b9
movl $0x2, %edi
callq 0x3a7f
leaq -0x1b6(%rip), %rsi      # 0x577c
movl $0x1, %edi
callq 0x3a7f
leaq -0x166(%rip), %rsi      # 0x57dd
movl $0xa, %edi
callq 0x3a7f
movslq (%r15), %rax
leaq (%r14,%rax,8), %rsi
movq (%rsi), %rdi
movzbl 0x5993(%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 0x59a5
movl $0x1, %edi
callq 0x31d0
movq (%r14), %rdi
callq 0x59a5
xorl %edi, %edi
callq 0x31d0