#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 {
  int st_mode;
  int st_rdev;
};

/* Variables and functions */
int O_CREAT;
int O_RDONLY;
#define S_IFBLK 132
#define S_IFCHR 131
int S_IFDIR;
#define S_IFIFO 130
int S_IFMT;
#define S_IFREG 129
#define S_IFSOCK 128
int /*<<< orphan*/ S_ISDIR(int);
int /*<<< orphan*/ S_ISREG(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ getuid();
int mkdir(char *, int);
int mknod(char *, int, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int rmdir(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int unlink(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  char name[4096];
  int i;
  if (argc != 2)
    usage(argv[0]);
  umask(0);
  for (i = 0; i <= S_IFMT; i += (1 << 12)) {
    struct stat st;
    int mode = i | 0644;
    int rc;
    sprintf(name, "%s-mknod%07o", argv[1], mode);
    rc = mknod(name, mode, 0x1234);
    switch (i) {
    case 0:
      mode |= S_IFREG;
    case S_IFREG:
    case S_IFCHR:
    case S_IFBLK:
      if (rc < 0 && getuid() != 0)
        continue;
    case S_IFSOCK:
    case S_IFIFO:
      if (rc < 0) {
        fprintf(stderr, "%s: ERROR mknod %s: %s\n", argv[0], name,
                strerror(errno));
        exit(10);
      }
      rc = stat(name, &st);
      if (rc < 0) {
        fprintf(stderr, "%s: ERROR stat %s: %s", argv[0], name,
                strerror(errno));
        exit(11);
      }
      if (st.st_mode != mode) {
        fprintf(stderr, "%s: ERROR mode %s: %o != %o", argv[0], name,
                st.st_mode, mode);
        exit(12);
      }
      if (i == S_IFCHR || i == S_IFBLK) {
        if (st.st_rdev != 0x1234) {
          fprintf(stderr,
                  "%s: ERROR rdev %s: "
                  "%llu != 0x1234",
                  argv[0], name, (unsigned long long)st.st_rdev);
          exit(13);
        }
      }
      rc = unlink(name);
      if (rc < 0) {
        fprintf(stderr, "%s: ERROR unlink %s: %s", argv[0], name,
                strerror(errno));
        exit(14);
      }
      break;
    default:
      if (rc == 0) {
        fprintf(stderr, "%s: ERROR: %s created\n", argv[0], name);
        exit(15);
      }
    }
  }
  for (i = 0; i <= S_IFMT; i += (1 << 12)) {
    struct stat st;
    int mode;
    int fd;
    int rc;
    mode = i | 0644;
    sprintf(name, "%s-creat%07o", argv[1], mode);
    fd = open(name, O_CREAT | O_RDONLY, mode);
    if (fd < 0) {
      fprintf(stderr, "%s: ERROR creat %s: %s\n", argv[0], name,
              strerror(errno));
      exit(21);
    }
    close(fd);
    rc = stat(name, &st);
    if (rc < 0) {
      fprintf(stderr, "%s: ERROR stat %s: %s", argv[0], name, strerror(errno));
      exit(11);
    }
    if (!S_ISREG(st.st_mode & S_IFMT)) {
      fprintf(stderr, "%s: ERROR mode %s: %o != %o", argv[0], name,
              st.st_mode & S_IFMT, S_IFREG);
      exit(12);
    }
    rc = unlink(name);
    if (rc < 0) {
      fprintf(stderr, "%s: ERROR unlink %s: %s\n", argv[0], name,
              strerror(errno));
      exit(20);
    }
  }
  for (i = 0; i <= S_IFMT; i += (1 << 12)) {
    struct stat st;
    int rc;
    sprintf(name, "%s-mkdir%06o", argv[1], i | 0644);
    rc = mkdir(name, i | 0664);
    if (rc < 0) {
      fprintf(stderr, "%s: ERROR mkdir %s: %s\n", argv[0], name,
              strerror(errno));
      exit(30);
    }
    rc = stat(name, &st);
    if (rc < 0) {
      fprintf(stderr, "%s: ERROR stat %s: %s", argv[0], name, strerror(errno));
      exit(11);
    }
    if (!S_ISDIR(st.st_mode)) {
      fprintf(stderr, "%s: ERROR mode %s: %o != %o", argv[0], name,
              st.st_mode & S_IFMT, S_IFDIR);
      exit(12);
    }
    rc = rmdir(name);
    if (rc < 0) {
      fprintf(stderr, "%s: ERROR rmdir %s: %s\n", argv[0], name,
              strerror(errno));
      exit(31);
    }
  }
  printf("%s: SUCCESS\n", argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     123f <main+0x2f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <usage@plt>
xor    %edi,%edi
call   10b0 <umask@plt>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x2d73(%rip),%rcx
cmp    (%rcx),%eax
jg     160c <main+0x3fc>
mov    -0x1014(%rbp),%eax
or     $0x1a4,%eax
mov    %eax,-0x1024(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x1024(%rbp),%ecx
lea    0xd75(%rip),%rsi
lea    -0x1010(%rbp),%rdi
mov    %rdi,-0x1058(%rbp)
call   1110 <sprintf@plt>
mov    -0x1058(%rbp),%rdi
mov    -0x1024(%rbp),%esi
mov    $0x1234,%edx
call   10d0 <mknod@plt>
mov    %eax,-0x1028(%rbp)
mov    -0x1014(%rbp),%eax
mov    %eax,-0x1050(%rbp)
test   %eax,%eax
je     132f <main+0x11f>
jmp    12d4 <main+0xc4>
mov    -0x1050(%rbp),%eax
sub    $0x80,%eax
je     1367 <main+0x157>
jmp    12ea <main+0xda>
mov    -0x1050(%rbp),%eax
sub    $0x81,%eax
je     1340 <main+0x130>
jmp    1300 <main+0xf0>
mov    -0x1050(%rbp),%eax
sub    $0x82,%eax
je     1367 <main+0x157>
jmp    1316 <main+0x106>
mov    -0x1050(%rbp),%eax
add    $0xffffff7d,%eax
sub    $0x2,%eax
jb     1340 <main+0x130>
jmp    15b0 <main+0x3a0>
mov    -0x1024(%rbp),%eax
or     $0x81,%eax
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    1362 <main+0x152>
mov    $0x0,%al
call   1060 <getuid@plt>
cmp    $0x0,%eax
je     1362 <main+0x152>
jmp    15f6 <main+0x3e6>
jmp    1367 <main+0x157>
cmpl   $0x0,-0x1028(%rbp)
jge    13dc <main+0x1cc>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x106c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1068(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1060(%rbp)
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x106c(%rbp),%edi
mov    -0x1068(%rbp),%rdx
mov    -0x1060(%rbp),%rcx
mov    %rax,%r8
lea    0xc42(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xa,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x1028(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    146a <main+0x25a>
mov    0x2bbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1084(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1080(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    0x2b8c(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x1084(%rbp),%edi
mov    -0x1080(%rbp),%rdx
mov    -0x1078(%rbp),%rcx
mov    %rax,%r8
lea    0xbcc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1020(%rbp),%eax
cmp    -0x1024(%rbp),%eax
je     14b9 <main+0x2a9>
mov    0x2b45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
mov    -0x1020(%rbp),%r8d
mov    -0x1024(%rbp),%r9d
lea    0xb93(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
cmpl   $0x83,-0x1014(%rbp)
je     14d9 <main+0x2c9>
cmpl   $0x84,-0x1014(%rbp)
jne    1524 <main+0x314>
cmpl   $0x1234,-0x101c(%rbp)
je     151f <main+0x30f>
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
movslq -0x101c(%rbp),%r8
lea    0xb49(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xd,%edi
call   1120 <exit@plt>
jmp    1524 <main+0x314>
lea    -0x1010(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x1028(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    15ab <main+0x39b>
mov    0x2a7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x109c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1098(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    0x2a4b(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x109c(%rbp),%edi
mov    -0x1098(%rbp),%rdx
mov    -0x1090(%rbp),%rcx
mov    %rax,%r8
lea    0xadf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xe,%edi
call   1120 <exit@plt>
jmp    15f1 <main+0x3e1>
cmpl   $0x0,-0x1028(%rbp)
jne    15ec <main+0x3dc>
mov    0x2a04(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
lea    0xab6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xf,%edi
call   1120 <exit@plt>
jmp    15f1 <main+0x3e1>
jmp    15f6 <main+0x3e6>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    1250 <main+0x40>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x29ad(%rip),%rcx
cmp    (%rcx),%eax
jg     189a <main+0x68a>
mov    -0x1014(%rbp),%eax
or     $0x1a4,%eax
mov    %eax,-0x1034(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x1034(%rbp),%ecx
lea    0xa50(%rip),%rsi
call   1110 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    0x298d(%rip),%rax
mov    (%rax),%esi
mov    0x296c(%rip),%rax
or     (%rax),%esi
mov    -0x1034(%rbp),%edx
call   1100 <open@plt>
mov    %eax,-0x1038(%rbp)
cmpl   $0x0,-0x1038(%rbp)
jge    16fc <main+0x4ec>
mov    0x292d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10b4(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10b0(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x10a8(%rbp)
mov    0x28fa(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x10b4(%rbp),%edi
mov    -0x10b0(%rbp),%rdx
mov    -0x10a8(%rbp),%rcx
mov    %rax,%r8
lea    0x9ca(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x15,%edi
call   1120 <exit@plt>
mov    -0x1038(%rbp),%edi
call   1090 <close@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jge    1795 <main+0x585>
mov    0x2894(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10cc(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10c8(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x10c0(%rbp)
mov    0x2861(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x10cc(%rbp),%edi
mov    -0x10c8(%rbp),%rdx
mov    -0x10c0(%rbp),%rcx
mov    %rax,%r8
lea    0x8a1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1030(%rbp),%edi
mov    0x282e(%rip),%rax
and    (%rax),%edi
call   10e0 <S_ISREG@plt>
cmp    $0x0,%eax
jne    17f8 <main+0x5e8>
mov    0x280f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
mov    -0x1030(%rbp),%r8d
mov    0x27f9(%rip),%rax
and    (%rax),%r8d
lea    0x85a(%rip),%rsi
mov    $0x81,%r9d
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jge    187f <main+0x66f>
mov    0x27aa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10e4(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10e0(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x10d8(%rbp)
mov    0x2777(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x10e4(%rbp),%edi
mov    -0x10e0(%rbp),%rdx
mov    -0x10d8(%rbp),%rcx
mov    %rax,%r8
lea    0x85f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x14,%edi
call   1120 <exit@plt>
jmp    1884 <main+0x674>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    1616 <main+0x406>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x271f(%rip),%rcx
cmp    (%rcx),%eax
jg     1b01 <main+0x8f1>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x1014(%rbp),%ecx
or     $0x1a4,%ecx
lea    0x80b(%rip),%rsi
call   1110 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x1014(%rbp),%esi
or     $0x1b4,%esi
call   1040 <mkdir@plt>
mov    %eax,-0x104c(%rbp)
cmpl   $0x0,-0x104c(%rbp)
jge    1973 <main+0x763>
mov    0x26b6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10fc(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10f8(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x10f0(%rbp)
mov    0x2683(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x10fc(%rbp),%edi
mov    -0x10f8(%rbp),%rdx
mov    -0x10f0(%rbp),%rcx
mov    %rax,%r8
lea    0x791(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1e,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1048(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x104c(%rbp)
cmpl   $0x0,-0x104c(%rbp)
jge    1a01 <main+0x7f1>
mov    0x2628(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1114(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1110(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1108(%rbp)
mov    0x25f5(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x1114(%rbp),%edi
mov    -0x1110(%rbp),%rdx
mov    -0x1108(%rbp),%rcx
mov    %rax,%r8
lea    0x635(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1048(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    1a5f <main+0x84f>
mov    0x25ac(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
mov    -0x1048(%rbp),%r8d
mov    0x2596(%rip),%rax
and    (%rax),%r8d
mov    0x256c(%rip),%rax
mov    (%rax),%r9d
lea    0x5ed(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x104c(%rbp)
cmpl   $0x0,-0x104c(%rbp)
jge    1ae6 <main+0x8d6>
mov    0x2543(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x112c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1128(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1120(%rbp)
mov    0x2510(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x112c(%rbp),%edi
mov    -0x1128(%rbp),%rdx
mov    -0x1120(%rbp),%rcx
mov    %rax,%r8
lea    0x636(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1f,%edi
call   1120 <exit@plt>
jmp    1aeb <main+0x8db>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    18a4 <main+0x694>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0x614(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x1130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%r15
cmp    $0x2,%edi
je     1231 <main+0x21>
mov    (%r15),%rdi
call   10f0 <usage@plt>
xor    %edi,%edi
call   10b0 <umask@plt>
mov    0x2d91(%rip),%r13
cmpl   $0x0,0x0(%r13)
js     14a0 <main+0x290>
mov    0x8(%r15),%rdx
lea    0xdab(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1a4,%ecx
call   1110 <sprintf@plt>
mov    %rbx,%rdi
mov    $0x1a4,%esi
mov    $0x1234,%edx
call   10d0 <mknod@plt>
test   %eax,%eax
js     12f3 <main+0xe3>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <stat@plt>
test   %eax,%eax
js     14c3 <main+0x2b3>
mov    0x8(%rsp),%r8d
cmp    $0x1a5,%r8d
jne    168b <main+0x47b>
lea    0x10(%rsp),%rdi
call   1030 <unlink@plt>
test   %eax,%eax
jns    1302 <main+0xf2>
mov    0x2d0d(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xd82(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xe,%edi
call   1120 <exit@plt>
xor    %eax,%eax
call   1060 <getuid@plt>
test   %eax,%eax
je     16ab <main+0x49b>
mov    0x0(%r13),%eax
cmp    $0x1000,%eax
jl     135c <main+0x14c>
mov    $0x1000,%ebx
lea    0xce7(%rip),%r14
lea    0x10(%rsp),%r12
xchg   %ax,%ax
lea    0x1a4(%rbx),%ebp
mov    0x8(%r15),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%ecx
call   1110 <sprintf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1234,%edx
call   10d0 <mknod@plt>
test   %eax,%eax
je     15aa <main+0x39a>
mov    0x0(%r13),%eax
add    $0x1000,%ebx
cmp    %eax,%ebx
jle    1320 <main+0x110>
test   %eax,%eax
js     14a0 <main+0x290>
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1a4(%r14),%ebp
mov    0x8(%r15),%rdx
mov    %rbx,%rdi
lea    0xcf1(%rip),%rsi
mov    %ebp,%ecx
call   1110 <sprintf@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%esi
mov    0x2c4c(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1100 <open@plt>
test   %eax,%eax
js     1502 <main+0x2f2>
mov    %eax,%edi
call   1090 <close@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <stat@plt>
test   %eax,%eax
js     14c3 <main+0x2b3>
mov    0x8(%rsp),%ebp
mov    0x0(%r13),%edi
and    %ebp,%edi
call   10e0 <S_ISREG@plt>
test   %eax,%eax
je     1541 <main+0x331>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %eax,%eax
js     156b <main+0x35b>
add    $0x1000,%r14d
mov    0x0(%r13),%eax
cmp    %eax,%r14d
jle    1380 <main+0x170>
test   %eax,%eax
js     14a0 <main+0x290>
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x8(%r15),%rdx
lea    0x1a4(%r14),%ecx
mov    %rbx,%rdi
lea    0xc7f(%rip),%rsi
call   1110 <sprintf@plt>
lea    0x1b4(%r14),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
test   %eax,%eax
js     15d3 <main+0x3c3>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <stat@plt>
test   %eax,%eax
js     14c3 <main+0x2b3>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1080 <S_ISDIR@plt>
test   %eax,%eax
je     1612 <main+0x402>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
test   %eax,%eax
js     164c <main+0x43c>
add    $0x1000,%r14d
cmp    0x0(%r13),%r14d
jle    1430 <main+0x220>
mov    (%r15),%rsi
lea    0xc57(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2afe(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb41(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    0x2abf(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2aab(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb70(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x15,%edi
call   1120 <exit@plt>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
and    0x0(%r13),%ebp
lea    0xae3(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebp,%r8d
mov    $0x81,%r9d
jmp    163b <main+0x42b>
mov    0x2a56(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2a42(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb1f(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x14,%edi
call   1120 <exit@plt>
mov    0x2a17(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xab2(%rip),%rsi
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xf,%edi
call   1120 <exit@plt>
mov    0x29ee(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x29da(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xadd(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1e,%edi
call   1120 <exit@plt>
mov    0x29af(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
and    0x0(%r13),%ebp
mov    0x2987(%rip),%rax
mov    (%rax),%r9d
lea    0xa08(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebp,%r8d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
mov    0x2975(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2961(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xa7c(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1f,%edi
call   1120 <exit@plt>
mov    0x2936(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0x99d(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    $0x1a5,%r9d
jmp    163b <main+0x42b>
mov    0x2916(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2902(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0x941(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xa,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@S_IFMT = global i32 0
@.str = [13 x i8] c"%s-mknod%07o\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: ERROR mknod %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"%s: ERROR stat %s: %s\00"
@.str.3 = [28 x i8] c"%s: ERROR mode %s: %o != %o\00"
@.str.4 = [34 x i8] c"%s: ERROR rdev %s: %llu != 0x1234\00"
@.str.5 = [24 x i8] c"%s: ERROR unlink %s: %s\00"
@.str.6 = [23 x i8] c"%s: ERROR: %s created\0A\00"
@.str.7 = [13 x i8] c"%s-creat%07o\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.8 = [24 x i8] c"%s: ERROR creat %s: %s\0A\00"
@.str.9 = [25 x i8] c"%s: ERROR unlink %s: %s\0A\00"
@.str.10 = [13 x i8] c"%s-mkdir%06o\00"
@.str.11 = [24 x i8] c"%s: ERROR mkdir %s: %s\0A\00"
@S_IFDIR = global i32 0
@.str.12 = [24 x i8] c"%s: ERROR rmdir %s: %s\0A\00"
@.str.13 = [13 x i8] c"%s: SUCCESS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i32
%8 = alloca %struct.stat
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.stat
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.stat
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usage(i8* %22)
br label %24
24: ; preds = %19, %2
%25 = call i32 @umask(i32 0)
store i32 0, i32* %7
br label %26
26: ; preds = %149, %24
%27 = load i32, i32* %7
%28 = load i32, i32* @S_IFMT
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %152
30: ; preds = %26
%31 = load i32, i32* %7
%32 = or i32 %31, 420
store i32 %32, i32* %9
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %9
%38 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %36, i32 %37)
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%40 = load i32, i32* %9
%41 = call i32 @mknod(i8* %39, i32 %40, i32 4660)
store i32 %41, i32* %10
%42 = load i32, i32* %7
switch i32 %42, label %136 [
i32 0, label %43
i32 129, label %46
i32 131, label %46
i32 132, label %46
i32 128, label %54
i32 130, label %54
]
43: ; preds = %30
%44 = load i32, i32* %9
%45 = or i32 %44, 129
store i32 %45, i32* %9
br label %46
46: ; preds = %30, %30, %30, %43
%47 = load i32, i32* %10
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = call i32 (...) @getuid()
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %49
br label %149
53: ; preds = %49, %46
br label %54
54: ; preds = %30, %30, %53
%55 = load i32, i32* %10
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 0
%61 = load i8*, i8** %60
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %61, i8* %62, i8* %64)
%66 = call i32 @exit(i32 10)
unreachable
67: ; preds = %54
%68 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%69 = call i32 @stat(i8* %68, %struct.stat* %8)
store i32 %69, i32* %10
%70 = load i32, i32* %10
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %82
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %76, i8* %77, i8* %79)
%81 = call i32 @exit(i32 11)
unreachable
82: ; preds = %67
%83 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%84 = load i32, i32* %83
%85 = load i32, i32* %9
%86 = icmp ne i32 %84, %85
br i1 %86, label %87, label %98
87: ; preds = %82
%88 = load i32, i32* @stderr
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 0
%91 = load i8*, i8** %90
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%93 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%94 = load i32, i32* %93
%95 = load i32, i32* %9
%96 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %91, i8* %92, i32 %94, i32 %95)
%97 = call i32 @exit(i32 12)
unreachable
98: ; preds = %82
%99 = load i32, i32* %7
%100 = icmp eq i32 %99, 131
br i1 %100, label %104, label %101
101: ; preds = %98
%102 = load i32, i32* %7
%103 = icmp eq i32 %102, 132
br i1 %103, label %104, label %120
104: ; preds = %101, %98
%105 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%106 = load i32, i32* %105
%107 = icmp ne i32 %106, 4660
br i1 %107, label %108, label %119
108: ; preds = %104
%109 = load i32, i32* @stderr
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%114 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%115 = load i32, i32* %114
%116 = sext i32 %115 to i64
%117 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %112, i8* %113, i64 %116)
%118 = call i32 @exit(i32 13)
unreachable
119: ; preds = %104
br label %120
120: ; preds = %119, %101
%121 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%122 = call i32 @unlink(i8* %121)
store i32 %122, i32* %10
%123 = load i32, i32* %10
%124 = icmp slt i32 %123, 0
br i1 %124, label %125, label %135
125: ; preds = %120
%126 = load i32, i32* @stderr
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 0
%129 = load i8*, i8** %128
%130 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%131 = load i32, i32* @errno
%132 = call i8* @strerror(i32 %131)
%133 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %129, i8* %130, i8* %132)
%134 = call i32 @exit(i32 14)
unreachable
135: ; preds = %120
br label %148
136: ; preds = %30
%137 = load i32, i32* %10
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %147
139: ; preds = %136
%140 = load i32, i32* @stderr
%141 = load i8**, i8*** %5
%142 = getelementptr inbounds i8*, i8** %141, i64 0
%143 = load i8*, i8** %142
%144 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%145 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %143, i8* %144)
%146 = call i32 @exit(i32 15)
unreachable
147: ; preds = %136
br label %148
148: ; preds = %147, %135
br label %149
149: ; preds = %148, %52
%150 = load i32, i32* %7
%151 = add nsw i32 %150, 4096
store i32 %151, i32* %7
br label %26
152: ; preds = %26
store i32 0, i32* %7
br label %153
153: ; preds = %236, %152
%154 = load i32, i32* %7
%155 = load i32, i32* @S_IFMT
%156 = icmp sle i32 %154, %155
br i1 %156, label %157, label %239
157: ; preds = %153
%158 = load i32, i32* %7
%159 = or i32 %158, 420
store i32 %159, i32* %12
%160 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%161 = load i8**, i8*** %5
%162 = getelementptr inbounds i8*, i8** %161, i64 1
%163 = load i8*, i8** %162
%164 = load i32, i32* %12
%165 = call i32 @sprintf(i8* %160, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %163, i32 %164)
%166 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%167 = load i32, i32* @O_CREAT
%168 = load i32, i32* @O_RDONLY
%169 = or i32 %167, %168
%170 = load i32, i32* %12
%171 = call i32 @open(i8* %166, i32 %169, i32 %170)
store i32 %171, i32* %13
%172 = load i32, i32* %13
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %184
174: ; preds = %157
%175 = load i32, i32* @stderr
%176 = load i8**, i8*** %5
%177 = getelementptr inbounds i8*, i8** %176, i64 0
%178 = load i8*, i8** %177
%179 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%180 = load i32, i32* @errno
%181 = call i8* @strerror(i32 %180)
%182 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %178, i8* %179, i8* %181)
%183 = call i32 @exit(i32 21)
unreachable
184: ; preds = %157
%185 = load i32, i32* %13
%186 = call i32 @close(i32 %185)
%187 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%188 = call i32 @stat(i8* %187, %struct.stat* %11)
store i32 %188, i32* %14
%189 = load i32, i32* %14
%190 = icmp slt i32 %189, 0
br i1 %190, label %191, label %201
191: ; preds = %184
%192 = load i32, i32* @stderr
%193 = load i8**, i8*** %5
%194 = getelementptr inbounds i8*, i8** %193, i64 0
%195 = load i8*, i8** %194
%196 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%197 = load i32, i32* @errno
%198 = call i8* @strerror(i32 %197)
%199 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %192, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %195, i8* %196, i8* %198)
%200 = call i32 @exit(i32 11)
unreachable
201: ; preds = %184
%202 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%203 = load i32, i32* %202
%204 = load i32, i32* @S_IFMT
%205 = and i32 %203, %204
%206 = call i32 @S_ISREG(i32 %205)
%207 = icmp ne i32 %206, 0
br i1 %207, label %220, label %208
208: ; preds = %201
%209 = load i32, i32* @stderr
%210 = load i8**, i8*** %5
%211 = getelementptr inbounds i8*, i8** %210, i64 0
%212 = load i8*, i8** %211
%213 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%214 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%215 = load i32, i32* %214
%216 = load i32, i32* @S_IFMT
%217 = and i32 %215, %216
%218 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %209, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %212, i8* %213, i32 %217, i32 129)
%219 = call i32 @exit(i32 12)
unreachable
220: ; preds = %201
%221 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%222 = call i32 @unlink(i8* %221)
store i32 %222, i32* %14
%223 = load i32, i32* %14
%224 = icmp slt i32 %223, 0
br i1 %224, label %225, label %235
225: ; preds = %220
%226 = load i32, i32* @stderr
%227 = load i8**, i8*** %5
%228 = getelementptr inbounds i8*, i8** %227, i64 0
%229 = load i8*, i8** %228
%230 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%231 = load i32, i32* @errno
%232 = call i8* @strerror(i32 %231)
%233 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %226, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %229, i8* %230, i8* %232)
%234 = call i32 @exit(i32 20)
unreachable
235: ; preds = %220
br label %236
236: ; preds = %235
%237 = load i32, i32* %7
%238 = add nsw i32 %237, 4096
store i32 %238, i32* %7
br label %153
239: ; preds = %153
store i32 0, i32* %7
br label %240
240: ; preds = %317, %239
%241 = load i32, i32* %7
%242 = load i32, i32* @S_IFMT
%243 = icmp sle i32 %241, %242
br i1 %243, label %244, label %320
244: ; preds = %240
%245 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%246 = load i8**, i8*** %5
%247 = getelementptr inbounds i8*, i8** %246, i64 1
%248 = load i8*, i8** %247
%249 = load i32, i32* %7
%250 = or i32 %249, 420
%251 = call i32 @sprintf(i8* %245, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* %248, i32 %250)
%252 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%253 = load i32, i32* %7
%254 = or i32 %253, 436
%255 = call i32 @mkdir(i8* %252, i32 %254)
store i32 %255, i32* %16
%256 = load i32, i32* %16
%257 = icmp slt i32 %256, 0
br i1 %257, label %258, label %268
258: ; preds = %244
%259 = load i32, i32* @stderr
%260 = load i8**, i8*** %5
%261 = getelementptr inbounds i8*, i8** %260, i64 0
%262 = load i8*, i8** %261
%263 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%264 = load i32, i32* @errno
%265 = call i8* @strerror(i32 %264)
%266 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %259, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i8* %262, i8* %263, i8* %265)
%267 = call i32 @exit(i32 30)
unreachable
268: ; preds = %244
%269 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%270 = call i32 @stat(i8* %269, %struct.stat* %15)
store i32 %270, i32* %16
%271 = load i32, i32* %16
%272 = icmp slt i32 %271, 0
br i1 %272, label %273, label %283
273: ; preds = %268
%274 = load i32, i32* @stderr
%275 = load i8**, i8*** %5
%276 = getelementptr inbounds i8*, i8** %275, i64 0
%277 = load i8*, i8** %276
%278 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%279 = load i32, i32* @errno
%280 = call i8* @strerror(i32 %279)
%281 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %274, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %277, i8* %278, i8* %280)
%282 = call i32 @exit(i32 11)
unreachable
283: ; preds = %268
%284 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%285 = load i32, i32* %284
%286 = call i32 @S_ISDIR(i32 %285)
%287 = icmp ne i32 %286, 0
br i1 %287, label %301, label %288
288: ; preds = %283
%289 = load i32, i32* @stderr
%290 = load i8**, i8*** %5
%291 = getelementptr inbounds i8*, i8** %290, i64 0
%292 = load i8*, i8** %291
%293 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%294 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%295 = load i32, i32* %294
%296 = load i32, i32* @S_IFMT
%297 = and i32 %295, %296
%298 = load i32, i32* @S_IFDIR
%299 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %289, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %292, i8* %293, i32 %297, i32 %298)
%300 = call i32 @exit(i32 12)
unreachable
301: ; preds = %283
%302 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%303 = call i32 @rmdir(i8* %302)
store i32 %303, i32* %16
%304 = load i32, i32* %16
%305 = icmp slt i32 %304, 0
br i1 %305, label %306, label %316
306: ; preds = %301
%307 = load i32, i32* @stderr
%308 = load i8**, i8*** %5
%309 = getelementptr inbounds i8*, i8** %308, i64 0
%310 = load i8*, i8** %309
%311 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%312 = load i32, i32* @errno
%313 = call i8* @strerror(i32 %312)
%314 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %307, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %310, i8* %311, i8* %313)
%315 = call i32 @exit(i32 31)
unreachable
316: ; preds = %301
br label %317
317: ; preds = %316
%318 = load i32, i32* %7
%319 = add nsw i32 %318, 4096
store i32 %319, i32* %7
br label %240
320: ; preds = %240
%321 = load i8**, i8*** %5
%322 = getelementptr inbounds i8*, i8** %321, i64 0
%323 = load i8*, i8** %322
%324 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %323)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@S_IFMT = global i32 0
@.str = [13 x i8] c"%s-mknod%07o\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: ERROR mknod %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"%s: ERROR stat %s: %s\00"
@.str.3 = [28 x i8] c"%s: ERROR mode %s: %o != %o\00"
@.str.5 = [24 x i8] c"%s: ERROR unlink %s: %s\00"
@.str.6 = [23 x i8] c"%s: ERROR: %s created\0A\00"
@.str.7 = [13 x i8] c"%s-creat%07o\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.8 = [24 x i8] c"%s: ERROR creat %s: %s\0A\00"
@.str.9 = [25 x i8] c"%s: ERROR unlink %s: %s\0A\00"
@.str.10 = [13 x i8] c"%s-mkdir%06o\00"
@.str.11 = [24 x i8] c"%s: ERROR mkdir %s: %s\0A\00"
@S_IFDIR = global i32 0
@.str.12 = [24 x i8] c"%s: ERROR rmdir %s: %s\0A\00"
@.str.13 = [13 x i8] c"%s: SUCCESS\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca %struct.stat
%5 = alloca %struct.stat
%6 = alloca %struct.stat
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%8 = icmp eq i32 %0, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @usage(i8* %10)
br label %12
12: ; preds = %9, %2
%13 = tail call i32 @umask(i32 0)
%14 = load i32, i32* @S_IFMT
%15 = icmp slt i32 %14, 0
br i1 %15, label %200, label %16
16: ; preds = %12
%17 = bitcast %struct.stat* %4 to i8*
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%20 = load i8*, i8** %18
%21 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %20, i32 420)
%22 = call i32 @mknod(i8* %7, i32 420, i32 4660)
%23 = icmp slt i32 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %16
%25 = call i32 @stat(i8* %7, %struct.stat* %4)
%26 = icmp slt i32 %25, 0
br i1 %26, label %53, label %27
27: ; preds = %24
%28 = load i32, i32* %19
%29 = icmp eq i32 %28, 421
br i1 %29, label %30, label %60
30: ; preds = %27
%31 = call i32 @unlink(i8* %7)
%32 = icmp slt i32 %31, 0
br i1 %32, label %65, label %36
33: ; preds = %16
%34 = call i32 (...) @getuid()
%35 = icmp eq i32 %34, 0
br i1 %35, label %46, label %36
36: ; preds = %33, %30
%37 = load i32, i32* @S_IFMT
%38 = icmp slt i32 %37, 4096
br i1 %38, label %39, label %72
39: ; preds = %84, %36
%40 = phi i32 [ %37, %36 ], [ %85, %84 ]
%41 = icmp slt i32 %40, 0
br i1 %41, label %200, label %42
42: ; preds = %39
%43 = bitcast %struct.stat* %5 to i8*
%44 = getelementptr inbounds i8*, i8** %1, i64 1
%45 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %94
46: ; preds = %33
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %1
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %48, i8* %7, i8* %50)
%52 = call i32 @exit(i32 10)
unreachable
53: ; preds = %24
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %1
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %55, i8* %7, i8* %57)
%59 = call i32 @exit(i32 11)
unreachable
60: ; preds = %27
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %1
%63 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %62, i8* %7, i32 %28, i32 421)
%64 = call i32 @exit(i32 12)
unreachable
65: ; preds = %30
%66 = load i32, i32* @stderr
%67 = load i8*, i8** %1
%68 = load i32, i32* @errno
%69 = call i8* @strerror(i32 %68)
%70 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %67, i8* %7, i8* %69)
%71 = call i32 @exit(i32 14)
unreachable
72: ; preds = %36, %84
%73 = phi i32 [ %86, %84 ], [ 4096, %36 ]
%74 = or i32 %73, 420
%75 = load i8*, i8** %18
%76 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %75, i32 %74)
%77 = call i32 @mknod(i8* %7, i32 %74, i32 4660)
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %72
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %1
%82 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %81, i8* %7)
%83 = call i32 @exit(i32 15)
unreachable
84: ; preds = %72
%85 = load i32, i32* @S_IFMT
%86 = add nuw nsw i32 %73, 4096
%87 = icmp sgt i32 %86, %85
br i1 %87, label %39, label %72
88: ; preds = %145
%89 = icmp slt i32 %147, 0
br i1 %89, label %200, label %90
90: ; preds = %88
%91 = bitcast %struct.stat* %6 to i8*
%92 = getelementptr inbounds i8*, i8** %1, i64 1
%93 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
br label %149
94: ; preds = %42, %145
%95 = phi i32 [ 0, %42 ], [ %146, %145 ]
%96 = or i32 %95, 420
%97 = load i8*, i8** %44
%98 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %97, i32 %96)
%99 = load i32, i32* @O_CREAT
%100 = load i32, i32* @O_RDONLY
%101 = or i32 %100, %99
%102 = call i32 @open(i8* %7, i32 %101, i32 %96)
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %111
104: ; preds = %94
%105 = load i32, i32* @stderr
%106 = load i8*, i8** %1
%107 = load i32, i32* @errno
%108 = call i8* @strerror(i32 %107)
%109 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %106, i8* %7, i8* %108)
%110 = call i32 @exit(i32 21)
unreachable
111: ; preds = %94
%112 = call i32 @close(i32 %102)
%113 = call i32 @stat(i8* %7, %struct.stat* %5)
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %122
115: ; preds = %111
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %1
%118 = load i32, i32* @errno
%119 = call i8* @strerror(i32 %118)
%120 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %117, i8* %7, i8* %119)
%121 = call i32 @exit(i32 11)
unreachable
122: ; preds = %111
%123 = load i32, i32* %45
%124 = load i32, i32* @S_IFMT
%125 = and i32 %124, %123
%126 = call i32 @S_ISREG(i32 %125)
%127 = icmp eq i32 %126, 0
br i1 %127, label %128, label %135
128: ; preds = %122
%129 = load i32, i32* @stderr
%130 = load i8*, i8** %1
%131 = load i32, i32* @S_IFMT
%132 = and i32 %131, %123
%133 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %130, i8* %7, i32 %132, i32 129)
%134 = call i32 @exit(i32 12)
unreachable
135: ; preds = %122
%136 = call i32 @unlink(i8* %7)
%137 = icmp slt i32 %136, 0
br i1 %137, label %138, label %145
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = load i8*, i8** %1
%141 = load i32, i32* @errno
%142 = call i8* @strerror(i32 %141)
%143 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %140, i8* %7, i8* %142)
%144 = call i32 @exit(i32 20)
unreachable
145: ; preds = %135
%146 = add nuw nsw i32 %95, 4096
%147 = load i32, i32* @S_IFMT
%148 = icmp sgt i32 %146, %147
br i1 %148, label %88, label %94
149: ; preds = %90, %196
%150 = phi i32 [ 0, %90 ], [ %197, %196 ]
%151 = load i8*, i8** %92
%152 = or i32 %150, 420
%153 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* %151, i32 %152)
%154 = or i32 %150, 436
%155 = call i32 @mkdir(i8* %7, i32 %154)
%156 = icmp slt i32 %155, 0
br i1 %156, label %157, label %164
157: ; preds = %149
%158 = load i32, i32* @stderr
%159 = load i8*, i8** %1
%160 = load i32, i32* @errno
%161 = call i8* @strerror(i32 %160)
%162 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i8* %159, i8* %7, i8* %161)
%163 = call i32 @exit(i32 30)
unreachable
164: ; preds = %149
%165 = call i32 @stat(i8* %7, %struct.stat* %6)
%166 = icmp slt i32 %165, 0
br i1 %166, label %167, label %174
167: ; preds = %164
%168 = load i32, i32* @stderr
%169 = load i8*, i8** %1
%170 = load i32, i32* @errno
%171 = call i8* @strerror(i32 %170)
%172 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %169, i8* %7, i8* %171)
%173 = call i32 @exit(i32 11)
unreachable
174: ; preds = %164
%175 = load i32, i32* %93
%176 = call i32 @S_ISDIR(i32 %175)
%177 = icmp eq i32 %176, 0
br i1 %177, label %178, label %186
178: ; preds = %174
%179 = load i32, i32* @stderr
%180 = load i8*, i8** %1
%181 = load i32, i32* @S_IFMT
%182 = and i32 %181, %175
%183 = load i32, i32* @S_IFDIR
%184 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %179, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %180, i8* %7, i32 %182, i32 %183)
%185 = call i32 @exit(i32 12)
unreachable
186: ; preds = %174
%187 = call i32 @rmdir(i8* %7)
%188 = icmp slt i32 %187, 0
br i1 %188, label %189, label %196
189: ; preds = %186
%190 = load i32, i32* @stderr
%191 = load i8*, i8** %1
%192 = load i32, i32* @errno
%193 = call i8* @strerror(i32 %192)
%194 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %190, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %191, i8* %7, i8* %193)
%195 = call i32 @exit(i32 31)
unreachable
196: ; preds = %186
%197 = add nuw nsw i32 %150, 4096
%198 = load i32, i32* @S_IFMT
%199 = icmp sgt i32 %197, %198
br i1 %199, label %200, label %149
200: ; preds = %196, %12, %39, %88
%201 = load i8*, i8** %1
%202 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %201)
ret i32 0
}