#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 */

/* Variables and functions */
int MakeDir(char const *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int RecursiveMakeDir(const char *inPath, int mode) {
  char pathCopy[256];
  char *thePathTraverser = pathCopy;
  int theErr;
  char oldChar;
  if (strlen(inPath) > 255)
    return -1;
  strcpy(pathCopy, inPath);
  if (*thePathTraverser == '/')
    thePathTraverser++;
  while (*thePathTraverser != '\0') {
    if (*thePathTraverser == '/') {
      oldChar = *thePathTraverser;
      *thePathTraverser = '\0';
      theErr = MakeDir(pathCopy, mode);
      *thePathTraverser = oldChar;
      if (theErr)
        return theErr;
    }
    thePathTraverser++;
  }
  return MakeDir(inPath, mode);
}


x86 assembly (clang, -O0):
<RecursiveMakeDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xff,%eax
jle    1170 <RecursiveMakeDir+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    1253 <RecursiveMakeDir+0x123>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11a5 <RecursiveMakeDir+0x75>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    11aa <RecursiveMakeDir+0x7a>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1244 <RecursiveMakeDir+0x114>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    122d <RecursiveMakeDir+0xfd>
mov    -0x128(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x12d(%rbp)
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <MakeDir@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x12d(%rbp),%cl
mov    -0x128(%rbp),%rax
mov    %cl,(%rax)
cmpl   $0x0,-0x12c(%rbp)
je     1228 <RecursiveMakeDir+0xf8>
mov    -0x12c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1253 <RecursiveMakeDir+0x123>
jmp    122d <RecursiveMakeDir+0xfd>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    11aa <RecursiveMakeDir+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <MakeDir@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecursiveMakeDir>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0xff,%ecx
jg     11ad <RecursiveMakeDir+0x7d>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
cmpb   $0x2f,(%rsp)
lea    0x1(%rsp),%rbx
cmovne %r15,%rbx
jmp    1198 <RecursiveMakeDir+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%rbx)
mov    %r15,%rdi
mov    %ebp,%esi
call   1050 <MakeDir@plt>
movb   $0x2f,(%rbx)
test   %eax,%eax
jne    11ad <RecursiveMakeDir+0x7d>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     1180 <RecursiveMakeDir+0x50>
test   %al,%al
jne    1194 <RecursiveMakeDir+0x64>
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <MakeDir@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @RecursiveMakeDir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8* %10, i8** %7
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 255
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %58
15: ; preds = %2
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %7
br label %26
26: ; preds = %23, %15
br label %27
27: ; preds = %51, %26
%28 = load i8*, i8** %7
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %54
32: ; preds = %27
%33 = load i8*, i8** %7
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 47
br i1 %36, label %37, label %51
37: ; preds = %32
%38 = load i8*, i8** %7
%39 = load i8, i8* %38
store i8 %39, i8* %9
%40 = load i8*, i8** %7
store i8 0, i8* %40
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%42 = load i32, i32* %5
%43 = call i32 @MakeDir(i8* %41, i32 %42)
store i32 %43, i32* %8
%44 = load i8, i8* %9
%45 = load i8*, i8** %7
store i8 %44, i8* %45
%46 = load i32, i32* %8
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %37
%49 = load i32, i32* %8
store i32 %49, i32* %3
br label %58
50: ; preds = %37
br label %51
51: ; preds = %50, %32
%52 = load i8*, i8** %7
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %7
br label %27
54: ; preds = %27
%55 = load i8*, i8** %4
%56 = load i32, i32* %5
%57 = call i32 @MakeDir(i8* %55, i32 %56)
store i32 %57, i32* %3
br label %58
58: ; preds = %54, %48, %14
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
define i32 @RecursiveMakeDir(i8* %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 255
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = call i32 @strcpy(i8* %4, i8* %0)
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 47
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
%12 = select i1 %10, i8* %11, i8* %4
br label %13
13: ; preds = %19, %7
%14 = phi i8* [ %12, %7 ], [ %20, %19 ]
%15 = load i8, i8* %14
switch i8 %15, label %19 [
i8 0, label %21
i8 47, label %16
]
16: ; preds = %13
store i8 0, i8* %14
%17 = call i32 @MakeDir(i8* %4, i32 %1)
store i8 47, i8* %14
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13, %16
%20 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
21: ; preds = %13
%22 = call i32 @MakeDir(i8* %0, i32 %1)
br label %23
23: ; preds = %16, %2, %21
%24 = phi i32 [ %22, %21 ], [ -1, %2 ], [ %17, %16 ]
ret i32 %24
}