#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;
};
typedef int /*<<< orphan*/ name;

/* 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*/ snprintf(char *, int, 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;
    snprintf(name, sizeof(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;
    snprintf(name, sizeof(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;
    snprintf(name, sizeof(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   1100 <usage@plt>
xor    %edi,%edi
call   10c0 <umask@plt>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x2d73(%rip),%rcx
cmp    (%rcx),%eax
jg     1612 <main+0x402>
mov    -0x1014(%rbp),%eax
or     $0x1a4,%eax
mov    %eax,-0x1024(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x1024(%rbp),%r8d
lea    0xd74(%rip),%rdx
lea    -0x1010(%rbp),%rdi
mov    %rdi,-0x1058(%rbp)
mov    $0x1000,%esi
call   1090 <snprintf@plt>
mov    -0x1058(%rbp),%rdi
mov    -0x1024(%rbp),%esi
mov    $0x1234,%edx
call   10e0 <mknod@plt>
mov    %eax,-0x1028(%rbp)
mov    -0x1014(%rbp),%eax
mov    %eax,-0x1050(%rbp)
test   %eax,%eax
je     1335 <main+0x125>
jmp    12da <main+0xca>
mov    -0x1050(%rbp),%eax
sub    $0x80,%eax
je     136d <main+0x15d>
jmp    12f0 <main+0xe0>
mov    -0x1050(%rbp),%eax
sub    $0x81,%eax
je     1346 <main+0x136>
jmp    1306 <main+0xf6>
mov    -0x1050(%rbp),%eax
sub    $0x82,%eax
je     136d <main+0x15d>
jmp    131c <main+0x10c>
mov    -0x1050(%rbp),%eax
add    $0xffffff7d,%eax
sub    $0x2,%eax
jb     1346 <main+0x136>
jmp    15b6 <main+0x3a6>
mov    -0x1024(%rbp),%eax
or     $0x81,%eax
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    1368 <main+0x158>
mov    $0x0,%al
call   1060 <getuid@plt>
cmp    $0x0,%eax
je     1368 <main+0x158>
jmp    15fc <main+0x3ec>
jmp    136d <main+0x15d>
cmpl   $0x0,-0x1028(%rbp)
jge    13e2 <main+0x1d2>
mov    0x2c47(%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    0x2c14(%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    0xc3c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xa,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x1028(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    1470 <main+0x260>
mov    0x2bb9(%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    0x2b86(%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    0xbc6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1020(%rbp),%eax
cmp    -0x1024(%rbp),%eax
je     14bf <main+0x2af>
mov    0x2b3f(%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    0xb8d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
cmpl   $0x83,-0x1014(%rbp)
je     14df <main+0x2cf>
cmpl   $0x84,-0x1014(%rbp)
jne    152a <main+0x31a>
cmpl   $0x1234,-0x101c(%rbp)
je     1525 <main+0x315>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
movslq -0x101c(%rbp),%r8
lea    0xb43(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xd,%edi
call   1120 <exit@plt>
jmp    152a <main+0x31a>
lea    -0x1010(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x1028(%rbp)
cmpl   $0x0,-0x1028(%rbp)
jge    15b1 <main+0x3a1>
mov    0x2a78(%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    0x2a45(%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    0xad9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xe,%edi
call   1120 <exit@plt>
jmp    15f7 <main+0x3e7>
cmpl   $0x0,-0x1028(%rbp)
jne    15f2 <main+0x3e2>
mov    0x29fe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
lea    0xab0(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xf,%edi
call   1120 <exit@plt>
jmp    15f7 <main+0x3e7>
jmp    15fc <main+0x3ec>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    1250 <main+0x40>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x29a7(%rip),%rcx
cmp    (%rcx),%eax
jg     18a6 <main+0x696>
mov    -0x1014(%rbp),%eax
or     $0x1a4,%eax
mov    %eax,-0x1034(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x1034(%rbp),%r8d
mov    $0x1000,%esi
lea    0xa44(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x1010(%rbp),%rdi
mov    0x2981(%rip),%rax
mov    (%rax),%esi
mov    0x2960(%rip),%rax
or     (%rax),%esi
mov    -0x1034(%rbp),%edx
call   1110 <open@plt>
mov    %eax,-0x1038(%rbp)
cmpl   $0x0,-0x1038(%rbp)
jge    1708 <main+0x4f8>
mov    0x2921(%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    0x28ee(%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    0x9be(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x15,%edi
call   1120 <exit@plt>
mov    -0x1038(%rbp),%edi
call   10a0 <close@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jge    17a1 <main+0x591>
mov    0x2888(%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    0x2855(%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    0x895(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1030(%rbp),%edi
mov    0x2822(%rip),%rax
and    (%rax),%edi
call   10f0 <S_ISREG@plt>
cmp    $0x0,%eax
jne    1804 <main+0x5f4>
mov    0x2803(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
mov    -0x1030(%rbp),%r8d
mov    0x27ed(%rip),%rax
and    (%rax),%r8d
lea    0x84e(%rip),%rsi
mov    $0x81,%r9d
mov    $0x0,%al
call   10b0 <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    188b <main+0x67b>
mov    0x279e(%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    0x276b(%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    0x853(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x14,%edi
call   1120 <exit@plt>
jmp    1890 <main+0x680>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    161c <main+0x40c>
movl   $0x0,-0x1014(%rbp)
mov    -0x1014(%rbp),%eax
mov    0x2713(%rip),%rcx
cmp    (%rcx),%eax
jg     1b14 <main+0x904>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x1014(%rbp),%r8d
or     $0x1a4,%r8d
mov    $0x1000,%esi
lea    0x7f8(%rip),%rdx
call   1090 <snprintf@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    1986 <main+0x776>
mov    0x26a3(%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    0x2670(%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    0x77e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1e,%edi
call   1120 <exit@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1048(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x104c(%rbp)
cmpl   $0x0,-0x104c(%rbp)
jge    1a14 <main+0x804>
mov    0x2615(%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    0x25e2(%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    0x622(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    -0x1048(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    1a72 <main+0x862>
mov    0x2599(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1010(%rbp),%rcx
mov    -0x1048(%rbp),%r8d
mov    0x2583(%rip),%rax
and    (%rax),%r8d
mov    0x2559(%rip),%rax
mov    (%rax),%r9d
lea    0x5da(%rip),%rsi
mov    $0x0,%al
call   10b0 <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    1af9 <main+0x8e9>
mov    0x2530(%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    0x24fd(%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    0x623(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1f,%edi
call   1120 <exit@plt>
jmp    1afe <main+0x8ee>
mov    -0x1014(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x1014(%rbp)
jmp    18b0 <main+0x6a0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0x601(%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   1100 <usage@plt>
xor    %edi,%edi
call   10c0 <umask@plt>
mov    0x2d91(%rip),%r13
cmpl   $0x0,0x0(%r13)
js     14b5 <main+0x2a5>
mov    0x8(%r15),%rcx
lea    0xdab(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x1a4,%r8d
call   1090 <snprintf@plt>
mov    %rbx,%rdi
mov    $0x1a4,%esi
mov    $0x1234,%edx
call   10e0 <mknod@plt>
test   %eax,%eax
js     12f9 <main+0xe9>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10d0 <stat@plt>
test   %eax,%eax
js     14d8 <main+0x2c8>
mov    0x8(%rsp),%r8d
cmp    $0x1a5,%r8d
jne    16a0 <main+0x490>
lea    0x10(%rsp),%rdi
call   1030 <unlink@plt>
test   %eax,%eax
jns    1308 <main+0xf8>
mov    0x2d07(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xd7c(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xe,%edi
call   1120 <exit@plt>
xor    %eax,%eax
call   1060 <getuid@plt>
test   %eax,%eax
je     16c0 <main+0x4b0>
mov    0x0(%r13),%eax
cmp    $0x1000,%eax
jl     1372 <main+0x162>
mov    $0x1000,%ebx
lea    0xce1(%rip),%r14
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1a4(%rbx),%ebp
mov    0x8(%r15),%rcx
mov    %r12,%rdi
mov    $0x1000,%esi
mov    %r14,%rdx
mov    %ebp,%r8d
call   1090 <snprintf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1234,%edx
call   10e0 <mknod@plt>
test   %eax,%eax
je     15bf <main+0x3af>
mov    0x0(%r13),%eax
add    $0x1000,%ebx
cmp    %eax,%ebx
jle    1330 <main+0x120>
test   %eax,%eax
js     14b5 <main+0x2a5>
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
lea    0x1a4(%r14),%ebp
mov    0x8(%r15),%rcx
mov    %rbx,%rdi
mov    $0x1000,%esi
lea    0xcdc(%rip),%rdx
mov    %ebp,%r8d
call   1090 <snprintf@plt>
mov    0x2c27(%rip),%rax
mov    (%rax),%esi
mov    0x2c36(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1110 <open@plt>
test   %eax,%eax
js     1517 <main+0x307>
mov    %eax,%edi
call   10a0 <close@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <stat@plt>
test   %eax,%eax
js     14d8 <main+0x2c8>
mov    0x8(%rsp),%ebp
mov    0x0(%r13),%edi
and    %ebp,%edi
call   10f0 <S_ISREG@plt>
test   %eax,%eax
je     1556 <main+0x346>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %eax,%eax
js     1580 <main+0x370>
add    $0x1000,%r14d
mov    0x0(%r13),%eax
cmp    %eax,%r14d
jle    1390 <main+0x180>
test   %eax,%eax
js     14b5 <main+0x2a5>
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
mov    0x8(%r15),%rcx
lea    0x1a4(%r14),%r8d
mov    %rbx,%rdi
mov    $0x1000,%esi
lea    0xc6a(%rip),%rdx
call   1090 <snprintf@plt>
lea    0x1b4(%r14),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
test   %eax,%eax
js     15e8 <main+0x3d8>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <stat@plt>
test   %eax,%eax
js     14d8 <main+0x2c8>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1080 <S_ISDIR@plt>
test   %eax,%eax
je     1627 <main+0x417>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
test   %eax,%eax
js     1661 <main+0x451>
add    $0x1000,%r14d
cmp    0x0(%r13),%r14d
jle    1440 <main+0x230>
mov    (%r15),%rsi
lea    0xc42(%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    0x2ae9(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2ad5(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb2c(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xb,%edi
call   1120 <exit@plt>
mov    0x2aaa(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2a96(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb5b(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x15,%edi
call   1120 <exit@plt>
mov    0x2a6b(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
and    0x0(%r13),%ebp
lea    0xace(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebp,%r8d
mov    $0x81,%r9d
jmp    1650 <main+0x440>
mov    0x2a41(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x2a2d(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb0a(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x14,%edi
call   1120 <exit@plt>
mov    0x2a02(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xa9d(%rip),%rsi
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xf,%edi
call   1120 <exit@plt>
mov    0x29d9(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x29c5(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xac8(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1e,%edi
call   1120 <exit@plt>
mov    0x299a(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
and    0x0(%r13),%ebp
mov    0x2972(%rip),%rax
mov    (%rax),%r9d
lea    0x9f3(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebp,%r8d
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xc,%edi
call   1120 <exit@plt>
mov    0x2960(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x294c(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xa67(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1f,%edi
call   1120 <exit@plt>
mov    0x2921(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0x988(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    $0x1a5,%r9d
jmp    1650 <main+0x440>
mov    0x2901(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rbp
mov    0x28ed(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0x92c(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <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 @snprintf(i8* %33, i32 4096, 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 @snprintf(i8* %160, i32 4096, 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 @snprintf(i8* %245, i32 4096, 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 @snprintf(i8* %7, i32 4096, i8* 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 @snprintf(i8* %7, i32 4096, i8* 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 @snprintf(i8* %7, i32 4096, i8* 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 @snprintf(i8* %7, i32 4096, i8* 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
}