// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x6d0, %rsp            # imm = 0x6D0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1d21(%rip), %rdx      # 0x930c
callq 0x31e0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
je 0x767c
movl -0x1c(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x6d0(%rbp)
subl $0x34, %eax
ja 0x7677
movq -0x6d0(%rbp), %rax
leaq 0x1872(%rip), %rcx      # 0x8e90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x1, 0x5ce3(%rip)      # 0xd311
jmp 0x7677
movb $0x0, 0x5cd9(%rip)      # 0xd310
jmp 0x7677
movb $0x1, 0x5cd0(%rip)      # 0xd310
jmp 0x7677
callq 0x78d0
xorl %edi, %edi
callq 0x3200
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7890
xorl %edi, %edi
callq 0x3200
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7890
movl $0x1, %edi
callq 0x3200
jmp 0x75dd
movw $0x20, -0x6c0(%rbp)
movb $0x0, -0x6bd(%rbp)
movb $0x0, -0x6be(%rbp)
movl $0x0, -0x6bc(%rbp)
movl $0x1, -0x6c4(%rbp)
movl -0x6c4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x18b6(%rip), %rax      # 0x8f70
cmpl $-0x1, (%rax,%rcx,4)
jne 0x76c2
jmp 0x7738
movslq -0x6c4(%rbp), %rax
movw $0x15, -0x6c0(%rbp,%rax,8)
movl $0xd1, %eax
subl -0x6c4(%rbp), %eax
addl $0x1, %eax
movb %al, %cl
movslq -0x6c4(%rbp), %rax
movb %cl, -0x6be(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movb $0x0, -0x6bd(%rbp,%rax,8)
movl -0x6c4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x185d(%rip), %rax      # 0x8f70
movl (%rax,%rcx,4), %ecx
movslq -0x6c4(%rbp), %rax
movl %ecx, -0x6bc(%rbp,%rax,8)
movl -0x6c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c4(%rbp)
jmp 0x76a7
movslq -0x6c4(%rbp), %rax
movw $0x6, -0x6c0(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movb $0x0, -0x6bd(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movb $0x0, -0x6be(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movl $0x7fff0000, -0x6bc(%rbp,%rax,8) # imm = 0x7FFF0000
movl -0x6c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c4(%rbp)
movslq -0x6c4(%rbp), %rax
movw $0x6, -0x6c0(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movb $0x0, -0x6bd(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movb $0x0, -0x6be(%rbp,%rax,8)
movslq -0x6c4(%rbp), %rax
movl $0x7ff00000, -0x6bc(%rbp,%rax,8) # imm = 0x7FF00000
movq 0x5808(%rip), %rax      # 0xcfd8
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x77ed
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7890
movl $0x1, %edi
callq 0x3200
movb $0x0, %al
callq 0x3340
movl $0x2, %edi
leaq -0x2e0(%rip), %rsi      # 0x7520
callq 0x3d90
movl $0x1, %edi
leaq -0x341(%rip), %rsi      # 0x74d0
callq 0x3d90
movl $0xa, %edi
leaq -0x2c2(%rip), %rsi      # 0x7560
callq 0x3d90
movq -0x10(%rbp), %rax
movq 0x57a6(%rip), %rcx      # 0xcfd8
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movq 0x5794(%rip), %rax      # 0xcfd8
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
movb 0x5ab8(%rip), %r8b      # 0xd311
movl $0x3, %ecx
movl $0x4, %eax
testb $0x1, %r8b
cmovnel %eax, %ecx
leaq -0x6c0(%rbp), %r8
movl $0xd4, %r9d
callq 0x3420
xorl %eax, %eax
addq $0x6d0, %rsp            # imm = 0x6D0
popq %rbp
retq
nopw (%rax,%rax)