// File: /workspace/github_c_makefile_star2_O3/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 0x2ba2
leaq 0x2c63(%rip), %rdi      # 0x5282
callq 0x2ba2
leaq 0x2c5b(%rip), %rdi      # 0x5286
callq 0x2ba2
leaq 0x2c57(%rip), %rdi      # 0x528e
callq 0x2ba2
leaq 0x2c4f(%rip), %rdi      # 0x5292
callq 0x2ba2
leaq 0x2c4f(%rip), %rdi      # 0x529e
callq 0x2ba2
leaq 0x2c50(%rip), %rdi      # 0x52ab
callq 0x2ba2
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
js 0x2a71
movq 0x6943(%rip), %r13      # 0x8fd0
leaq 0x2a2c(%rip), %r15      # 0x50c0
leal -0x4d(%rax), %ecx
cmpl $0x2b, %ecx
ja 0x2722
leaq 0x2969(%rip), %rdx      # 0x5010
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq (%r13), %rbp
cmpb $0x2d, (%rbp)
jne 0x26c4
cmpb $0x0, 0x1(%rbp)
je 0x29da
callq 0x2250
movl %eax, %r15d
callq 0x21b0
movl %r15d, %edi
movl %eax, %esi
callq 0x23d0
movq %rbp, %rdi
leaq 0x2b9b(%rip), %rsi      # 0x5280
callq 0x2410
movq %rax, 0x6c4f(%rip)      # 0x9340
callq 0x2250
movl %eax, %r15d
callq 0x21b0
movl %r15d, %edi
leaq 0x29b8(%rip), %r15      # 0x50c0
movl %eax, %esi
callq 0x23d0
cmpq $0x0, 0x6c29(%rip)      # 0x9340
jne 0x29b5
jmp 0x2ac8
leal -0x100(%rax), %ecx
cmpl $0x6, %ecx
ja 0x2752
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
jmpq *%rcx
testl %r12d, %r12d
sete %cl
cmpl %eax, %r12d
sete %dl
orb %cl, %dl
movl %eax, %r12d
jne 0x29b5
jmp 0x2a63
cmpl $0x45, %eax
jne 0x2a7f
movq (%r13), %r13
movq %r13, %rdi
callq 0x2180
leaq 0x21(%rax), %rdi
callq 0x2360
testq %rax, %rax
je 0x2aab
movq %rax, %rbp
leaq 0x20(%rax), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x2090
movq %r15, %rdi
movl $0x3d, %esi
callq 0x21f0
cmpq %r15, %rax
je 0x2ab7
movq %r15, (%rbp)
testq %rax, %rax
je 0x2981
movq %rax, %rcx
incq %rcx
movb $0x0, (%rax)
jmp 0x2983
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x6b59(%rip)      # 0x9324
jmp 0x29b5
movq (%r13), %rax
movq %rax, 0x6b25(%rip)      # 0x9300
jmp 0x29b5
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x6af9(%rip)      # 0x92e8
jmp 0x29b5
movq (%r13), %r13
movq %r13, %rdi
movl $0x2c, %esi
callq 0x21f0
testq %rax, %rax
je 0x2a95
movq %rax, %r15
movq %r13, %rdi
callq 0x2450
movl %eax, 0x6ad9(%rip)      # 0x92f8
incq %r15
movq %r15, %rdi
callq 0x2450
movl %eax, 0x6acc(%rip)      # 0x92fc
movq 0x6799(%rip), %r13      # 0x8fd0
leaq 0x2882(%rip), %r15      # 0x50c0
jmp 0x29b5
movq (%r13), %rax
movq %rax, 0x6aa2(%rip)      # 0x92f0
jmp 0x29b5
movb $0x1, 0x6a7a(%rip)      # 0x92d4
jmp 0x29b5
movq (%r13), %rdi
callq 0x2100
mulsd 0x2798(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x6a9a(%rip)      # 0x9314
jmp 0x29b5
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x6a92(%rip)      # 0x9320
jmp 0x29b5
movq (%r13), %rax
movq %rax, 0x6a2a(%rip)      # 0x92c8
jmp 0x29b5
movq (%r13), %rax
movq %rax, 0x6a32(%rip)      # 0x92e0
jmp 0x29b5
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x69fe(%rip)      # 0x92c0
jmp 0x29b5
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x6a02(%rip)      # 0x92d8
jmp 0x29b5
movq (%r13), %rdi
callq 0x2100
mulsd 0x271c(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x6a1a(%rip)      # 0x9310
jmp 0x29b5
movq (%r13), %rdi
callq 0x2ba2
testl %eax, %eax
jne 0x29b5
jmp 0x2a9e
incl 0x69f5(%rip)            # 0x930c
jmp 0x29b5
movq (%r13), %rdi
testq %rdi, %rdi
je 0x2975
callq 0x2450
movl %eax, 0x6940(%rip)      # 0x9270
jmp 0x29b5
movq (%r13), %rdi
callq 0x2100
mulsd 0x26c2(%rip), %xmm0     # 0x5008
cvttsd2si %xmm0, %eax
movl %eax, 0x69b8(%rip)      # 0x9308
jmp 0x29b5
movq (%r13), %rdi
callq 0x2450
movl %eax, 0x69b7(%rip)      # 0x9318
jmp 0x29b5
movb $0x1, 0x69b2(%rip)      # 0x931c
jmp 0x29b5
movb $0x1, 0x695d(%rip)      # 0x92d0
jmp 0x29b5
movl $0x0, 0x68f1(%rip)      # 0x9270
jmp 0x29b5
xorl %ecx, %ecx
movq 0x6646(%rip), %r13      # 0x8fd0
leaq 0x272f(%rip), %r15      # 0x50c0
movq %rcx, 0x8(%rbp)
movq 0x68e4(%rip), %rax      # 0x9280
movq %rbp, (%rax)
movq %rbp, %rax
addq $0x18, %rax
movq %rax, 0x68d3(%rip)      # 0x9280
movq $0x0, 0x18(%rbp)
movl %ebx, %edi
movq %r14, %rsi
leaq 0x271f(%rip), %rdx      # 0x50e0
leaq 0x6068(%rip), %rcx      # 0x8a30
xorl %r8d, %r8d
callq 0x21d0
testl %eax, %eax
jns 0x2694
jmp 0x29ed
movq 0x65df(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movq %rax, 0x6955(%rip)      # 0x9340
jmp 0x29b5
cmpl $0x103, %r12d           # imm = 0x103
jne 0x2a6c
leaq 0x3e0a(%rip), %rdi      # 0x6807
callq 0x20c0
leaq 0x3e13(%rip), %rdi      # 0x681c
callq 0x20c0
leaq 0x3e32(%rip), %rdi      # 0x6847
callq 0x20c0
leaq 0x297c(%rip), %rdi      # 0x539d
leaq 0x298c(%rip), %rsi      # 0x53b4
xorl %eax, %eax
callq 0x2200
leaq 0x2987(%rip), %rdi      # 0x53bd
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 0x2713(%rip), %rdi      # 0x517d
jmp 0x2a78
testl %r12d, %r12d
jne 0x2ad9
leaq 0x2723(%rip), %rdi      # 0x519b
xorl %eax, %eax
callq 0x2ccf
leaq 0x3461(%rip), %rdi      # 0x5ee7
callq 0x20c0
movl $0x2, %edi
callq 0x2470
leaq 0x26c4(%rip), %rdi      # 0x5160
jmp 0x2abe
movq (%r13), %rsi
leaq 0x2673(%rip), %rdi      # 0x511c
jmp 0x2ac1
leaq 0x289d(%rip), %rdi      # 0x534f
jmp 0x2b7c
leaq 0x267f(%rip), %rdi      # 0x513d
movq %r13, %rsi
xorl %eax, %eax
callq 0x2ccf
leaq 0x28b1(%rip), %rdi      # 0x5380
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2d7f
callq 0x2250
testl %eax, %eax
jne 0x2b3e
callq 0x21b0
movl %eax, 0x683b(%rip)      # 0x9328
callq 0x2350
movl %eax, 0x6834(%rip)      # 0x932c
movl $0x12, %edi
callq 0x2310
callq 0x2e80
callq 0x2f06
cmpl $0x102, %r12d           # imm = 0x102
je 0x2b47
cmpl $0x101, %r12d           # imm = 0x101
je 0x2b5e
cmpl $0x100, %r12d           # imm = 0x100
jne 0x2b75
movq 0x649a(%rip), %rax      # 0x8fc8
cmpl %ebx, (%rax)
jge 0x2b83
leaq 0x26b3(%rip), %rdi      # 0x51ec
jmp 0x2a78
leaq 0x268f(%rip), %rdi      # 0x51d4
jmp 0x2b7c
movq 0x647a(%rip), %rax      # 0x8fc8
cmpl %ebx, (%rax)
jge 0x2b8a
leaq 0x26da(%rip), %rdi      # 0x5233
jmp 0x2a78
movq 0x6463(%rip), %rax      # 0x8fc8
movslq (%rax), %rax
cmpl %ebx, %eax
jge 0x2b96
leaq (%r14,%rax,8), %rdi
callq 0x33fb
leaq 0x26db(%rip), %rdi      # 0x5257
xorl %eax, %eax
callq 0x2d7f
callq 0x2f94
jmp 0x2b8f
callq 0x389c
xorl %edi, %edi
callq 0x2470
leaq 0x2670(%rip), %rdi      # 0x520d
jmp 0x2a78