// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1bc0(%rip), %rdx      # 0x4004
callq 0x2290
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jle 0x2496
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
subl $0x67, %eax
je 0x2468
jmp 0x245e
movl -0x30(%rbp), %eax
subl $0x75, %eax
je 0x2478
jmp 0x2488
movq 0x3b69(%rip), %rax      # 0x5fd8
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x2494
movq 0x3b59(%rip), %rax      # 0x5fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2494
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2660
jmp 0x2436
callq 0x20c0
movl %eax, -0x2c(%rbp)
callq 0x2300
movl %eax, -0x28(%rbp)
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
subl $-0x1, %eax
je 0x24bb
jmp 0x24b2
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x24ce
jmp 0x2510
movl $0x1, %edi
leaq 0x1b44(%rip), %rsi      # 0x400b
movb $0x0, %al
callq 0x21e0
movl $0x13, %edi
callq 0x2040
callq 0x2140
cmpl $0x0, %eax
je 0x24ea
movl -0x2c(%rbp), %edi
callq 0x26a0
movl -0x2c(%rbp), %edi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
callq 0x2770
movl -0x2c(%rbp), %edi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
callq 0x2770
xorl %edi, %edi
callq 0x22c0
callq 0x21d0
movl %eax, %edi
callq 0x2250
cmpl $0x0, %eax
jl 0x2532
callq 0x2110
movl %eax, %edi
callq 0x22d0
cmpl $0x0, %eax
jge 0x2545
movl $0x1, %edi
leaq 0x1ad2(%rip), %rsi      # 0x4010
movb $0x0, %al
callq 0x2120
movl $0x4, %edi
movl $0x1, %esi
movb $0x0, %al
callq 0x21b0
movl $0x10000000, %edi       # imm = 0x10000000
callq 0x2090
cmpl $0x0, %eax
jge 0x2578
movl $0x1, %edi
leaq 0x1ab9(%rip), %rsi      # 0x402a
movb $0x0, %al
callq 0x2120
movl -0x28(%rbp), %edi
callq 0x36f0
movl -0x28(%rbp), %edi
movl $0x12, %esi
callq 0x21c0
movl -0x28(%rbp), %edi
callq 0x3690
xorl %edi, %edi
callq 0x2250
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x2160
xorl %edi, %edi
callq 0x22d0
movq -0x10(%rbp), %rax
movq 0x3a16(%rip), %rcx      # 0x5fd0
movslq (%rcx), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x25f2
movq -0x10(%rbp), %rax
movq 0x3a01(%rip), %rcx      # 0x5fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movq 0x39ef(%rip), %rax      # 0x5fd0
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x22a0
jmp 0x264b
leaq 0x1a52(%rip), %rdi      # 0x404b
callq 0x2030
cmpq $0x0, %rax
je 0x2634
leaq 0x1a40(%rip), %rdi      # 0x404b
callq 0x2030
movq %rax, -0x40(%rbp)
leaq 0x1a30(%rip), %rdi      # 0x404b
callq 0x2030
movq -0x40(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x22f0
jmp 0x2649
leaq 0x1a16(%rip), %rsi      # 0x4051
xorl %eax, %eax
movl %eax, %edx
movq %rsi, %rdi
movb $0x0, %al
callq 0x22f0
jmp 0x264b
movl $0x1, %edi
leaq 0x1a02(%rip), %rsi      # 0x4059
movb $0x0, %al
callq 0x21e0
nop