#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;
};
typedef int mode_t;

/* Variables and functions */
#define EEXIST 130
int EIO;
#define EISDIR 129
#define ENOENT 128
int ENOMEM;
int ENOTDIR;
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
scalar_t__ S_ISDIR(int);
int S_IWUSR;
int S_IXUSR;
int errno;
int fchmodat(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ fstatat(int, char const *, struct stat *, int /*<<< orphan*/);
int mkdirat(int, char const *, int);
void *strdup(char const *);
int strlen(char *);
char *strrchr(char *, char);
int _mkpath(int dfd, const char *path, mode_t omode, const char **firstdir) {
  char *apath = NULL, *opath = NULL, *s, *sn, *sl;
  unsigned int depth = 0;
  mode_t chmod_mode = 0;
  int retval = 0;
  int old_errno = errno;
  struct stat sbuf;
  if (0 == mkdirat(dfd, path, omode)) {
    if (firstdir) {
      *firstdir = strdup(path);
    }
    goto mkpath_exit;
  }
  switch (errno) {
  case ENOENT:
    break;
  case EEXIST:
    if (fstatat(dfd, path, &sbuf, 0) == 0) {
      if (S_ISDIR(sbuf.st_mode)) {
        retval = EEXIST;
      } else {
        retval = ENOTDIR;
      }
    } else {
      retval = EIO;
    }
    goto mkpath_exit;
  case EISDIR:
    retval = EEXIST;
    goto mkpath_exit;
  default:
    retval = errno;
    goto mkpath_exit;
  }
  apath = strdup(path);
  if (apath == NULL) {
    retval = ENOMEM;
    goto mkpath_exit;
  }
  sl = s = apath + strlen(apath) - 1;
  do {
    sn = s;
    if (s - 1 > apath && *s == '.' && *(s - 1) == '/')
      s -= 2;
    if (s > apath && *s == '/')
      s--;
  } while (s < sn);
  if (s < sl) {
    s[1] = '\0';
    path = opath = strdup(apath);
    if (opath == NULL) {
      retval = ENOMEM;
      goto mkpath_exit;
    }
  }
  if (0 == mkdirat(dfd, path, omode)) {
    if (firstdir) {
      *firstdir = strdup(path);
    }
    goto mkpath_exit;
  }
  while (1) {
    s = strrchr(apath, '/');
    if (!s) {
      retval = ENOENT;
      goto mkpath_exit;
    }
    *s = '\0';
    depth++;
    if (0 == mkdirat(dfd, apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
      struct stat dirstat;
      if (-1 == fstatat(dfd, apath, &dirstat, 0)) {
        retval = ENOENT;
        goto mkpath_exit;
      }
      if ((dirstat.st_mode & (S_IWUSR | S_IXUSR)) != (S_IWUSR | S_IXUSR)) {
        chmod_mode = dirstat.st_mode | S_IWUSR | S_IXUSR;
        if (-1 == fchmodat(dfd, apath, chmod_mode, 0)) {
          retval = ENOENT;
          goto mkpath_exit;
        }
      }
      if (firstdir) {
        *firstdir = strdup(apath);
      }
      break;
    } else if (errno == EEXIST) {
      if (fstatat(dfd, apath, &sbuf, 0) == 0 && S_ISDIR(sbuf.st_mode)) {
        if (firstdir) {
          *firstdir = strdup(apath);
        }
        break;
      }
      retval = ENOTDIR;
      goto mkpath_exit;
    } else if (errno != ENOENT) {
      retval = errno;
      goto mkpath_exit;
    }
  }
  while (depth > 1) {
    s = strrchr(apath, '\0');
    *s = '/';
    depth--;
    if (-1 == mkdirat(dfd, apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
      if (errno == EEXIST)
        continue;
      retval = errno;
      goto mkpath_exit;
    }
    if (chmod_mode) {
      if (-1 == fchmodat(dfd, apath, chmod_mode, 0)) {
        retval = ENOENT;
        goto mkpath_exit;
      }
    }
  }
  if (-1 == mkdirat(dfd, path, omode)) {
    retval = errno;
    if (errno == EEXIST && fstatat(dfd, path, &sbuf, 0) == 0 &&
        !S_ISDIR(sbuf.st_mode)) {
      retval = ENOTDIR;
    }
  }
mkpath_exit:
  free(apath);
  free(opath);
  errno = old_errno;
  return retval;
}


x86 assembly (clang, -O0):
<_mkpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <mkdirat@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1208 <_mkpath+0x88>
cmpq   $0x0,-0x20(%rbp)
je     1203 <_mkpath+0x83>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1759 <_mkpath+0x5d9>
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x80,%eax
je     124a <_mkpath+0xca>
jmp    1224 <_mkpath+0xa4>
mov    -0x6c(%rbp),%eax
sub    $0x81,%eax
je     12ab <_mkpath+0x12b>
jmp    1237 <_mkpath+0xb7>
mov    -0x6c(%rbp),%eax
sub    $0x82,%eax
je     124f <_mkpath+0xcf>
jmp    12b7 <_mkpath+0x137>
jmp    12c8 <_mkpath+0x148>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rdx
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
cmp    $0x0,%rax
jne    129a <_mkpath+0x11a>
mov    -0x60(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1289 <_mkpath+0x109>
movl   $0x82,-0x54(%rbp)
jmp    1295 <_mkpath+0x115>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    12a6 <_mkpath+0x126>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
movl   $0x82,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12f1 <_mkpath+0x171>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
cmp    -0x28(%rbp),%rax
jbe    1361 <_mkpath+0x1e1>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1361 <_mkpath+0x1e1>
mov    -0x38(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
jne    1361 <_mkpath+0x1e1>
mov    -0x38(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    138b <_mkpath+0x20b>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    138b <_mkpath+0x20b>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
jmp    1390 <_mkpath+0x210>
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jb     131a <_mkpath+0x19a>
mov    -0x38(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    13e6 <_mkpath+0x266>
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13e1 <_mkpath+0x261>
mov    0x2bd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
jmp    13e6 <_mkpath+0x266>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <mkdirat@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1424 <_mkpath+0x2a4>
cmpq   $0x0,-0x20(%rbp)
je     141f <_mkpath+0x29f>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1759 <_mkpath+0x5d9>
jmp    1429 <_mkpath+0x2a9>
mov    -0x28(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1452 <_mkpath+0x2d2>
movl   $0x80,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    0x2b68(%rip),%rax
mov    (%rax),%edx
mov    0x2b57(%rip),%rax
or     (%rax),%edx
mov    0x2b66(%rip),%rax
or     (%rax),%edx
call   1070 <mkdirat@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1563 <_mkpath+0x3e3>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
lea    -0x68(%rbp),%rdx
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
mov    %rax,%rcx
mov    $0xffffffffffffffff,%rax
cmp    %rcx,%rax
jne    14c6 <_mkpath+0x346>
movl   $0x80,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    -0x68(%rbp),%eax
mov    0x2af0(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2aef(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
mov    0x2adc(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2adb(%rip),%rdx
or     (%rdx),%ecx
cmp    %ecx,%eax
je     1540 <_mkpath+0x3c0>
mov    -0x68(%rbp),%eax
mov    0x2abf(%rip),%rcx
or     (%rcx),%eax
mov    0x2abe(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x50(%rbp),%edx
xor    %ecx,%ecx
call   1080 <fchmodat@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    153b <_mkpath+0x3bb>
movl   $0x80,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
jmp    1540 <_mkpath+0x3c0>
cmpq   $0x0,-0x20(%rbp)
je     155e <_mkpath+0x3de>
mov    -0x28(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    160b <_mkpath+0x48b>
mov    0x2a36(%rip),%rax
cmpl   $0x82,(%rax)
jne    15d8 <_mkpath+0x458>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
lea    -0x60(%rbp),%rdx
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
cmp    $0x0,%rax
jne    15c7 <_mkpath+0x447>
mov    -0x60(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     15c7 <_mkpath+0x447>
cmpq   $0x0,-0x20(%rbp)
je     15c2 <_mkpath+0x442>
mov    -0x28(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    160b <_mkpath+0x48b>
mov    0x2a2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
mov    0x29c1(%rip),%rax
cmpl   $0x80,(%rax)
je     15fc <_mkpath+0x47c>
mov    0x29ae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
jmp    1601 <_mkpath+0x481>
jmp    1606 <_mkpath+0x486>
jmp    1429 <_mkpath+0x2a9>
jmp    1610 <_mkpath+0x490>
cmpl   $0x1,-0x4c(%rbp)
jbe    16d8 <_mkpath+0x558>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x4c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    0x2991(%rip),%rax
mov    (%rax),%edx
mov    0x2980(%rip),%rax
or     (%rax),%edx
mov    0x298f(%rip),%rax
or     (%rax),%edx
call   1070 <mkdirat@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1698 <_mkpath+0x518>
mov    0x292a(%rip),%rax
cmpl   $0x82,(%rax)
jne    1687 <_mkpath+0x507>
jmp    1610 <_mkpath+0x490>
mov    0x2912(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
cmpl   $0x0,-0x50(%rbp)
je     16d3 <_mkpath+0x553>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x50(%rbp),%edx
xor    %ecx,%ecx
call   1080 <fchmodat@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    16ce <_mkpath+0x54e>
movl   $0x80,-0x54(%rbp)
jmp    1759 <_mkpath+0x5d9>
jmp    16d3 <_mkpath+0x553>
jmp    1610 <_mkpath+0x490>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <mkdirat@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1754 <_mkpath+0x5d4>
mov    0x28a3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2897(%rip),%rax
cmpl   $0x82,(%rax)
jne    174f <_mkpath+0x5cf>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rdx
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
cmp    $0x0,%rax
jne    174f <_mkpath+0x5cf>
mov    -0x60(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    174f <_mkpath+0x5cf>
mov    0x28ae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    1754 <_mkpath+0x5d4>
jmp    1759 <_mkpath+0x5d9>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%ecx
mov    0x282b(%rip),%rax
mov    %ecx,(%rax)
mov    -0x54(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mkpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x2e00(%rip),%r14
mov    (%r14),%eax
mov    %eax,0x4(%rsp)
call   1070 <mkdirat@plt>
test   %eax,%eax
je     11fd <_mkpath+0x7d>
mov    (%r14),%r13d
cmp    $0x80,%r13d
je     121e <_mkpath+0x9e>
cmp    $0x81,%r13d
je     1293 <_mkpath+0x113>
cmp    $0x82,%r13d
jne    1316 <_mkpath+0x196>
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
test   %rax,%rax
je     12e0 <_mkpath+0x160>
mov    0x2db8(%rip),%rax
jmp    1313 <_mkpath+0x193>
test   %rbx,%rbx
je     120d <_mkpath+0x8d>
mov    %r15,%rdi
call   1090 <strdup@plt>
mov    %rax,(%rbx)
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %r13d,%r13d
mov    0x4(%rsp),%ebp
jmp    1570 <_mkpath+0x3f0>
mov    %rbx,0x18(%rsp)
mov    %r15,%rdi
call   1090 <strdup@plt>
test   %rax,%rax
je     130c <_mkpath+0x18c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
add    %rbx,%rax
mov    $0xffffffffffffffff,%rdx
mov    %rdx,%rcx
jmp    1258 <_mkpath+0xd8>
cmp    %rdx,%rcx
mov    %rcx,%rdx
jge    12a7 <_mkpath+0x127>
lea    (%rax,%rdx,1),%rsi
add    $0xffffffffffffffff,%rsi
cmp    %rbx,%rsi
jbe    127c <_mkpath+0xfc>
lea    (%rax,%rdx,1),%rcx
cmpb   $0x2e,(%rcx)
mov    %rdx,%rcx
jne    127c <_mkpath+0xfc>
lea    -0x2(%rdx),%rcx
cmpb   $0x2f,(%rsi)
cmovne %rdx,%rcx
lea    (%rax,%rcx,1),%rsi
cmp    %rbx,%rsi
jbe    1250 <_mkpath+0xd0>
xor    %edi,%edi
cmpb   $0x2f,(%rsi)
sete   %dil
sub    %rdi,%rcx
jmp    1250 <_mkpath+0xd0>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    $0x82,%r13d
mov    0x4(%rsp),%ebp
jmp    1570 <_mkpath+0x3f0>
cmp    $0xfffffffffffffffe,%rcx
jg     1324 <_mkpath+0x1a4>
movb   $0x0,0x1(%rax,%rcx,1)
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    %rax,%r15
mov    %rax,%rcx
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    132b <_mkpath+0x1ab>
mov    0x2cd7(%rip),%rax
mov    (%rax),%r13d
xor    %r15d,%r15d
mov    0x4(%rsp),%ebp
jmp    1570 <_mkpath+0x3f0>
mov    0x10(%rsp),%edi
call   1050 <S_ISDIR@plt>
mov    $0x82,%r13d
test   %rax,%rax
mov    0x4(%rsp),%ebp
jne    1302 <_mkpath+0x182>
mov    0x2cf9(%rip),%rax
mov    (%rax),%r13d
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1570 <_mkpath+0x3f0>
mov    0x2c95(%rip),%rax
mov    (%rax),%r13d
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    0x4(%rsp),%ebp
jmp    1570 <_mkpath+0x3f0>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %r12d,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <mkdirat@plt>
test   %eax,%eax
je     13df <_mkpath+0x25f>
mov    $0x1,%ecx
mov    $0x80,%r13d
nopl   0x0(%rax,%rax,1)
mov    %ecx,%r14d
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     1560 <_mkpath+0x3e0>
movb   $0x0,(%rax)
mov    0x2c5d(%rip),%rax
mov    (%rax),%edx
mov    0x2c5c(%rip),%rax
or     (%rax),%edx
mov    0x2c63(%rip),%rax
or     (%rax),%edx
mov    %r12d,%edi
mov    %rbx,%rsi
call   1070 <mkdirat@plt>
test   %eax,%eax
je     1401 <_mkpath+0x281>
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
lea    0x1(%r14),%ecx
cmp    $0x80,%eax
je     1350 <_mkpath+0x1d0>
cmp    $0x82,%eax
jne    155d <_mkpath+0x3dd>
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
test   %rax,%rax
je     1460 <_mkpath+0x2e0>
mov    0x2c21(%rip),%rax
mov    (%rax),%r13d
jmp    1560 <_mkpath+0x3e0>
xor    %r13d,%r13d
mov    0x18(%rsp),%rbp
test   %rbp,%rbp
je     1567 <_mkpath+0x3e7>
mov    %r15,%rdi
call   1090 <strdup@plt>
mov    %rax,0x0(%rbp)
jmp    1567 <_mkpath+0x3e7>
lea    0x20(%rsp),%rdx
movl   $0x0,0x14(%rsp)
mov    %r12d,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
cmp    $0xffffffffffffffff,%rax
je     1560 <_mkpath+0x3e0>
mov    0x20(%rsp),%eax
mov    0x2b90(%rip),%rcx
mov    0x2b91(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    %eax,%ecx
not    %ecx
test   %ecx,%edx
je     147a <_mkpath+0x2fa>
or     %eax,%edx
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %edx,0x14(%rsp)
xor    %ecx,%ecx
call   1080 <fchmodat@plt>
cmp    $0xffffffff,%eax
jne    147a <_mkpath+0x2fa>
jmp    1560 <_mkpath+0x3e0>
mov    0x10(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     13d0 <_mkpath+0x250>
movl   $0x0,0x14(%rsp)
mov    0x18(%rsp),%rax
test   %rax,%rax
je     1494 <_mkpath+0x314>
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
cmp    $0x2,%r14d
jae    1507 <_mkpath+0x387>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <mkdirat@plt>
xor    %r13d,%r13d
cmp    $0xffffffff,%eax
jne    1560 <_mkpath+0x3e0>
mov    0x2ae6(%rip),%r14
mov    (%r14),%r13d
cmp    $0x82,%r13d
jne    1567 <_mkpath+0x3e7>
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
call   10a0 <fstatat@plt>
test   %rax,%rax
je     1595 <_mkpath+0x415>
mov    $0x82,%r13d
jmp    1567 <_mkpath+0x3e7>
mov    0x2aac(%rip),%rax
mov    (%rax),%eax
cmp    $0x82,%eax
jne    155d <_mkpath+0x3dd>
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
jbe    149a <_mkpath+0x31a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movb   $0x2f,(%rbx,%rax,1)
mov    0x2ab6(%rip),%rax
mov    (%rax),%edx
mov    0x2ab5(%rip),%rax
or     (%rax),%edx
mov    0x2abc(%rip),%rax
or     (%rax),%edx
mov    %r12d,%edi
mov    %rbx,%rsi
call   1070 <mkdirat@plt>
cmp    $0xffffffff,%eax
je     14ed <_mkpath+0x36d>
cmpl   $0x0,0x14(%rsp)
je     14fd <_mkpath+0x37d>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    0x14(%rsp),%edx
xor    %ecx,%ecx
call   1080 <fchmodat@plt>
cmp    $0xffffffff,%eax
jne    14fd <_mkpath+0x37d>
jmp    1560 <_mkpath+0x3e0>
mov    %eax,%r13d
mov    0x2a39(%rip),%r14
mov    0x4(%rsp),%ebp
mov    0x8(%rsp),%r15
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,(%r14)
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%edi
call   1050 <S_ISDIR@plt>
mov    $0x82,%r13d
test   %rax,%rax
mov    0x4(%rsp),%ebp
mov    0x8(%rsp),%r15
jne    1570 <_mkpath+0x3f0>
mov    0x2a3f(%rip),%rax
mov    (%rax),%r13d
jmp    1570 <_mkpath+0x3f0>

LLVM IR (-O0):
%struct.stat = type { i32 }
@errno = global i32 0
@ENOTDIR = global i32 0
@EIO = global i32 0
@ENOMEM = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
define i32 @_mkpath(i32 %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.stat
%19 = alloca %struct.stat
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%20 = load i32, i32* @errno
store i32 %20, i32* %17
%21 = load i32, i32* %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = call i32 @mkdirat(i32 %21, i8* %22, i32 %23)
%25 = icmp eq i32 0, %24
br i1 %25, label %26, label %34
26: ; preds = %4
%27 = load i8**, i8*** %8
%28 = icmp ne i8** %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8*, i8** %6
%31 = call i8* @strdup(i8* %30)
%32 = load i8**, i8*** %8
store i8* %31, i8** %32
br label %33
33: ; preds = %29, %26
br label %287
34: ; preds = %4
%35 = load i32, i32* @errno
switch i32 %35, label %55 [
i32 128, label %36
i32 130, label %37
i32 129, label %54
]
36: ; preds = %34
br label %57
37: ; preds = %34
%38 = load i32, i32* %5
%39 = load i8*, i8** %6
%40 = call i64 @fstatat(i32 %38, i8* %39, %struct.stat* %18, i32 0)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%44 = load i32, i32* %43
%45 = call i64 @S_ISDIR(i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 130, i32* %16
br label %50
48: ; preds = %42
%49 = load i32, i32* @ENOTDIR
store i32 %49, i32* %16
br label %50
50: ; preds = %48, %47
br label %53
51: ; preds = %37
%52 = load i32, i32* @EIO
store i32 %52, i32* %16
br label %53
53: ; preds = %51, %50
br label %287
54: ; preds = %34
store i32 130, i32* %16
br label %287
55: ; preds = %34
%56 = load i32, i32* @errno
store i32 %56, i32* %16
br label %287
57: ; preds = %36
%58 = load i8*, i8** %6
%59 = call i8* @strdup(i8* %58)
store i8* %59, i8** %9
%60 = load i8*, i8** %9
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = load i32, i32* @ENOMEM
store i32 %63, i32* %16
br label %287
64: ; preds = %57
%65 = load i8*, i8** %9
%66 = load i8*, i8** %9
%67 = call i32 @strlen(i8* %66)
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %65, i64 %68
%70 = getelementptr inbounds i8, i8* %69, i64 -1
store i8* %70, i8** %11
store i8* %70, i8** %13
br label %71
71: ; preds = %104, %64
%72 = load i8*, i8** %11
store i8* %72, i8** %12
%73 = load i8*, i8** %11
%74 = getelementptr inbounds i8, i8* %73, i64 -1
%75 = load i8*, i8** %9
%76 = icmp ugt i8* %74, %75
br i1 %76, label %77, label %91
77: ; preds = %71
%78 = load i8*, i8** %11
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 46
br i1 %81, label %82, label %91
82: ; preds = %77
%83 = load i8*, i8** %11
%84 = getelementptr inbounds i8, i8* %83, i64 -1
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 47
br i1 %87, label %88, label %91
88: ; preds = %82
%89 = load i8*, i8** %11
%90 = getelementptr inbounds i8, i8* %89, i64 -2
store i8* %90, i8** %11
br label %91
91: ; preds = %88, %82, %77, %71
%92 = load i8*, i8** %11
%93 = load i8*, i8** %9
%94 = icmp ugt i8* %92, %93
br i1 %94, label %95, label %103
95: ; preds = %91
%96 = load i8*, i8** %11
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 47
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = load i8*, i8** %11
%102 = getelementptr inbounds i8, i8* %101, i32 -1
store i8* %102, i8** %11
br label %103
103: ; preds = %100, %95, %91
br label %104
104: ; preds = %103
%105 = load i8*, i8** %11
%106 = load i8*, i8** %12
%107 = icmp ult i8* %105, %106
br i1 %107, label %71, label %108
108: ; preds = %104
%109 = load i8*, i8** %11
%110 = load i8*, i8** %13
%111 = icmp ult i8* %109, %110
br i1 %111, label %112, label %122
112: ; preds = %108
%113 = load i8*, i8** %11
%114 = getelementptr inbounds i8, i8* %113, i64 1
store i8 0, i8* %114
%115 = load i8*, i8** %9
%116 = call i8* @strdup(i8* %115)
store i8* %116, i8** %10
store i8* %116, i8** %6
%117 = load i8*, i8** %10
%118 = icmp eq i8* %117, null
br i1 %118, label %119, label %121
119: ; preds = %112
%120 = load i32, i32* @ENOMEM
store i32 %120, i32* %16
br label %287
121: ; preds = %112
br label %122
122: ; preds = %121, %108
%123 = load i32, i32* %5
%124 = load i8*, i8** %6
%125 = load i32, i32* %7
%126 = call i32 @mkdirat(i32 %123, i8* %124, i32 %125)
%127 = icmp eq i32 0, %126
br i1 %127, label %128, label %136
128: ; preds = %122
%129 = load i8**, i8*** %8
%130 = icmp ne i8** %129, null
br i1 %130, label %131, label %135
131: ; preds = %128
%132 = load i8*, i8** %6
%133 = call i8* @strdup(i8* %132)
%134 = load i8**, i8*** %8
store i8* %133, i8** %134
br label %135
135: ; preds = %131, %128
br label %287
136: ; preds = %122
br label %137
137: ; preds = %136, %225
%138 = load i8*, i8** %9
%139 = call i8* @strrchr(i8* %138, i8 signext 47)
store i8* %139, i8** %11
%140 = load i8*, i8** %11
%141 = icmp ne i8* %140, null
br i1 %141, label %143, label %142
142: ; preds = %137
store i32 128, i32* %16
br label %287
143: ; preds = %137
%144 = load i8*, i8** %11
store i8 0, i8* %144
%145 = load i32, i32* %14
%146 = add i32 %145, 1
store i32 %146, i32* %14
%147 = load i32, i32* %5
%148 = load i8*, i8** %9
%149 = load i32, i32* @S_IRWXU
%150 = load i32, i32* @S_IRWXG
%151 = or i32 %149, %150
%152 = load i32, i32* @S_IRWXO
%153 = or i32 %151, %152
%154 = call i32 @mkdirat(i32 %147, i8* %148, i32 %153)
%155 = icmp eq i32 0, %154
br i1 %155, label %156, label %195
156: ; preds = %143
%157 = load i32, i32* %5
%158 = load i8*, i8** %9
%159 = call i64 @fstatat(i32 %157, i8* %158, %struct.stat* %19, i32 0)
%160 = icmp eq i64 -1, %159
br i1 %160, label %161, label %162
161: ; preds = %156
store i32 128, i32* %16
br label %287
162: ; preds = %156
%163 = getelementptr inbounds %struct.stat, %struct.stat* %19, i32 0, i32 0
%164 = load i32, i32* %163
%165 = load i32, i32* @S_IWUSR
%166 = load i32, i32* @S_IXUSR
%167 = or i32 %165, %166
%168 = and i32 %164, %167
%169 = load i32, i32* @S_IWUSR
%170 = load i32, i32* @S_IXUSR
%171 = or i32 %169, %170
%172 = icmp ne i32 %168, %171
br i1 %172, label %173, label %187
173: ; preds = %162
%174 = getelementptr inbounds %struct.stat, %struct.stat* %19, i32 0, i32 0
%175 = load i32, i32* %174
%176 = load i32, i32* @S_IWUSR
%177 = or i32 %175, %176
%178 = load i32, i32* @S_IXUSR
%179 = or i32 %177, %178
store i32 %179, i32* %15
%180 = load i32, i32* %5
%181 = load i8*, i8** %9
%182 = load i32, i32* %15
%183 = call i32 @fchmodat(i32 %180, i8* %181, i32 %182, i32 0)
%184 = icmp eq i32 -1, %183
br i1 %184, label %185, label %186
185: ; preds = %173
store i32 128, i32* %16
br label %287
186: ; preds = %173
br label %187
187: ; preds = %186, %162
%188 = load i8**, i8*** %8
%189 = icmp ne i8** %188, null
br i1 %189, label %190, label %194
190: ; preds = %187
%191 = load i8*, i8** %9
%192 = call i8* @strdup(i8* %191)
%193 = load i8**, i8*** %8
store i8* %192, i8** %193
br label %194
194: ; preds = %190, %187
br label %226
195: ; preds = %143
%196 = load i32, i32* @errno
%197 = icmp eq i32 %196, 130
br i1 %197, label %198, label %218
198: ; preds = %195
%199 = load i32, i32* %5
%200 = load i8*, i8** %9
%201 = call i64 @fstatat(i32 %199, i8* %200, %struct.stat* %18, i32 0)
%202 = icmp eq i64 %201, 0
br i1 %202, label %203, label %216
203: ; preds = %198
%204 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%205 = load i32, i32* %204
%206 = call i64 @S_ISDIR(i32 %205)
%207 = icmp ne i64 %206, 0
br i1 %207, label %208, label %216
208: ; preds = %203
%209 = load i8**, i8*** %8
%210 = icmp ne i8** %209, null
br i1 %210, label %211, label %215
211: ; preds = %208
%212 = load i8*, i8** %9
%213 = call i8* @strdup(i8* %212)
%214 = load i8**, i8*** %8
store i8* %213, i8** %214
br label %215
215: ; preds = %211, %208
br label %226
216: ; preds = %203, %198
%217 = load i32, i32* @ENOTDIR
store i32 %217, i32* %16
br label %287
218: ; preds = %195
%219 = load i32, i32* @errno
%220 = icmp ne i32 %219, 128
br i1 %220, label %221, label %223
221: ; preds = %218
%222 = load i32, i32* @errno
store i32 %222, i32* %16
br label %287
223: ; preds = %218
br label %224
224: ; preds = %223
br label %225
225: ; preds = %224
br label %137
226: ; preds = %215, %194
br label %227
227: ; preds = %262, %248, %226
%228 = load i32, i32* %14
%229 = icmp ugt i32 %228, 1
br i1 %229, label %230, label %263
230: ; preds = %227
%231 = load i8*, i8** %9
%232 = call i8* @strrchr(i8* %231, i8 signext 0)
store i8* %232, i8** %11
%233 = load i8*, i8** %11
store i8 47, i8* %233
%234 = load i32, i32* %14
%235 = add i32 %234, -1
store i32 %235, i32* %14
%236 = load i32, i32* %5
%237 = load i8*, i8** %9
%238 = load i32, i32* @S_IRWXU
%239 = load i32, i32* @S_IRWXG
%240 = or i32 %238, %239
%241 = load i32, i32* @S_IRWXO
%242 = or i32 %240, %241
%243 = call i32 @mkdirat(i32 %236, i8* %237, i32 %242)
%244 = icmp eq i32 -1, %243
br i1 %244, label %245, label %251
245: ; preds = %230
%246 = load i32, i32* @errno
%247 = icmp eq i32 %246, 130
br i1 %247, label %248, label %249
248: ; preds = %245
br label %227
249: ; preds = %245
%250 = load i32, i32* @errno
store i32 %250, i32* %16
br label %287
251: ; preds = %230
%252 = load i32, i32* %15
%253 = icmp ne i32 %252, 0
br i1 %253, label %254, label %262
254: ; preds = %251
%255 = load i32, i32* %5
%256 = load i8*, i8** %9
%257 = load i32, i32* %15
%258 = call i32 @fchmodat(i32 %255, i8* %256, i32 %257, i32 0)
%259 = icmp eq i32 -1, %258
br i1 %259, label %260, label %261
260: ; preds = %254
store i32 128, i32* %16
br label %287
261: ; preds = %254
br label %262
262: ; preds = %261, %251
br label %227
263: ; preds = %227
%264 = load i32, i32* %5
%265 = load i8*, i8** %6
%266 = load i32, i32* %7
%267 = call i32 @mkdirat(i32 %264, i8* %265, i32 %266)
%268 = icmp eq i32 -1, %267
br i1 %268, label %269, label %286
269: ; preds = %263
%270 = load i32, i32* @errno
store i32 %270, i32* %16
%271 = load i32, i32* @errno
%272 = icmp eq i32 %271, 130
br i1 %272, label %273, label %285
273: ; preds = %269
%274 = load i32, i32* %5
%275 = load i8*, i8** %6
%276 = call i64 @fstatat(i32 %274, i8* %275, %struct.stat* %18, i32 0)
%277 = icmp eq i64 %276, 0
br i1 %277, label %278, label %285
278: ; preds = %273
%279 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%280 = load i32, i32* %279
%281 = call i64 @S_ISDIR(i32 %280)
%282 = icmp ne i64 %281, 0
br i1 %282, label %285, label %283
283: ; preds = %278
%284 = load i32, i32* @ENOTDIR
store i32 %284, i32* %16
br label %285
285: ; preds = %283, %278, %273, %269
br label %286
286: ; preds = %285, %263
br label %287
287: ; preds = %286, %260, %249, %221, %216, %185, %161, %142, %135, %119, %62, %55, %54, %53, %33
%288 = load i8*, i8** %9
%289 = call i32 @free(i8* %288)
%290 = load i8*, i8** %10
%291 = call i32 @free(i8* %290)
%292 = load i32, i32* %17
store i32 %292, i32* @errno
%293 = load i32, i32* %16
ret i32 %293
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@errno = global i32 0
@ENOTDIR = global i32 0
@EIO = global i32 0
@ENOMEM = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
define i32 @_mkpath(i32 %0, i8* %1, i32 %2, i8** writeonly %3) {
%5 = alloca %struct.stat
%6 = alloca %struct.stat
%7 = load i32, i32* @errno
%8 = bitcast %struct.stat* %5 to i8*
%9 = tail call i32 @mkdirat(i32 %0, i8* %1, i32 %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = icmp eq i8** %3, null
br i1 %12, label %176, label %13
13: ; preds = %11
%14 = tail call i8* @strdup(i8* %1)
store i8* %14, i8** %3
br label %176
15: ; preds = %4
%16 = load i32, i32* @errno
switch i32 %16, label %29 [
i32 128, label %30
i32 130, label %17
i32 129, label %176
]
17: ; preds = %15
%18 = call i64 @fstatat(i32 %0, i8* %1, %struct.stat* %5, i32 0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%22 = load i32, i32* %21
%23 = call i64 @S_ISDIR(i32 %22)
%24 = icmp eq i64 %23, 0
%25 = load i32, i32* @ENOTDIR
%26 = select i1 %24, i32 %25, i32 130
br label %176
27: ; preds = %17
%28 = load i32, i32* @EIO
br label %176
29: ; preds = %15
br label %176
30: ; preds = %15
%31 = tail call i8* @strdup(i8* %1)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* @ENOMEM
br label %176
35: ; preds = %30
%36 = tail call i32 @strlen(i8* %31)
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %31, i64 %37
br label %39
39: ; preds = %61, %35
%40 = phi i64 [ -1, %35 ], [ %62, %61 ]
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 -1
%43 = icmp ugt i8* %42, %31
br i1 %43, label %44, label %52
44: ; preds = %39
%45 = load i8, i8* %41
%46 = icmp eq i8 %45, 46
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i8, i8* %42
%49 = icmp eq i8 %48, 47
%50 = add nsw i64 %40, -2
%51 = select i1 %49, i64 %50, i64 %40
br label %52
52: ; preds = %47, %44, %39
%53 = phi i64 [ %40, %44 ], [ %40, %39 ], [ %51, %47 ]
%54 = getelementptr inbounds i8, i8* %38, i64 %53
%55 = icmp ugt i8* %54, %31
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8, i8* %54
%58 = icmp eq i8 %57, 47
%59 = sext i1 %58 to i64
%60 = add nsw i64 %53, %59
br label %61
61: ; preds = %56, %52
%62 = phi i64 [ %53, %52 ], [ %60, %56 ]
%63 = icmp slt i64 %62, %40
br i1 %63, label %39, label %64
64: ; preds = %61
%65 = icmp slt i64 %62, -1
br i1 %65, label %66, label %73
66: ; preds = %64
%67 = getelementptr inbounds i8, i8* %38, i64 %62
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8 0, i8* %68
%69 = tail call i8* @strdup(i8* %31)
%70 = icmp eq i8* %69, null
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = load i32, i32* @ENOMEM
br label %176
73: ; preds = %66, %64
%74 = phi i8* [ %69, %66 ], [ null, %64 ]
%75 = phi i8* [ %69, %66 ], [ %1, %64 ]
%76 = tail call i32 @mkdirat(i32 %0, i8* %75, i32 %2)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = icmp eq i8** %3, null
br i1 %79, label %176, label %80
80: ; preds = %78
%81 = tail call i8* @strdup(i8* %75)
store i8* %81, i8** %3
br label %176
82: ; preds = %73, %118
%83 = phi i32 [ %87, %118 ], [ 0, %73 ]
%84 = tail call i8* @strrchr(i8* dereferenceable(1) %31, i8 signext 47)
%85 = icmp eq i8* %84, null
br i1 %85, label %176, label %86
86: ; preds = %82
store i8 0, i8* %84
%87 = add i32 %83, 1
%88 = load i32, i32* @S_IRWXU
%89 = load i32, i32* @S_IRWXG
%90 = or i32 %89, %88
%91 = load i32, i32* @S_IRWXO
%92 = or i32 %90, %91
%93 = tail call i32 @mkdirat(i32 %0, i8* %31, i32 %92)
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %118
95: ; preds = %86
%96 = bitcast %struct.stat* %6 to i8*
%97 = call i64 @fstatat(i32 %0, i8* %31, %struct.stat* %6, i32 0)
%98 = icmp eq i64 %97, -1
br i1 %98, label %117, label %99
99: ; preds = %95
%100 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%101 = load i32, i32* %100
%102 = load i32, i32* @S_IWUSR
%103 = load i32, i32* @S_IXUSR
%104 = or i32 %103, %102
%105 = and i32 %104, %101
%106 = icmp eq i32 %105, %104
br i1 %106, label %111, label %107
107: ; preds = %99
%108 = or i32 %104, %101
%109 = call i32 @fchmodat(i32 %0, i8* %31, i32 %108, i32 0)
%110 = icmp eq i32 %109, -1
br i1 %110, label %117, label %111
111: ; preds = %107, %99
%112 = phi i32 [ %108, %107 ], [ 0, %99 ]
%113 = icmp eq i8** %3, null
br i1 %113, label %116, label %114
114: ; preds = %111
%115 = call i8* @strdup(i8* %31)
store i8* %115, i8** %3
br label %116
116: ; preds = %114, %111
br label %134
117: ; preds = %107, %95
br label %176
118: ; preds = %86
%119 = load i32, i32* @errno
switch i32 %119, label %176 [
i32 130, label %120
i32 128, label %82
]
120: ; preds = %118
%121 = call i64 @fstatat(i32 %0, i8* %31, %struct.stat* %5, i32 0)
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %132
123: ; preds = %120
%124 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%125 = load i32, i32* %124
%126 = call i64 @S_ISDIR(i32 %125)
%127 = icmp eq i64 %126, 0
br i1 %127, label %132, label %128
128: ; preds = %123
%129 = icmp eq i8** %3, null
br i1 %129, label %134, label %130
130: ; preds = %128
%131 = call i8* @strdup(i8* %31)
store i8* %131, i8** %3
br label %134
132: ; preds = %123, %120
%133 = load i32, i32* @ENOTDIR
br label %176
134: ; preds = %116, %128, %130
%135 = phi i32 [ 0, %130 ], [ 0, %128 ], [ %112, %116 ]
%136 = icmp ugt i32 %87, 1
br i1 %136, label %137, label %160
137: ; preds = %134
%138 = icmp eq i32 %135, 0
br label %139
139: ; preds = %137, %158
%140 = phi i32 [ %87, %137 ], [ %143, %158 ]
%141 = call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %31)
%142 = getelementptr i8, i8* %31, i64 %141
store i8 47, i8* %142
%143 = add i32 %140, -1
%144 = load i32, i32* @S_IRWXU
%145 = load i32, i32* @S_IRWXG
%146 = or i32 %145, %144
%147 = load i32, i32* @S_IRWXO
%148 = or i32 %146, %147
%149 = call i32 @mkdirat(i32 %0, i8* %31, i32 %148)
%150 = icmp eq i32 %149, -1
br i1 %150, label %151, label %154
151: ; preds = %139
%152 = load i32, i32* @errno
%153 = icmp eq i32 %152, 130
br i1 %153, label %158, label %176
154: ; preds = %139
br i1 %138, label %158, label %155
155: ; preds = %154
%156 = call i32 @fchmodat(i32 %0, i8* %31, i32 %135, i32 0)
%157 = icmp eq i32 %156, -1
br i1 %157, label %176, label %158
158: ; preds = %154, %155, %151
%159 = icmp ugt i32 %143, 1
br i1 %159, label %139, label %160
160: ; preds = %158, %134
%161 = call i32 @mkdirat(i32 %0, i8* %75, i32 %2)
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %176
163: ; preds = %160
%164 = load i32, i32* @errno
%165 = icmp eq i32 %164, 130
br i1 %165, label %166, label %176
166: ; preds = %163
%167 = call i64 @fstatat(i32 %0, i8* %75, %struct.stat* %5, i32 0)
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %176
169: ; preds = %166
%170 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%171 = load i32, i32* %170
%172 = call i64 @S_ISDIR(i32 %171)
%173 = icmp eq i64 %172, 0
%174 = load i32, i32* @ENOTDIR
%175 = select i1 %173, i32 %174, i32 130
br label %176
176: ; preds = %82, %118, %151, %155, %29, %33, %71, %132, %13, %11, %27, %80, %78, %163, %166, %160, %15, %169, %20, %117
%177 = phi i8* [ null, %13 ], [ null, %11 ], [ null, %29 ], [ null, %27 ], [ null, %33 ], [ null, %71 ], [ %74, %80 ], [ %74, %78 ], [ %74, %117 ], [ %74, %166 ], [ %74, %163 ], [ %74, %160 ], [ %74, %132 ], [ null, %15 ], [ %74, %169 ], [ null, %20 ], [ %74, %155 ], [ %74, %151 ], [ %74, %118 ], [ %74, %82 ]
%178 = phi i8* [ null, %13 ], [ null, %11 ], [ null, %29 ], [ null, %27 ], [ null, %33 ], [ %31, %71 ], [ %31, %80 ], [ %31, %78 ], [ %31, %117 ], [ %31, %166 ], [ %31, %163 ], [ %31, %160 ], [ %31, %132 ], [ null, %15 ], [ %31, %169 ], [ null, %20 ], [ %31, %155 ], [ %31, %151 ], [ %31, %118 ], [ %31, %82 ]
%179 = phi i32 [ 0, %13 ], [ 0, %11 ], [ %16, %29 ], [ %28, %27 ], [ %34, %33 ], [ %72, %71 ], [ 0, %80 ], [ 0, %78 ], [ 128, %117 ], [ 130, %166 ], [ %164, %163 ], [ 0, %160 ], [ %133, %132 ], [ 130, %15 ], [ %175, %169 ], [ %26, %20 ], [ %152, %151 ], [ 128, %155 ], [ 128, %82 ], [ %119, %118 ]
%180 = call i32 @free(i8* %178)
%181 = call i32 @free(i8* %177)
store i32 %7, i32* @errno
ret i32 %179
}