// File: /workspace/github_c_makefile_star2_O3/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
leaq 0x1bf1(%rip), %rdx      # 0x4004
callq 0x2280
testl %eax, %eax
jle 0x245b
xorl %r15d, %r15d
movq 0x3bb2(%rip), %r13      # 0x5fd8
leaq 0x1bd7(%rip), %r12      # 0x4004
xorl %r14d, %r14d
cmpl $0x75, %eax
je 0x2444
cmpl $0x67, %eax
jne 0x24fe
movq (%r13), %r15
jmp 0x2448
movq (%r13), %r14
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2280
testl %eax, %eax
jg 0x2430
jmp 0x2461
xorl %r14d, %r14d
xorl %r15d, %r15d
callq 0x20c0
movl %eax, %r12d
callq 0x22f0
testl %eax, %eax
je 0x248c
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x24cb
leaq 0x1b8b(%rip), %rsi      # 0x400b
movl $0x1, %edi
xorl %eax, %eax
callq 0x21d0
movl $0x13, %edi
callq 0x2040
callq 0x2130
testl %eax, %eax
je 0x24a7
movl %r12d, %edi
callq 0x25d4
movl %r12d, %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2640
movl %r12d, %edi
movl $0x1, %esi
movq %r14, %rdx
callq 0x2640
xorl %edi, %edi
callq 0x22b0
callq 0x21c0
movl %eax, %edi
callq 0x2240
testl %eax, %eax
js 0x24eb
callq 0x2110
movl %eax, %edi
callq 0x22c0
testl %eax, %eax
jns 0x2523
leaq 0x1b1e(%rip), %rsi      # 0x4010
movl $0x1, %edi
xorl %eax, %eax
callq 0x2120
movq (%rbx), %rdx
movq 0x3af0(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1b4c(%rip), %rsi      # 0x405e
xorl %eax, %eax
callq 0x2180
movl $0x40, %edi
callq 0x22b0
movl $0x4, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0x21a0
movl $0x10000000, %edi       # imm = 0x10000000
callq 0x2090
testl %eax, %eax
jns 0x254b
leaq 0x1ae1(%rip), %rsi      # 0x402a
jmp 0x24f2
movl %ebp, %edi
callq 0x336f
movl %ebp, %edi
movl $0x12, %esi
callq 0x21b0
movl %ebp, %edi
callq 0x333b
xorl %edi, %edi
callq 0x2240
xorl %edi, %edi
xorl %esi, %esi
callq 0x2150
xorl %edi, %edi
callq 0x22c0
movq 0x3a4d(%rip), %rax      # 0x5fd0
movslq (%rax), %rax
movq (%rbx,%rax,8), %rdi
testq %rdi, %rdi
jne 0x25ac
leaq 0x1ab5(%rip), %rdi      # 0x404b
callq 0x2030
testq %rax, %rax
jne 0x25b7
leaq 0x1aaa(%rip), %rdi      # 0x4051
movq %rdi, %rsi
jmp 0x25bd
leaq (%rbx,%rax,8), %rsi
callq 0x2290
jmp 0x25c6
movq %rax, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22e0
leaq 0x1a8c(%rip), %rsi      # 0x4059
jmp 0x2480
nop