#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  scalar_t__ st_uid;
};
struct passwd {
  char *pw_dir;
  scalar_t__ pw_uid;
};
struct dirent {
  char *d_name;
};
typedef int pid_t;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ dup(int);
int /*<<< orphan*/ execl(char *, char *, char *, ...);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ geteuid();
struct passwd *getpwnam(char const *);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ *stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strtoul(char *, char **, int);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (geteuid()) {
    fprintf(stderr, "%s: must be run as root\n", argv[0]);
    return 1;
  };
  int rmhome = 0;
  int kick = 0;
  const char *username = NULL;
  int i;
  for (i = 1; i < argc; i++) {
    if (argv[i][0] != '-') {
      if (username != NULL) {
        fprintf(stderr, "%s: only one user should be specified\n", argv[0]);
        return 1;
      };
      username = argv[i];
    } else if (argv[i][1] != '-') {
      const char *scan;
      for (scan = &argv[i][1]; *scan != 0; scan++) {
        switch (*scan) {
        case 'r':
          rmhome = 1;
          break;
        case 'k':
          kick = 1;
          break;
        default:
          fprintf(stderr, "%s: unrecognized command-line switch `-%c'\n",
                  argv[0], *scan);
          return 1;
        };
      };
    } else if (strcmp(argv[i], "--remove-home") == 0) {
      rmhome = 1;
    } else if (strcmp(argv[i], "--kick") == 0) {
      kick = 1;
    } else {
      fprintf(stderr, "%s: unrecognized command-line option `%s'\n", argv[0],
              argv[i]);
      return 1;
    };
  };
  if (username == NULL) {
    fprintf(stderr, "USAGE:\t%s [-r|--remove-home] [-k|--kick] <username>\n",
            argv[0]);
    fprintf(stderr, "\tDelete the user with the given username.\n\n");
    fprintf(stderr, "\t-r, --remove-home\n");
    fprintf(stderr,
            "\t\tDelete the user's home directory. If not passed, then\n");
    fprintf(
        stderr,
        "\t\tby default the directory's owner and group are set to root.\n\n");
    fprintf(stderr, "\t-k, --kick\n");
    fprintf(stderr, "\t\tKill all processes running for this user.\n");
    return 1;
  };
  fprintf(stderr, "Removing user account `%s'...\n", username);
  struct passwd *pwd = getpwnam(username);
  if (pwd == NULL) {
    fprintf(stderr, "User account not found.\n");
    return 1;
  };
  int pipefd[2];
  if (pipe(pipefd) != 0) {
    perror("pipe");
    return 1;
  };
  pid_t pid = fork();
  if (pid == -1) {
    perror("fork");
    return 1;
  } else if (pid == 0) {
    close(0);
    dup(pipefd[0]);
    close(pipefd[0]);
    close(pipefd[1]);
    execl("/usr/bin/userctl", "rmuser", NULL);
    perror("exec userctl");
    _exit(1);
  } else {
    FILE *cmdout = fdopen(pipefd[1], "w");
    close(pipefd[0]);
    fprintf(cmdout, "rmuser %s\n", username);
    fprintf(cmdout, "save\n");
    fclose(cmdout);
    int wstatus;
    waitpid(pid, &wstatus, 0);
    if (wstatus != 0) {
      return 1;
    };
  };
  if (rmhome) {
    fprintf(stderr, "Deleting home directory `%s'...\n", pwd->pw_dir);
    pid = fork();
    if (pid == -1) {
      perror("fork");
      return 1;
    } else if (pid == 0) {
      execl("/usr/bin/rm", "rm", "-r", pwd->pw_dir, NULL);
      _exit(1);
    } else {
      waitpid(pid, NULL, 0);
    };
  } else {
    fprintf(stderr, "Delegating home directory `%s' to root...\n", pwd->pw_dir);
    chown(pwd->pw_dir, 0, 0);
  };
  if (kick) {
    fprintf(stderr, "Kicking the user...\n");
    int gotAny;
    do {
      gotAny = 0;
      DIR *dirp = opendir("/proc");
      if (dirp == NULL) {
        perror("opendir /proc");
        return 1;
      };
      struct dirent *ent;
      while ((ent = readdir(dirp)) != NULL) {
        char *endptr;
        pid_t pid = (pid_t)strtoul(ent->d_name, &endptr, 10);
        if (*endptr == 0) {
          char path[256];
          sprintf(path, "/proc/%s", ent->d_name);
          struct stat st;
          if (stat(path, &st) == 0) {
            if (st.st_uid == pwd->pw_uid) {
              kill(pid, SIGKILL);
              gotAny = 1;
            };
          };
        };
      };
      closedir(dirp);
      sleep(1);
    } while (gotAny);
  };
  fprintf(stderr, "User deleted.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <geteuid@plt>
cmp    $0x0,%rax
je     12c5 <main+0x55>
mov    0x2d3f(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14d7 <main+0x267>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1351 <main+0xe1>
cmpq   $0x0,-0x20(%rbp)
je     133c <main+0xcc>
mov    0x2cc8(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcf0(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    14c4 <main+0x254>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
je     1422 <main+0x1b2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     141d <main+0x1ad>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18c(%rbp)
sub    $0x6b,%eax
je     13c9 <main+0x159>
jmp    13a9 <main+0x139>
mov    -0x18c(%rbp),%eax
sub    $0x72,%eax
jne    13d5 <main+0x165>
jmp    13bd <main+0x14d>
movl   $0x1,-0x14(%rbp)
jmp    1407 <main+0x197>
movl   $0x1,-0x18(%rbp)
jmp    1407 <main+0x197>
mov    0x2c04(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
lea    0xc4c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
jmp    140c <main+0x19c>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    137e <main+0x10e>
jmp    14bf <main+0x24f>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc37(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1450 <main+0x1e0>
movl   $0x1,-0x14(%rbp)
jmp    14ba <main+0x24a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc17(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    147e <main+0x20e>
movl   $0x1,-0x18(%rbp)
jmp    14b5 <main+0x245>
mov    0x2b5b(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xbdf(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
jmp    14ba <main+0x24a>
jmp    14bf <main+0x24f>
jmp    14c4 <main+0x254>
jmp    14c9 <main+0x259>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12e2 <main+0x72>
cmpq   $0x0,-0x20(%rbp)
jne    159d <main+0x32d>
mov    0x2af7(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xbb2(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2ad8(%rip),%rax
mov    (%rax),%rdi
lea    0xbcf(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2ac0(%rip),%rax
mov    (%rax),%rdi
lea    0xbe3(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2aa8(%rip),%rax
mov    (%rax),%rdi
lea    0xbdf(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2a90(%rip),%rax
mov    (%rax),%rdi
lea    0xc00(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2a78(%rip),%rax
mov    (%rax),%rdi
lea    0xc28(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2a60(%rip),%rax
mov    (%rax),%rdi
lea    0xc1d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
mov    0x2a3c(%rip),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc22(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <getpwnam@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    15f5 <main+0x385>
mov    0x2a08(%rip),%rax
mov    (%rax),%rdi
lea    0xc11(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
lea    -0x40(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
je     1620 <main+0x3b0>
lea    0xbfd(%rip),%rdi
call   1140 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    164c <main+0x3dc>
lea    0xbd6(%rip),%rdi
call   1140 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
cmpl   $0x0,-0x44(%rbp)
jne    16a4 <main+0x434>
xor    %edi,%edi
call   1080 <close@plt>
mov    -0x40(%rbp),%edi
call   1060 <dup@plt>
mov    -0x40(%rbp),%edi
call   1080 <close@plt>
mov    -0x3c(%rbp),%edi
call   1080 <close@plt>
lea    0xb9a(%rip),%rdi
lea    0xba4(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1170 <execl@plt>
lea    0xb99(%rip),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x3c(%rbp),%edi
lea    0xb8d(%rip),%rsi
call   1120 <fdopen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%edi
call   1080 <close@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xb6f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xb68(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x44(%rbp),%edi
lea    -0x54(%rbp),%rsi
xor    %edx,%edx
call   1130 <waitpid@plt>
cmpl   $0x0,-0x54(%rbp)
je     1714 <main+0x4a4>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
jmp    1719 <main+0x4a9>
jmp    171e <main+0x4ae>
cmpl   $0x0,-0x14(%rbp)
je     17c7 <main+0x557>
mov    0x28b1(%rip),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xb0e(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1773 <main+0x503>
lea    0xaaf(%rip),%rdi
call   1140 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
cmpl   $0x0,-0x44(%rbp)
jne    17af <main+0x53f>
mov    -0x38(%rbp),%rax
mov    (%rax),%rcx
lea    0xae4(%rip),%rdi
lea    0xae6(%rip),%rsi
lea    0xae2(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1170 <execl@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x44(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1130 <waitpid@plt>
jmp    17c2 <main+0x552>
jmp    17f6 <main+0x586>
mov    0x2812(%rip),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xa9f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1110 <chown@plt>
cmpl   $0x0,-0x18(%rbp)
je     192b <main+0x6bb>
mov    0x27d9(%rip),%rax
mov    (%rax),%rdi
lea    0xa98(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x0,-0x58(%rbp)
lea    0xaa0(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1852 <main+0x5e2>
lea    0xa7d(%rip),%rdi
call   1140 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    194a <main+0x6da>
jmp    1857 <main+0x5e7>
mov    -0x60(%rbp),%rdi
call   1100 <readdir@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
je     1909 <main+0x699>
mov    -0x68(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    $0xa,%edx
call   1150 <strtoul@plt>
mov    %eax,-0x74(%rbp)
mov    -0x70(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1904 <main+0x694>
lea    -0x180(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    (%rax),%rdx
lea    0xa21(%rip),%rsi
call   1160 <sprintf@plt>
lea    -0x180(%rbp),%rdi
lea    -0x188(%rbp),%rsi
call   10e0 <stat@plt>
cmp    $0x0,%rax
jne    18ff <main+0x68f>
mov    -0x188(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    18fa <main+0x68a>
mov    -0x74(%rbp),%edi
mov    0x26ec(%rip),%rax
mov    (%rax),%esi
call   10f0 <kill@plt>
movl   $0x1,-0x58(%rbp)
jmp    18ff <main+0x68f>
jmp    1904 <main+0x694>
jmp    1857 <main+0x5e7>
mov    -0x60(%rbp),%rdi
call   10a0 <closedir@plt>
mov    $0x1,%edi
call   1180 <sleep@plt>
cmpl   $0x0,-0x58(%rbp)
jne    1818 <main+0x5a8>
jmp    192b <main+0x6bb>
mov    0x26ae(%rip),%rax
mov    (%rax),%rdi
lea    0x999(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <geteuid@plt>
test   %rax,%rax
je     12c2 <main+0x42>
mov    0x2d37(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xd4a(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1587 <main+0x307>
cmp    $0x2,%ebp
jl     14cf <main+0x24f>
mov    %ebp,%r14d
xor    %ebp,%ebp
mov    $0x1,%r12d
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    12f9 <main+0x79>
xchg   %ax,%ax
test   %r15,%r15
mov    %rdi,%r15
jne    15a0 <main+0x320>
add    $0x1,%r12
cmp    %r14,%r12
je     13aa <main+0x12a>
mov    (%rbx,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
jne    12e0 <main+0x60>
mov    0x1(%rdi),%al
test   %al,%al
je     12ec <main+0x6c>
cmp    $0x2d,%al
jne    133e <main+0xbe>
lea    0xd58(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1380 <main+0x100>
mov    (%rbx,%r12,8),%rdi
lea    0xd51(%rip),%rsi
call   10b0 <strcmp@plt>
mov    $0x1,%r13d
test   %rax,%rax
je     12ec <main+0x6c>
jmp    15ca <main+0x34a>
add    $0x2,%rdi
jmp    135d <main+0xdd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rdi),%eax
add    $0x1,%rdi
mov    %edx,%ebp
test   %al,%al
je     1379 <main+0xf9>
movsbl %al,%ecx
mov    $0x1,%edx
cmp    $0x72,%ecx
je     1350 <main+0xd0>
cmp    $0x6b,%ecx
jne    138a <main+0x10a>
mov    $0x1,%r13d
mov    %ebp,%edx
jmp    1350 <main+0xd0>
mov    %edx,%ebp
jmp    12ec <main+0x6c>
mov    $0x1,%ebp
jmp    12ec <main+0x6c>
mov    0x2c4f(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xca2(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1587 <main+0x307>
test   %r15,%r15
je     14cf <main+0x24f>
mov    0x2c26(%rip),%rbx
mov    (%rbx),%rdi
lea    0xe10(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r15,%rdi
call   10c0 <getpwnam@plt>
test   %rax,%rax
je     15b9 <main+0x339>
mov    %rax,0x8(%rsp)
mov    %rsp,%rdi
call   1090 <pipe@plt>
test   %rax,%rax
jne    1730 <main+0x4b0>
xor    %eax,%eax
call   11a0 <fork@plt>
cmp    $0xffffffff,%eax
je     1739 <main+0x4b9>
mov    %eax,%r14d
test   %eax,%eax
je     1764 <main+0x4e4>
mov    0x4(%rsp),%edi
lea    0xe20(%rip),%rsi
call   1120 <fdopen@plt>
mov    %rax,%rbx
mov    (%rsp),%edi
call   1080 <close@plt>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
lea    0xe02(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1170 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0x20(%rsp),%rsi
mov    %r14d,%edi
xor    %edx,%edx
call   1130 <waitpid@plt>
cmpl   $0x0,0x20(%rsp)
mov    $0x1,%ebx
jne    158c <main+0x30c>
mov    0x2b5a(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%rsp),%r14
mov    (%r14),%rdx
test   %ebp,%ebp
je     15eb <main+0x36b>
lea    0xdae(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
xor    %eax,%eax
call   11a0 <fork@plt>
cmp    $0xffffffff,%eax
je     174a <main+0x4ca>
test   %eax,%eax
je     17b1 <main+0x531>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1130 <waitpid@plt>
jmp    1605 <main+0x385>
mov    0x2b0a(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    (%rbx),%rdx
lea    0xbc8(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x0(%rbp),%rcx
lea    0xbeb(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    0x0(%rbp),%rcx
lea    0xbfd(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    0x0(%rbp),%rcx
lea    0xbf7(%rip),%rdi
mov    $0x38,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    0x0(%rbp),%rcx
lea    0xc16(%rip),%rdi
mov    $0x3f,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    0x0(%rbp),%rcx
lea    0xc3c(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    0x0(%rbp),%rcx
lea    0xc2f(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a39(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xa65(%rip),%rsi
jmp    12b6 <main+0x36>
mov    (%rbx),%rcx
lea    0xc30(%rip),%rdi
mov    $0x18,%esi
jmp    157d <main+0x2fd>
mov    0x2a0f(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
mov    (%rbx,%r12,8),%rcx
lea    0xa9f(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1587 <main+0x307>
lea    0xc8c(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1110 <chown@plt>
test   %r13d,%r13d
je     1709 <main+0x489>
mov    0x29cb(%rip),%rax
mov    (%rax),%rcx
lea    0xc8a(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
lea    0x18(%rsp),%rbx
lea    0x20(%rsp),%r13
jmp    1656 <main+0x3d6>
xor    %ebp,%ebp
mov    %r15,%rdi
call   10a0 <closedir@plt>
mov    $0x1,%edi
call   1190 <sleep@plt>
test   %ebp,%ebp
je     1709 <main+0x489>
lea    0xc69(%rip),%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     175b <main+0x4db>
mov    %rax,%r15
mov    %rax,%rdi
call   1100 <readdir@plt>
test   %rax,%rax
je     163a <main+0x3ba>
mov    %rax,%r14
xor    %ebp,%ebp
jmp    16a0 <main+0x420>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1100 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     163c <main+0x3bc>
mov    (%r14),%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1150 <strtoul@plt>
mov    %eax,%r12d
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1690 <main+0x410>
mov    (%r14),%rdx
mov    %r13,%rdi
lea    0xc02(%rip),%rsi
call   1160 <sprintf@plt>
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   10e0 <stat@plt>
test   %rax,%rax
jne    1690 <main+0x410>
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
cmp    0x8(%rcx),%rax
jne    1690 <main+0x410>
mov    0x28e0(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
call   10f0 <kill@plt>
mov    $0x1,%ebp
jmp    1690 <main+0x410>
mov    0x28d0(%rip),%rax
mov    (%rax),%rcx
lea    0xbbb(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
call   1170 <fwrite@plt>
xor    %ebx,%ebx
jmp    158c <main+0x30c>
lea    0xad5(%rip),%rdi
jmp    1740 <main+0x4c0>
lea    0xad1(%rip),%rdi
call   1140 <perror@plt>
jmp    1587 <main+0x307>
lea    0xac0(%rip),%rdi
call   1140 <perror@plt>
jmp    158c <main+0x30c>
lea    0xb5c(%rip),%rdi
jmp    1740 <main+0x4c0>
xor    %edi,%edi
call   1080 <close@plt>
mov    (%rsp),%edi
call   1060 <dup@plt>
mov    (%rsp),%edi
call   1080 <close@plt>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
lea    0xa8b(%rip),%rdi
lea    0xa95(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1180 <execl@plt>
lea    0xa8c(%rip),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%rcx
lea    0xaaf(%rip),%rdi
lea    0xab1(%rip),%rsi
lea    0xaad(%rip),%rdx
xor    %r8d,%r8d
xor    %eax,%eax
call   1180 <execl@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8*, i64 }
%struct.dirent = type { i8* }
%struct.stat = type { i64 }
@stderr = global i32* null
@.str = [25 x i8] c"%s: must be run as root\0A\00"
@.str.1 = [39 x i8] c"%s: only one user should be specified\0A\00"
@.str.2 = [44 x i8] c"%s: unrecognized command-line switch `-%c'\0A\00"
@.str.3 = [14 x i8] c"--remove-home\00"
@.str.4 = [7 x i8] c"--kick\00"
@.str.5 = [43 x i8] c"%s: unrecognized command-line option `%s'\0A\00"
@.str.6 = [53 x i8] c"USAGE:\09%s [-r|--remove-home] [-k|--kick] <username>\0A\00"
@.str.7 = [44 x i8] c"\09Delete the user with the given username.\0A\0A\00"
@.str.8 = [20 x i8] c"\09-r, --remove-home\0A\00"
@.str.9 = [57 x i8] c"\09\09Delete the user's home directory. If not passed, then\0A\00"
@.str.10 = [64 x i8] c"\09\09by default the directory's owner and group are set to root.\0A\0A\00"
@.str.11 = [13 x i8] c"\09-k, --kick\0A\00"
@.str.12 = [45 x i8] c"\09\09Kill all processes running for this user.\0A\00"
@.str.13 = [31 x i8] c"Removing user account `%s'...\0A\00"
@.str.14 = [25 x i8] c"User account not found.\0A\00"
@.str.15 = [5 x i8] c"pipe\00"
@.str.16 = [5 x i8] c"fork\00"
@.str.17 = [17 x i8] c"/usr/bin/userctl\00"
@.str.18 = [7 x i8] c"rmuser\00"
@.str.19 = [13 x i8] c"exec userctl\00"
@.str.20 = [2 x i8] c"w\00"
@.str.21 = [11 x i8] c"rmuser %s\0A\00"
@.str.22 = [6 x i8] c"save\0A\00"
@.str.23 = [33 x i8] c"Deleting home directory `%s'...\0A\00"
@.str.24 = [12 x i8] c"/usr/bin/rm\00"
@.str.25 = [3 x i8] c"rm\00"
@.str.26 = [3 x i8] c"-r\00"
@.str.27 = [43 x i8] c"Delegating home directory `%s' to root...\0A\00"
@.str.28 = [21 x i8] c"Kicking the user...\0A\00"
@.str.29 = [6 x i8] c"/proc\00"
@.str.30 = [14 x i8] c"opendir /proc\00"
@.str.31 = [9 x i8] c"/proc/%s\00"
@SIGKILL = global i32 0
@.str.32 = [15 x i8] c"User deleted.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca %struct.passwd*
%12 = alloca [2 x i32]
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca %struct.dirent*
%19 = alloca i8*
%20 = alloca i32
%21 = alloca [256 x i8]
%22 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = call i64 (...) @geteuid()
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = load i32*, i32** @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %29)
store i32 1, i32* %3
br label %319
31: ; preds = %2
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
store i32 1, i32* %9
br label %32
32: ; preds = %136, %31
%33 = load i32, i32* %9
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %139
36: ; preds = %32
%37 = load i8**, i8*** %5
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 45
br i1 %45, label %46, label %61
46: ; preds = %36
%47 = load i8*, i8** %8
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = load i32*, i32** @stderr
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 0
%53 = load i8*, i8** %52
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %53)
store i32 1, i32* %3
br label %319
55: ; preds = %46
%56 = load i8**, i8*** %5
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
store i8* %60, i8** %8
br label %135
61: ; preds = %36
%62 = load i8**, i8*** %5
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 45
br i1 %70, label %71, label %103
71: ; preds = %61
%72 = load i8**, i8*** %5
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = getelementptr inbounds i8, i8* %76, i64 1
store i8* %77, i8** %10
br label %78
78: ; preds = %99, %71
%79 = load i8*, i8** %10
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %102
83: ; preds = %78
%84 = load i8*, i8** %10
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
switch i32 %86, label %89 [
i32 114, label %87
i32 107, label %88
]
87: ; preds = %83
store i32 1, i32* %6
br label %98
88: ; preds = %83
store i32 1, i32* %7
br label %98
89: ; preds = %83
%90 = load i32*, i32** @stderr
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 0
%93 = load i8*, i8** %92
%94 = load i8*, i8** %10
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %93, i32 %96)
store i32 1, i32* %3
br label %319
98: ; preds = %88, %87
br label %99
99: ; preds = %98
%100 = load i8*, i8** %10
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %10
br label %78
102: ; preds = %78
br label %134
103: ; preds = %61
%104 = load i8**, i8*** %5
%105 = load i32, i32* %9
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8*, i8** %104, i64 %106
%108 = load i8*, i8** %107
%109 = call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %103
store i32 1, i32* %6
br label %133
112: ; preds = %103
%113 = load i8**, i8*** %5
%114 = load i32, i32* %9
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %112
store i32 1, i32* %7
br label %132
121: ; preds = %112
%122 = load i32*, i32** @stderr
%123 = load i8**, i8*** %5
%124 = getelementptr inbounds i8*, i8** %123, i64 0
%125 = load i8*, i8** %124
%126 = load i8**, i8*** %5
%127 = load i32, i32* %9
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8*, i8** %126, i64 %128
%130 = load i8*, i8** %129
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %125, i8* %130)
store i32 1, i32* %3
br label %319
132: ; preds = %120
br label %133
133: ; preds = %132, %111
br label %134
134: ; preds = %133, %102
br label %135
135: ; preds = %134, %55
br label %136
136: ; preds = %135
%137 = load i32, i32* %9
%138 = add nsw i32 %137, 1
store i32 %138, i32* %9
br label %32
139: ; preds = %32
%140 = load i8*, i8** %8
%141 = icmp eq i8* %140, null
br i1 %141, label %142, label %160
142: ; preds = %139
%143 = load i32*, i32** @stderr
%144 = load i8**, i8*** %5
%145 = getelementptr inbounds i8*, i8** %144, i64 0
%146 = load i8*, i8** %145
%147 = call i32 (i32*, i8*, ...) @fprintf(i32* %143, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %146)
%148 = load i32*, i32** @stderr
%149 = call i32 (i32*, i8*, ...) @fprintf(i32* %148, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%150 = load i32*, i32** @stderr
%151 = call i32 (i32*, i8*, ...) @fprintf(i32* %150, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%152 = load i32*, i32** @stderr
%153 = call i32 (i32*, i8*, ...) @fprintf(i32* %152, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0))
%154 = load i32*, i32** @stderr
%155 = call i32 (i32*, i8*, ...) @fprintf(i32* %154, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0))
%156 = load i32*, i32** @stderr
%157 = call i32 (i32*, i8*, ...) @fprintf(i32* %156, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%158 = load i32*, i32** @stderr
%159 = call i32 (i32*, i8*, ...) @fprintf(i32* %158, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %3
br label %319
160: ; preds = %139
%161 = load i32*, i32** @stderr
%162 = load i8*, i8** %8
%163 = call i32 (i32*, i8*, ...) @fprintf(i32* %161, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i8* %162)
%164 = load i8*, i8** %8
%165 = call %struct.passwd* @getpwnam(i8* %164)
store %struct.passwd* %165, %struct.passwd** %11
%166 = load %struct.passwd*, %struct.passwd** %11
%167 = icmp eq %struct.passwd* %166, null
br i1 %167, label %168, label %171
168: ; preds = %160
%169 = load i32*, i32** @stderr
%170 = call i32 (i32*, i8*, ...) @fprintf(i32* %169, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %3
br label %319
171: ; preds = %160
%172 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%173 = call i64 @pipe(i32* %172)
%174 = icmp ne i64 %173, 0
br i1 %174, label %175, label %177
175: ; preds = %171
%176 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %3
br label %319
177: ; preds = %171
%178 = call i32 (...) @fork()
store i32 %178, i32* %13
%179 = load i32, i32* %13
%180 = icmp eq i32 %179, -1
br i1 %180, label %181, label %183
181: ; preds = %177
%182 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
store i32 1, i32* %3
br label %319
183: ; preds = %177
%184 = load i32, i32* %13
%185 = icmp eq i32 %184, 0
br i1 %185, label %186, label %200
186: ; preds = %183
%187 = call i32 @close(i32 0)
%188 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%189 = load i32, i32* %188
%190 = call i32 @dup(i32 %189)
%191 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%192 = load i32, i32* %191
%193 = call i32 @close(i32 %192)
%194 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%195 = load i32, i32* %194
%196 = call i32 @close(i32 %195)
%197 = call i32 (i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* null)
%198 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0))
%199 = call i32 @_exit(i32 1)
unreachable
200: ; preds = %183
%201 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%202 = load i32, i32* %201
%203 = call i32* @fdopen(i32 %202, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i64 0, i64 0))
store i32* %203, i32** %14
%204 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%205 = load i32, i32* %204
%206 = call i32 @close(i32 %205)
%207 = load i32*, i32** %14
%208 = load i8*, i8** %8
%209 = call i32 (i32*, i8*, ...) @fprintf(i32* %207, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0), i8* %208)
%210 = load i32*, i32** %14
%211 = call i32 (i32*, i8*, ...) @fprintf(i32* %210, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0))
%212 = load i32*, i32** %14
%213 = call i32 @fclose(i32* %212)
%214 = load i32, i32* %13
%215 = call i32 @waitpid(i32 %214, i32* %15, i32 0)
%216 = load i32, i32* %15
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %219
218: ; preds = %200
store i32 1, i32* %3
br label %319
219: ; preds = %200
br label %220
220: ; preds = %219
br label %221
221: ; preds = %220
%222 = load i32, i32* %6
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %249
224: ; preds = %221
%225 = load i32*, i32** @stderr
%226 = load %struct.passwd*, %struct.passwd** %11
%227 = getelementptr inbounds %struct.passwd, %struct.passwd* %226, i32 0, i32 0
%228 = load i8*, i8** %227
%229 = call i32 (i32*, i8*, ...) @fprintf(i32* %225, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.23, i64 0, i64 0), i8* %228)
%230 = call i32 (...) @fork()
store i32 %230, i32* %13
%231 = load i32, i32* %13
%232 = icmp eq i32 %231, -1
br i1 %232, label %233, label %235
233: ; preds = %224
%234 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
store i32 1, i32* %3
br label %319
235: ; preds = %224
%236 = load i32, i32* %13
%237 = icmp eq i32 %236, 0
br i1 %237, label %238, label %244
238: ; preds = %235
%239 = load %struct.passwd*, %struct.passwd** %11
%240 = getelementptr inbounds %struct.passwd, %struct.passwd* %239, i32 0, i32 0
%241 = load i8*, i8** %240
%242 = call i32 (i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0), i8* %241, i8* null)
%243 = call i32 @_exit(i32 1)
unreachable
244: ; preds = %235
%245 = load i32, i32* %13
%246 = call i32 @waitpid(i32 %245, i32* null, i32 0)
br label %247
247: ; preds = %244
br label %248
248: ; preds = %247
br label %259
249: ; preds = %221
%250 = load i32*, i32** @stderr
%251 = load %struct.passwd*, %struct.passwd** %11
%252 = getelementptr inbounds %struct.passwd, %struct.passwd* %251, i32 0, i32 0
%253 = load i8*, i8** %252
%254 = call i32 (i32*, i8*, ...) @fprintf(i32* %250, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.27, i64 0, i64 0), i8* %253)
%255 = load %struct.passwd*, %struct.passwd** %11
%256 = getelementptr inbounds %struct.passwd, %struct.passwd* %255, i32 0, i32 0
%257 = load i8*, i8** %256
%258 = call i32 @chown(i8* %257, i32 0, i32 0)
br label %259
259: ; preds = %249, %248
%260 = load i32, i32* %7
%261 = icmp ne i32 %260, 0
br i1 %261, label %262, label %316
262: ; preds = %259
%263 = load i32*, i32** @stderr
%264 = call i32 (i32*, i8*, ...) @fprintf(i32* %263, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.28, i64 0, i64 0))
br label %265
265: ; preds = %312, %262
store i32 0, i32* %16
%266 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.29, i64 0, i64 0))
store i32* %266, i32** %17
%267 = load i32*, i32** %17
%268 = icmp eq i32* %267, null
br i1 %268, label %269, label %271
269: ; preds = %265
%270 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.30, i64 0, i64 0))
store i32 1, i32* %3
br label %319
271: ; preds = %265
br label %272
272: ; preds = %307, %271
%273 = load i32*, i32** %17
%274 = call %struct.dirent* @readdir(i32* %273)
store %struct.dirent* %274, %struct.dirent** %18
%275 = icmp ne %struct.dirent* %274, null
br i1 %275, label %276, label %308
276: ; preds = %272
%277 = load %struct.dirent*, %struct.dirent** %18
%278 = getelementptr inbounds %struct.dirent, %struct.dirent* %277, i32 0, i32 0
%279 = load i8*, i8** %278
%280 = call i32 @strtoul(i8* %279, i8** %19, i32 10)
store i32 %280, i32* %20
%281 = load i8*, i8** %19
%282 = load i8, i8* %281
%283 = sext i8 %282 to i32
%284 = icmp eq i32 %283, 0
br i1 %284, label %285, label %307
285: ; preds = %276
%286 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%287 = load %struct.dirent*, %struct.dirent** %18
%288 = getelementptr inbounds %struct.dirent, %struct.dirent* %287, i32 0, i32 0
%289 = load i8*, i8** %288
%290 = call i32 @sprintf(i8* %286, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.31, i64 0, i64 0), i8* %289)
%291 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%292 = call i64 @stat(i8* %291, %struct.stat* %22)
%293 = icmp eq i64 %292, 0
br i1 %293, label %294, label %306
294: ; preds = %285
%295 = getelementptr inbounds %struct.stat, %struct.stat* %22, i32 0, i32 0
%296 = load i64, i64* %295
%297 = load %struct.passwd*, %struct.passwd** %11
%298 = getelementptr inbounds %struct.passwd, %struct.passwd* %297, i32 0, i32 1
%299 = load i64, i64* %298
%300 = icmp eq i64 %296, %299
br i1 %300, label %301, label %305
301: ; preds = %294
%302 = load i32, i32* %20
%303 = load i32, i32* @SIGKILL
%304 = call i32 @kill(i32 %302, i32 %303)
store i32 1, i32* %16
br label %305
305: ; preds = %301, %294
br label %306
306: ; preds = %305, %285
br label %307
307: ; preds = %306, %276
br label %272
308: ; preds = %272
%309 = load i32*, i32** %17
%310 = call i32 @closedir(i32* %309)
%311 = call i32 @sleep(i32 1)
br label %312
312: ; preds = %308
%313 = load i32, i32* %16
%314 = icmp ne i32 %313, 0
br i1 %314, label %265, label %315
315: ; preds = %312
br label %316
316: ; preds = %315, %259
%317 = load i32*, i32** @stderr
%318 = call i32 (i32*, i8*, ...) @fprintf(i32* %317, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.32, i64 0, i64 0))
store i32 0, i32* %3
br label %319
319: ; preds = %316, %269, %233, %218, %181, %175, %168, %142, %121, %89, %49, %25
%320 = load i32, i32* %3
ret i32 %320
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.passwd = type { i8*, i64 }
%struct.dirent = type { i8* }
@stderr = global i32* null
@.str = [25 x i8] c"%s: must be run as root\0A\00"
@.str.1 = [39 x i8] c"%s: only one user should be specified\0A\00"
@.str.2 = [44 x i8] c"%s: unrecognized command-line switch `-%c'\0A\00"
@.str.3 = [14 x i8] c"--remove-home\00"
@.str.4 = [7 x i8] c"--kick\00"
@.str.5 = [43 x i8] c"%s: unrecognized command-line option `%s'\0A\00"
@.str.6 = [53 x i8] c"USAGE:\09%s [-r|--remove-home] [-k|--kick] <username>\0A\00"
@.str.7 = [44 x i8] c"\09Delete the user with the given username.\0A\0A\00"
@.str.8 = [20 x i8] c"\09-r, --remove-home\0A\00"
@.str.9 = [57 x i8] c"\09\09Delete the user's home directory. If not passed, then\0A\00"
@.str.10 = [64 x i8] c"\09\09by default the directory's owner and group are set to root.\0A\0A\00"
@.str.11 = [13 x i8] c"\09-k, --kick\0A\00"
@.str.12 = [45 x i8] c"\09\09Kill all processes running for this user.\0A\00"
@.str.13 = [31 x i8] c"Removing user account `%s'...\0A\00"
@.str.14 = [25 x i8] c"User account not found.\0A\00"
@.str.15 = [5 x i8] c"pipe\00"
@.str.16 = [5 x i8] c"fork\00"
@.str.17 = [17 x i8] c"/usr/bin/userctl\00"
@.str.18 = [7 x i8] c"rmuser\00"
@.str.19 = [13 x i8] c"exec userctl\00"
@.str.20 = [2 x i8] c"w\00"
@.str.21 = [11 x i8] c"rmuser %s\0A\00"
@.str.22 = [6 x i8] c"save\0A\00"
@.str.23 = [33 x i8] c"Deleting home directory `%s'...\0A\00"
@.str.24 = [12 x i8] c"/usr/bin/rm\00"
@.str.25 = [3 x i8] c"rm\00"
@.str.26 = [3 x i8] c"-r\00"
@.str.27 = [43 x i8] c"Delegating home directory `%s' to root...\0A\00"
@.str.28 = [21 x i8] c"Kicking the user...\0A\00"
@.str.29 = [6 x i8] c"/proc\00"
@.str.30 = [14 x i8] c"opendir /proc\00"
@.str.31 = [9 x i8] c"/proc/%s\00"
@SIGKILL = global i32 0
@.str.32 = [15 x i8] c"User deleted.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca %struct.stat
%8 = tail call i64 (...) @geteuid()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = icmp sgt i32 %0, 1
br i1 %11, label %12, label %73
12: ; preds = %10
%13 = zext i32 %0 to i64
br label %18
14: ; preds = %2
%15 = load i32*, i32** @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %208
18: ; preds = %12, %65
%19 = phi i64 [ 1, %12 ], [ %69, %65 ]
%20 = phi i32 [ 0, %12 ], [ %68, %65 ]
%21 = phi i32 [ 0, %12 ], [ %67, %65 ]
%22 = phi i8* [ null, %12 ], [ %66, %65 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %19
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 45
br i1 %26, label %33, label %27
27: ; preds = %18
%28 = icmp eq i8* %22, null
br i1 %28, label %65, label %29
29: ; preds = %27
%30 = load i32*, i32** @stderr
%31 = load i8*, i8** %1
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %208
33: ; preds = %18
%34 = getelementptr inbounds i8, i8* %24, i64 1
%35 = load i8, i8* %34
switch i8 %35, label %36 [
i8 45, label %53
i8 0, label %65
]
36: ; preds = %33, %43
%37 = phi i8 [ %47, %43 ], [ %35, %33 ]
%38 = phi i32 [ %45, %43 ], [ %20, %33 ]
%39 = phi i32 [ %44, %43 ], [ %21, %33 ]
%40 = phi i8* [ %46, %43 ], [ %34, %33 ]
%41 = sext i8 %37 to i32
switch i32 %41, label %49 [
i32 114, label %43
i32 107, label %42
]
42: ; preds = %36
br label %43
43: ; preds = %36, %42
%44 = phi i32 [ 1, %42 ], [ %39, %36 ]
%45 = phi i32 [ %38, %42 ], [ 1, %36 ]
%46 = getelementptr inbounds i8, i8* %40, i64 1
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %65, label %36
49: ; preds = %36
%50 = load i32*, i32** @stderr
%51 = load i8*, i8** %1
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %51, i32 %41)
br label %208
53: ; preds = %33
%54 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %65, label %56
56: ; preds = %53
%57 = load i8*, i8** %23
%58 = tail call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %56
%61 = load i32*, i32** @stderr
%62 = load i8*, i8** %1
%63 = load i8*, i8** %23
%64 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %62, i8* %63)
br label %208
65: ; preds = %43, %33, %56, %53, %27
%66 = phi i8* [ %24, %27 ], [ %22, %53 ], [ %22, %56 ], [ %22, %33 ], [ %22, %43 ]
%67 = phi i32 [ %21, %27 ], [ %21, %53 ], [ 1, %56 ], [ %21, %33 ], [ %44, %43 ]
%68 = phi i32 [ %20, %27 ], [ 1, %53 ], [ %20, %56 ], [ %20, %33 ], [ %45, %43 ]
%69 = add nuw nsw i64 %19, 1
%70 = icmp eq i64 %69, %13
br i1 %70, label %71, label %18
71: ; preds = %65
%72 = icmp eq i8* %66, null
br i1 %72, label %73, label %89
73: ; preds = %10, %71
%74 = load i32*, i32** @stderr
%75 = load i8*, i8** %1
%76 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %75)
%77 = load i32*, i32** @stderr
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i64 43, i64 1, i32* %77)
%79 = load i32*, i32** @stderr
%80 = tail call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i64 19, i64 1, i32* %79)
%81 = load i32*, i32** @stderr
%82 = tail call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0), i64 56, i64 1, i32* %81)
%83 = load i32*, i32** @stderr
%84 = tail call i64 @fwrite(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0), i64 63, i64 1, i32* %83)
%85 = load i32*, i32** @stderr
%86 = tail call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i64 12, i64 1, i32* %85)
%87 = load i32*, i32** @stderr
%88 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i64 44, i64 1, i32* %87)
br label %208
89: ; preds = %71
%90 = load i32*, i32** @stderr
%91 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i8* %66)
%92 = tail call %struct.passwd* @getpwnam(i8* %66)
%93 = icmp eq %struct.passwd* %92, null
br i1 %93, label %94, label %97
94: ; preds = %89
%95 = load i32*, i32** @stderr
%96 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i64 24, i64 1, i32* %95)
br label %208
97: ; preds = %89
%98 = bitcast [2 x i32]* %3 to i8*
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%100 = call i64 @pipe(i32* %99)
%101 = icmp eq i64 %100, 0
br i1 %101, label %104, label %102
102: ; preds = %97
%103 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
br label %206
104: ; preds = %97
%105 = call i32 (...) @fork()
switch i32 %105, label %120 [
i32 -1, label %106
i32 0, label %108
]
106: ; preds = %104
%107 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
br label %206
108: ; preds = %104
%109 = call i32 @close(i32 0)
%110 = load i32, i32* %99
%111 = call i32 @dup(i32 %110)
%112 = load i32, i32* %99
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
%117 = call i32 (i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* null)
%118 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0))
%119 = call i32 @_exit(i32 1)
unreachable
120: ; preds = %104
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%122 = load i32, i32* %121
%123 = call i32* @fdopen(i32 %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i64 0, i64 0))
%124 = load i32, i32* %99
%125 = call i32 @close(i32 %124)
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0), i8* %66)
%127 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i64 5, i64 1, i32* %123)
%128 = call i32 @fclose(i32* %123)
%129 = bitcast i32* %4 to i8*
%130 = call i32 @waitpid(i32 %105, i32* %4, i32 0)
%131 = load i32, i32* %4
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %206
133: ; preds = %120
%134 = icmp eq i32 %68, 0
%135 = load i32*, i32** @stderr
%136 = getelementptr inbounds %struct.passwd, %struct.passwd* %92, i64 0, i32 0
%137 = load i8*, i8** %136
br i1 %134, label %149, label %138
138: ; preds = %133
%139 = call i32 (i32*, i8*, ...) @fprintf(i32* %135, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.23, i64 0, i64 0), i8* %137)
%140 = call i32 (...) @fork()
switch i32 %140, label %147 [
i32 -1, label %141
i32 0, label %143
]
141: ; preds = %138
%142 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
br label %206
143: ; preds = %138
%144 = load i8*, i8** %136
%145 = call i32 (i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0), i8* %144, i8* null)
%146 = call i32 @_exit(i32 1)
unreachable
147: ; preds = %138
%148 = call i32 @waitpid(i32 %140, i32* null, i32 0)
br label %153
149: ; preds = %133
%150 = call i32 (i32*, i8*, ...) @fprintf(i32* %135, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.27, i64 0, i64 0), i8* %137)
%151 = load i8*, i8** %136
%152 = call i32 @chown(i8* %151, i32 0, i32 0)
br label %153
153: ; preds = %149, %147
%154 = icmp eq i32 %67, 0
br i1 %154, label %203, label %155
155: ; preds = %153
%156 = load i32*, i32** @stderr
%157 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.28, i64 0, i64 0), i64 20, i64 1, i32* %156)
%158 = bitcast i8** %5 to i8*
%159 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%160 = bitcast %struct.stat* %7 to i8*
%161 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%162 = getelementptr inbounds %struct.passwd, %struct.passwd* %92, i64 0, i32 1
br label %163
163: ; preds = %198, %155
%164 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.29, i64 0, i64 0))
%165 = icmp eq i32* %164, null
br i1 %165, label %169, label %166
166: ; preds = %163
%167 = call %struct.dirent* @readdir(i32* %164)
%168 = icmp eq %struct.dirent* %167, null
br i1 %168, label %198, label %171
169: ; preds = %163
%170 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.30, i64 0, i64 0))
br label %206
171: ; preds = %166, %194
%172 = phi %struct.dirent* [ %196, %194 ], [ %167, %166 ]
%173 = phi i32 [ %195, %194 ], [ 0, %166 ]
%174 = getelementptr inbounds %struct.dirent, %struct.dirent* %172, i64 0, i32 0
%175 = load i8*, i8** %174
%176 = call i32 @strtoul(i8* %175, i8** %5, i32 10)
%177 = load i8*, i8** %5
%178 = load i8, i8* %177
%179 = icmp eq i8 %178, 0
br i1 %179, label %180, label %194
180: ; preds = %171
%181 = load i8*, i8** %174
%182 = call i32 @sprintf(i8* %159, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.31, i64 0, i64 0), i8* %181)
%183 = call i64 @stat(i8* %159, %struct.stat* %7)
%184 = icmp eq i64 %183, 0
br i1 %184, label %185, label %192
185: ; preds = %180
%186 = load i64, i64* %161
%187 = load i64, i64* %162
%188 = icmp eq i64 %186, %187
br i1 %188, label %189, label %192
189: ; preds = %185
%190 = load i32, i32* @SIGKILL
%191 = call i32 @kill(i32 %176, i32 %190)
br label %192
192: ; preds = %185, %189, %180
%193 = phi i32 [ 1, %189 ], [ %173, %185 ], [ %173, %180 ]
br label %194
194: ; preds = %192, %171
%195 = phi i32 [ %193, %192 ], [ %173, %171 ]
%196 = call %struct.dirent* @readdir(i32* %164)
%197 = icmp eq %struct.dirent* %196, null
br i1 %197, label %198, label %171
198: ; preds = %194, %166
%199 = phi i32 [ 0, %166 ], [ %195, %194 ]
%200 = call i32 @closedir(i32* %164)
%201 = call i32 @sleep(i32 1)
%202 = icmp eq i32 %199, 0
br i1 %202, label %203, label %163
203: ; preds = %198, %153
%204 = load i32*, i32** @stderr
%205 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.32, i64 0, i64 0), i64 14, i64 1, i32* %204)
br label %206
206: ; preds = %169, %106, %141, %203, %120, %102
%207 = phi i32 [ 1, %102 ], [ 1, %106 ], [ 1, %141 ], [ 0, %203 ], [ 1, %120 ], [ 1, %169 ]
br label %208
208: ; preds = %49, %29, %60, %73, %206, %94, %14
%209 = phi i32 [ 1, %14 ], [ 1, %29 ], [ 1, %49 ], [ 1, %60 ], [ 1, %73 ], [ 1, %94 ], [ %207, %206 ]
ret i32 %209
}