// File: /workspace/github_c_makefile_star2_O2/arachsys[P]containers/pseudo.c
// Function: main
int main(int argc, char **argv) {
  char *gidmap = NULL, *uidmap = NULL;
  int option;
  pid_t child, parent;

  while ((option = getopt(argc, argv, "+:g:u:")) > 0)
    switch (option) {
      case 'g':
        gidmap = optarg;
        break;
      case 'u':
        uidmap = optarg;
        break;
      default:
        usage(argv[0]);
    }

  parent = getpid();
  switch (child = fork()) {
    case -1:
      err(EXIT_FAILURE, "fork");
    case 0:
      raise(SIGSTOP);
      if (geteuid() != 0)
        denysetgroups(parent);
      writemap(parent, GID, gidmap);
      writemap(parent, UID, uidmap);
      exit(0);
  }

  if (setgid(getgid()) < 0 || setuid(getuid()) < 0)
    errx(EXIT_FAILURE, "Failed to drop privileges");
  prctl(PR_SET_DUMPABLE, 1);

  if (unshare(CLONE_NEWUSER) < 0)
    errx(EXIT_FAILURE, "Failed to unshare user namespace");

  waitforstop(child);
  kill(child, SIGCONT);
  waitforexit(child);

  setgid(0);
  setgroups(0, NULL);
  setuid(0);

  if (argv[optind])
    execvp(argv[optind], argv + optind);
  else if (getenv("SHELL"))
    execl(getenv("SHELL"), getenv("SHELL"), NULL);
  else
    execl(SHELL, SHELL, NULL);

  err(EXIT_FAILURE, "exec");
  return EXIT_FAILURE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
xorl %r14d, %r14d
leaq 0x1bee(%rip), %r12      # 0x4004
movq 0x3bbb(%rip), %r13      # 0x5fd8
xorl %r15d, %r15d
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2280
testl %eax, %eax
jle 0x2447
cmpl $0x67, %eax
jne 0x243c
movq (%r13), %r15
jmp 0x2420
cmpl $0x75, %eax
jne 0x2470
movq (%r13), %r14
jmp 0x2420
callq 0x20c0
movl %eax, %r12d
callq 0x22f0
testl %eax, %eax
je 0x2493
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x24ce
leaq 0x1ba5(%rip), %rsi      # 0x400b
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x21d0
movq (%rbx), %rdx
movq 0x3b7e(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1bda(%rip), %rsi      # 0x405e
xorl %eax, %eax
callq 0x2180
pushq $0x40
popq %rdi
callq 0x22b0
pushq $0x13
popq %rdi
callq 0x2040
callq 0x2130
testl %eax, %eax
je 0x24ac
movl %r12d, %edi
callq 0x25a8
movl %r12d, %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x260e
pushq $0x1
popq %rsi
movl %r12d, %edi
movq %r14, %rdx
callq 0x260e
xorl %edi, %edi
callq 0x22b0
callq 0x21c0
movl %eax, %edi
callq 0x2240
testl %eax, %eax
js 0x24ee
callq 0x2110
movl %eax, %edi
callq 0x22c0
testl %eax, %eax
jns 0x24ff
leaq 0x1b1b(%rip), %rsi      # 0x4010
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x2120
pushq $0x4
popq %rdi
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x21a0
movl $0x10000000, %edi       # imm = 0x10000000
callq 0x2090
testl %eax, %eax
jns 0x2523
leaq 0x1b09(%rip), %rsi      # 0x402a
jmp 0x24f5
movl %ebp, %edi
callq 0x3204
pushq $0x12
popq %rsi
movl %ebp, %edi
callq 0x21b0
movl %ebp, %edi
callq 0x31d2
xorl %edi, %edi
callq 0x2240
xorl %edi, %edi
xorl %esi, %esi
callq 0x2150
xorl %edi, %edi
callq 0x22c0
movq 0x3a77(%rip), %rax      # 0x5fd0
movslq (%rax), %rax
movq (%rbx,%rax,8), %rdi
testq %rdi, %rdi
jne 0x2582
leaq 0x1adf(%rip), %rdi      # 0x404b
callq 0x2030
testq %rax, %rax
jne 0x258d
leaq 0x1ad4(%rip), %rdi      # 0x4051
movq %rdi, %rsi
jmp 0x2593
leaq (%rbx,%rax,8), %rsi
callq 0x2290
jmp 0x259c
movq %rax, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22e0
leaq 0x1ab6(%rip), %rsi      # 0x4059
jmp 0x2466