// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x38, %rsp
movl $0x0, 0x34(%rsp)
movl %edi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl $0x0, 0x14(%rsp)
callq 0x2a50
movl 0x30(%rsp), %edi
movq 0x28(%rsp), %rsi
leaq 0x3d4e(%rip), %rdx      # 0x6320
leaq 0x7427(%rip), %rcx      # 0x9a00
xorl %eax, %eax
movl %eax, %r8d
callq 0x21d0
movl %eax, 0x24(%rsp)
cmpl $0x0, %eax
jl 0x2919
movl 0x24(%rsp), %eax
addl $-0x45, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0xc1, %eax
ja 0x2909
movq 0x8(%rsp), %rax
leaq 0x39fb(%rip), %rcx      # 0x6010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x79ab(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7c7d(%rip)      # 0xa2b0
jmp 0x2914
movq 0x7991(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, 0x7c6f(%rip)      # 0xa2b8
jmp 0x2914
movl $0x1, 0x7c68(%rip)      # 0xa2c0
jmp 0x2914
movq 0x796c(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2ab0
cmpl $0x0, %eax
jne 0x2689
movq 0x7958(%rip), %rax      # 0x9fd0
movq (%rax), %rsi
leaq 0x3cc4(%rip), %rdi      # 0x6346
movb $0x0, %al
callq 0x2c10
jmp 0x2914
movl $0x1, 0x7c2c(%rip)      # 0xa2c4
jmp 0x2914
movq 0x792c(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2ce0
cmpl $0x0, %eax
jne 0x26c9
movq 0x7918(%rip), %rax      # 0x9fd0
movq (%rax), %rsi
leaq 0x3ca5(%rip), %rdi      # 0x6367
movb $0x0, %al
callq 0x2c10
jmp 0x2914
movq 0x78fb(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7be5(%rip)      # 0xa2c8
jmp 0x2914
movq 0x78e1(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, 0x7bd7(%rip)      # 0xa2d0
jmp 0x2914
movq 0x78cb(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7bc5(%rip)      # 0xa2d8
jmp 0x2914
movq 0x78b1(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2dd0
jmp 0x2914
movq 0x789d(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, 0x7ba3(%rip)      # 0xa2e0
jmp 0x2914
movq 0x7887(%rip), %rax      # 0x9fd0
cmpq $0x0, (%rax)
je 0x2766
movq 0x787a(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7afc(%rip)      # 0xa260
jmp 0x2770
movl $0x0, 0x7af0(%rip)      # 0xa260
jmp 0x2914
movq 0x7854(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
movl $0x2c, %esi
callq 0x21f0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x27ae
movq 0x7833(%rip), %rax      # 0x9fd0
movq (%rax), %rsi
leaq 0x3be3(%rip), %rdi      # 0x638a
movb $0x0, %al
callq 0x2c10
movq 0x781b(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7b25(%rip)      # 0xa2e8
movq 0x18(%rsp), %rdi
addq $0x1, %rdi
callq 0x2450
movl %eax, 0x7b15(%rip)      # 0xa2ec
jmp 0x2914
movq 0x77ed(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq %rax, 0x7b03(%rip)      # 0xa2f0
jmp 0x2914
movq 0x77d7(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2100
movaps %xmm0, %xmm1
movsd 0x37fc(%rip), %xmm0     # 0x6008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x7ade(%rip)      # 0xa2f8
jmp 0x2914
movl 0x7ad7(%rip), %eax      # 0xa2fc
addl $0x1, %eax
movl %eax, 0x7ace(%rip)      # 0xa2fc
jmp 0x2914
movq 0x7796(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2100
movaps %xmm0, %xmm1
movsd 0x37bb(%rip), %xmm0     # 0x6008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x7aa5(%rip)      # 0xa300
jmp 0x2914
movq 0x7769(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2100
movaps %xmm0, %xmm1
movsd 0x378e(%rip), %xmm0     # 0x6008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x7a7c(%rip)      # 0xa304
jmp 0x2914
cmpl $0x0, 0x14(%rsp)
je 0x289e
movl 0x14(%rsp), %eax
cmpl 0x24(%rsp), %eax
jne 0x28a8
movl 0x24(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x28b6
leaq 0x3af8(%rip), %rdi      # 0x63a7
movb $0x0, %al
callq 0x2c10
jmp 0x2914
movq 0x7711(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7a3b(%rip)      # 0xa308
jmp 0x2914
movl $0x1, 0x7a33(%rip)      # 0xa30c
jmp 0x2914
movq 0x76ee(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7a20(%rip)      # 0xa310
jmp 0x2914
movq 0x76d7(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x7a0d(%rip)      # 0xa314
jmp 0x2914
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x2c10
jmp 0x25c2
cmpl $0x0, 0x14(%rsp)
jne 0x292e
leaq 0x3a9e(%rip), %rdi      # 0x63c5
movb $0x0, %al
callq 0x2c10
cmpl $0x103, 0x14(%rsp)      # imm = 0x103
jne 0x2944
callq 0x2e70
xorl %eax, %eax
addq $0x38, %rsp
retq
callq 0x2250
cmpl $0x0, %eax
je 0x295c
leaq 0x3aa9(%rip), %rdi      # 0x63fe
movb $0x0, %al
callq 0x2ed0
callq 0x21b0
movl %eax, 0x79b1(%rip)      # 0xa318
callq 0x2350
movl %eax, 0x79aa(%rip)      # 0xa31c
movl $0x12, %edi
callq 0x2310
callq 0x3000
callq 0x30b0
movl 0x14(%rsp), %eax
movl %eax, 0x4(%rsp)
subl $0x100, %eax            # imm = 0x100
je 0x29b4
jmp 0x2997
movl 0x4(%rsp), %eax
subl $0x101, %eax            # imm = 0x101
je 0x29d8
jmp 0x29a4
movl 0x4(%rsp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x2a12
jmp 0x2a36
movq 0x760d(%rip), %rax      # 0x9fc8
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
jge 0x29d1
leaq 0x3a4c(%rip), %rdi      # 0x6416
movb $0x0, %al
callq 0x2c10
callq 0x3120
jmp 0x2a44
movq 0x75e9(%rip), %rax      # 0x9fc8
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
jl 0x29f5
leaq 0x3a49(%rip), %rdi      # 0x6437
movb $0x0, %al
callq 0x2c10
movq 0x28(%rsp), %rdi
movq 0x75c7(%rip), %rax      # 0x9fc8
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x31b0
jmp 0x2a44
movq 0x75af(%rip), %rax      # 0x9fc8
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
jge 0x2a2f
leaq 0x3a35(%rip), %rdi      # 0x645d
movb $0x0, %al
callq 0x2c10
callq 0x3340
jmp 0x2a44
leaq 0x3a44(%rip), %rdi      # 0x6481
movb $0x0, %al
callq 0x2ed0
xorl %edi, %edi
callq 0x2470
nopl (%rax,%rax)