// File: /workspace/github_c_makefile_star2_O1/silverneko[P]miku/isolate/isolate.c
// Function: main
int
main(int argc, char **argv)
{
  int c;
  char *sep;
  enum opt_code mode = 0;

  init_dir_rules();

  while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) >= 0)
    switch (c){
      case 'b':
        box_id = atoi(optarg);
        break;
      case 'c':
        set_cwd = optarg;
        break;
      case OPT_CG:
        cg_enable = 1;
        break;
      case 'd':
        if (!set_dir_action(optarg))
          usage("Invalid directory specified: %s\n", optarg);
        break;
      case 'e':
        pass_environ = 1;
        break;
      case 'E':
        if (!set_env_action(optarg))
          usage("Invalid environment specified: %s\n", optarg);
        break;
      case 'k':
        stack_limit = atoi(optarg);
        break;
      case 'i':
        redir_stdin = optarg;
        break;
      case 'm':
        memory_limit = atoi(optarg);
        break;
      case 'M':
        meta_open(optarg);
        break;
      case 'o':
        redir_stdout = optarg;
        break;
      case 'p':
        if (optarg)
          max_processes = atoi(optarg);
        else
          max_processes = 0;
        break;
      case 'q':
        sep = strchr(optarg, ',');
        if (!sep)
          usage("Invalid quota specified: %s\n", optarg);
        block_quota = atoi(optarg);
        inode_quota = atoi(sep+1);
        break;
      case 'r':
        redir_stderr = optarg;
        break;
      case 't':
        timeout = 1000*atof(optarg);
        break;
      case 'v':
        verbose++;
        break;
      case 'w':
        wall_timeout = 1000*atof(optarg);
        break;
      case 'x':
        extra_timeout = 1000*atof(optarg);
        break;
      case OPT_INIT:
      case OPT_RUN:
      case OPT_CLEANUP:
      case OPT_VERSION:
        if (!mode || mode == c)
          mode = c;
        else
          usage("Only one command is allowed.\n");
        break;
      case OPT_CG_MEM:
        cg_memory_limit = atoi(optarg);
        break;
      case OPT_CG_TIMING:
        cg_timing = 1;
        break;
      case 'f':
        file_limit = atoi(optarg);
        break;
      case 's':
        fsize_limit = atoi(optarg);
        break;
      default:
        usage(NULL);
    }

  if (!mode)
    usage("Please specify an isolate command (e.g. --init, --run).\n");
  if (mode == OPT_VERSION)
    {
      show_version();
      return 0;
    }

  if (geteuid())
    die("Must be started as root");
  orig_uid = getuid();
  orig_gid = getgid();

  umask(022);
  box_init();
  cg_init();

  switch (mode){
    case OPT_INIT:
      if (optind < argc)
        usage("--init mode takes no parameters\n");
      init();
      break;
    case OPT_RUN:
      if (optind >= argc)
        usage("--run mode requires a command to run\n");
      run(argv+optind);
      break;
    case OPT_CLEANUP:
      if (optind < argc)
        usage("--cleanup mode takes no parameters\n");
      cleanup();
      break;
    default:
      die("Internal error: mode mismatch");
  }
  exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
leaq 0x2c62(%rip), %rdi      # 0x5275
callq 0x2bd2
leaq 0x2c63(%rip), %rdi      # 0x5282
callq 0x2bd2
leaq 0x2c5b(%rip), %rdi      # 0x5286
callq 0x2bd2
leaq 0x2c57(%rip), %rdi      # 0x528e
callq 0x2bd2
leaq 0x2c4f(%rip), %rdi      # 0x5292
callq 0x2bd2
leaq 0x2c4f(%rip), %rdi      # 0x529e
callq 0x2bd2
leaq 0x2c50(%rip), %rdi      # 0x52ab
callq 0x2bd2
leaq 0x2a79(%rip), %rdx      # 0x50e0
leaq 0x63c2(%rip), %rcx      # 0x8a30
xorl %r12d, %r12d
movl %ebx, %edi
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x21d0
testl %eax, %eax
movl %ebx, 0x4(%rsp)
js 0x29fc
xorl %r12d, %r12d
movq 0x693c(%rip), %r15      # 0x8fd0
leal -0x4d(%rax), %ecx
cmpl $0x2b, %ecx
ja 0x2731
leaq 0x2969(%rip), %rdx      # 0x5010
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq (%r15), %rbp
movq %rbp, %rdi
leaq 0x2cc6(%rip), %rsi      # 0x5383
callq 0x22f0
testl %eax, %eax
je 0x298b
callq 0x2250
movq %r12, %rbx
movq %r15, %r12
movl %eax, %r15d
callq 0x21b0
movl %r15d, %edi
movl %eax, %esi
callq 0x23d0
movq %rbp, %rdi
leaq 0x2b8f(%rip), %rsi      # 0x5280
callq 0x2410
movq %rax, 0x6c43(%rip)      # 0x9340
callq 0x2250
movl %eax, %r15d
callq 0x21b0
movl %r15d, %edi
movq %r12, %r15
movq %rbx, %r12
movl 0x4(%rsp), %ebx
movl %eax, %esi
callq 0x23d0
cmpq $0x0, 0x6c1a(%rip)      # 0x9340
jne 0x29d9
jmp 0x2b5e
leal -0x100(%rax), %ecx
cmpl $0x6, %ecx
ja 0x2768
leaq 0x297d(%rip), %rdx      # 0x50c0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testl %r12d, %r12d
sete %cl
cmpl %eax, %r12d
sete %dl
orb %cl, %dl
movl %eax, %r12d
jne 0x29d9
jmp 0x2a72
cmpl $0x45, %eax
jne 0x2a9d
movq %r12, %rbx
movq %r15, %r12
movq (%r15), %r15
movq %r15, %rdi
callq 0x2180
leaq 0x21(%rax), %rdi
callq 0x2360
testq %rax, %rax
je 0x2b4c
movq %rax, %rbp
leaq 0x20(%rax), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2090
movq %r13, %rdi
movl $0x3d, %esi
callq 0x21f0
cmpq %r13, %rax
movq %r12, %r15
movq %rbx, %r12
movl 0x4(%rsp), %ebx
je 0x2a8e
movq %r13, (%rbp)
testq %rax, %rax
je 0x29aa
leaq 0x1(%rax), %rcx
movb $0x0, (%rax)
jmp 0x29ac
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x6b37(%rip)      # 0x9324
jmp 0x29d9
movq (%r15), %rax
movq %rax, 0x6b04(%rip)      # 0x9300
jmp 0x29d9
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x6ad9(%rip)      # 0x92e8
jmp 0x29d9
movq %r12, %rbx
movq %r15, %r12
movq (%r15), %r15
movq %r15, %rdi
movl $0x2c, %esi
callq 0x21f0
testq %rax, %rax
je 0x2b2f
movq %rax, %r13
movq (%r12), %rdi
callq 0x2450
movl %eax, 0x6ab3(%rip)      # 0x92f8
incq %r13
movq %r13, %rdi
callq 0x2450
movl %eax, 0x6aa6(%rip)      # 0x92fc
movq %r12, %r15
movq %rbx, %r12
movl 0x4(%rsp), %ebx
jmp 0x29d9
movq (%r15), %rax
movq %rax, 0x6a81(%rip)      # 0x92f0
jmp 0x29d9
movb $0x1, 0x6a59(%rip)      # 0x92d4
jmp 0x29d9
movq (%r15), %rdi
callq 0x2100
mulsd 0x2778(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x6a7a(%rip)      # 0x9314
jmp 0x29d9
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x6a73(%rip)      # 0x9320
jmp 0x29d9
movq (%r15), %rax
movq %rax, 0x6a0c(%rip)      # 0x92c8
jmp 0x29d9
movq (%r15), %rax
movq %rax, 0x6a15(%rip)      # 0x92e0
jmp 0x29d9
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x69e2(%rip)      # 0x92c0
jmp 0x29d9
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x69e7(%rip)      # 0x92d8
jmp 0x29d9
movq (%r15), %rdi
callq 0x2100
mulsd 0x2702(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x6a00(%rip)      # 0x9310
jmp 0x29d9
movq (%r15), %rdi
callq 0x2bd2
testl %eax, %eax
jne 0x29d9
jmp 0x2b3b
incl 0x69dc(%rip)            # 0x930c
jmp 0x29d9
movq (%r15), %rdi
testq %rdi, %rdi
je 0x299e
callq 0x2450
movl %eax, 0x6928(%rip)      # 0x9270
jmp 0x29d9
movq (%r15), %rdi
callq 0x2100
mulsd 0x26ab(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x69a1(%rip)      # 0x9308
jmp 0x29d9
movq (%r15), %rdi
callq 0x2450
movl %eax, 0x69a1(%rip)      # 0x9318
jmp 0x29d9
movb $0x1, 0x699c(%rip)      # 0x931c
jmp 0x29d9
movb $0x1, 0x6947(%rip)      # 0x92d0
jmp 0x29d9
movq 0x662e(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movq %rax, 0x69a4(%rip)      # 0x9340
jmp 0x29d9
movl $0x0, 0x68c8(%rip)      # 0x9270
jmp 0x29d9
xorl %ecx, %ecx
movq %rbp, %rdx
addq $0x18, %rdx
movq %rcx, 0x8(%rbp)
movq 0x68c2(%rip), %rcx      # 0x9280
movq %rbp, (%rcx)
movq %rdx, 0x68b8(%rip)      # 0x9280
movq $0x0, 0x18(%rbp)
cmpq %r13, %rax
je 0x2a8e
movl %ebx, %edi
movq %r14, %rsi
leaq 0x26fb(%rip), %rdx      # 0x50e0
leaq 0x6044(%rip), %rcx      # 0x8a30
xorl %r8d, %r8d
callq 0x21d0
testl %eax, %eax
jns 0x2694
cmpl $0x103, %r12d           # imm = 0x103
jne 0x2a7b
leaq 0x3dfe(%rip), %rdi      # 0x680a
callq 0x20c0
leaq 0x3e07(%rip), %rdi      # 0x681f
callq 0x20c0
leaq 0x3e26(%rip), %rdi      # 0x684a
callq 0x20c0
leaq 0x2972(%rip), %rdi      # 0x53a2
leaq 0x2982(%rip), %rsi      # 0x53b9
xorl %eax, %eax
callq 0x2200
leaq 0x297d(%rip), %rdi      # 0x53c2
movl $0xea60, %esi           # imm = 0xEA60
movl $0x15f8f, %edx          # imm = 0x15F8F
movl $0xea60, %ecx           # imm = 0xEA60
movl $0x15f8f, %r8d          # imm = 0x15F8F
xorl %eax, %eax
callq 0x2200
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2704(%rip), %rdi      # 0x517d
jmp 0x2a87
testl %r12d, %r12d
jne 0x2ab3
leaq 0x2714(%rip), %rdi      # 0x519b
xorl %eax, %eax
callq 0x2d34
movq (%r15), %rsi
leaq 0x26a5(%rip), %rdi      # 0x513d
jmp 0x2b45
leaq 0x3446(%rip), %rdi      # 0x5eea
callq 0x20c0
movl $0x2, %edi
callq 0x2470
movq %r12, %r15
callq 0x2250
testl %eax, %eax
jne 0x2b55
callq 0x21b0
movl %eax, 0x685a(%rip)      # 0x9328
callq 0x2350
movl %eax, 0x6853(%rip)      # 0x932c
movl $0x12, %edi
callq 0x2310
callq 0x2ee5
callq 0x2f6b
cmpl $0x102, %r15d           # imm = 0x102
je 0x2b6f
cmpl $0x101, %r15d           # imm = 0x101
je 0x2b8a
cmpl $0x100, %r15d           # imm = 0x100
jne 0x2ba5
movq 0x64b1(%rip), %rax      # 0x8fc8
movl 0x4(%rsp), %ecx
cmpl %ecx, (%rax)
jge 0x2bb3
leaq 0x26c2(%rip), %rdi      # 0x51ec
jmp 0x2a87
leaq 0x262a(%rip), %rdi      # 0x5160
movq %r15, %rsi
jmp 0x2b45
movq (%r15), %rsi
leaq 0x25d7(%rip), %rdi      # 0x511c
xorl %eax, %eax
callq 0x2d34
leaq 0x27fc(%rip), %rdi      # 0x534f
jmp 0x2bac
leaq 0x2678(%rip), %rdi      # 0x51d4
jmp 0x2bac
leaq 0x2820(%rip), %rdi      # 0x5385
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2de4
movq 0x6452(%rip), %rax      # 0x8fc8
movl 0x4(%rsp), %ecx
cmpl %ecx, (%rax)
jge 0x2bba
leaq 0x26ae(%rip), %rdi      # 0x5233
jmp 0x2a87
movq 0x6437(%rip), %rax      # 0x8fc8
movl 0x4(%rsp), %ecx
cmpl %ecx, (%rax)
jge 0x2bc6
movslq (%rax), %rax
leaq (%r14,%rax,8), %rdi
callq 0x3432
leaq 0x26ab(%rip), %rdi      # 0x5257
xorl %eax, %eax
callq 0x2de4
callq 0x2ff9
jmp 0x2bbf
callq 0x38c8
xorl %edi, %edi
callq 0x2470
leaq 0x2640(%rip), %rdi      # 0x520d
jmp 0x2a87