// File: /workspace/github_c_makefile_star2_O1/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 0x1be1(%rip), %rdx      # 0x4004
callq 0x2290
testl %eax, %eax
jle 0x246b
xorl %r15d, %r15d
movq 0x3ba2(%rip), %r13      # 0x5fd8
leaq 0x1bc7(%rip), %r12      # 0x4004
xorl %r14d, %r14d
cmpl $0x75, %eax
je 0x2454
cmpl $0x67, %eax
jne 0x250e
movq (%r13), %r15
jmp 0x2458
movq (%r13), %r14
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2290
testl %eax, %eax
jg 0x2440
jmp 0x2471
xorl %r14d, %r14d
xorl %r15d, %r15d
callq 0x20c0
movl %eax, %r12d
callq 0x2300
testl %eax, %eax
je 0x249c
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x24db
leaq 0x1b7b(%rip), %rsi      # 0x400b
movl $0x1, %edi
xorl %eax, %eax
callq 0x21e0
movl $0x13, %edi
callq 0x2040
callq 0x2130
testl %eax, %eax
je 0x24b7
movl %r12d, %edi
callq 0x25e4
movl %r12d, %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2650
movl %r12d, %edi
movl $0x1, %esi
movq %r14, %rdx
callq 0x2650
xorl %edi, %edi
callq 0x22c0
callq 0x21d0
movl %eax, %edi
callq 0x2250
testl %eax, %eax
js 0x24fb
callq 0x2110
movl %eax, %edi
callq 0x22d0
testl %eax, %eax
jns 0x2533
leaq 0x1b0e(%rip), %rsi      # 0x4010
movl $0x1, %edi
xorl %eax, %eax
callq 0x2120
movq (%rbx), %rdx
movq 0x3ae0(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1b3c(%rip), %rsi      # 0x405e
xorl %eax, %eax
callq 0x2190
movl $0x40, %edi
callq 0x22c0
movl $0x4, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0x21b0
movl $0x10000000, %edi       # imm = 0x10000000
callq 0x2090
testl %eax, %eax
jns 0x255b
leaq 0x1ad1(%rip), %rsi      # 0x402a
jmp 0x2502
movl %ebp, %edi
callq 0x33d7
movl %ebp, %edi
movl $0x12, %esi
callq 0x21c0
movl %ebp, %edi
callq 0x33a3
xorl %edi, %edi
callq 0x2250
xorl %edi, %edi
xorl %esi, %esi
callq 0x2150
xorl %edi, %edi
callq 0x22d0
movq 0x3a3d(%rip), %rax      # 0x5fd0
movslq (%rax), %rax
movq (%rbx,%rax,8), %rdi
testq %rdi, %rdi
jne 0x25bc
leaq 0x1aa5(%rip), %rdi      # 0x404b
callq 0x2030
testq %rax, %rax
jne 0x25c7
leaq 0x1a9a(%rip), %rdi      # 0x4051
movq %rdi, %rsi
jmp 0x25cd
leaq (%rbx,%rax,8), %rsi
callq 0x22a0
jmp 0x25d6
movq %rax, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22f0
leaq 0x1a7c(%rip), %rsi      # 0x4059
jmp 0x2490
nop