#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 S_IROTH;
int S_IRWXG;
int S_IRWXU;
int S_IXOTH;
int /*<<< orphan*/ fileExist(char *);
int /*<<< orphan*/ mkdir(char *, int);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
void makePath(char *Path) {
  char T[1024], *P;
  strcpy(T, Path);
  P = T;
  while ((P = strchr(P + 1, '/'))) {
    *P = 0;
    if (!fileExist(T))
      mkdir(T, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
    *P = '/';
  }
  if (!fileExist(T))
    mkdir(T, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}


x86 assembly (clang, -O0):
<makePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     11f1 <makePath+0xb1>
mov    -0x418(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
call   1060 <fileExist@plt>
cmp    $0x0,%eax
jne    11e2 <makePath+0xa2>
lea    -0x410(%rbp),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
mov    0x2e0f(%rip),%rax
or     (%rax),%esi
mov    0x2df6(%rip),%rax
or     (%rax),%esi
mov    0x2e05(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    -0x418(%rbp),%rax
movb   $0x2f,(%rax)
jmp    116d <makePath+0x2d>
lea    -0x410(%rbp),%rdi
call   1060 <fileExist@plt>
cmp    $0x0,%eax
jne    1236 <makePath+0xf6>
lea    -0x410(%rbp),%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
mov    0x2dbb(%rip),%rax
or     (%rax),%esi
mov    0x2da2(%rip),%rax
or     (%rax),%esi
mov    0x2db1(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makePath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0x1(%rsp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e3 <makePath+0xa3>
mov    %rax,%rbx
mov    %rsp,%r14
mov    0x2e6b(%rip),%r15
mov    0x2e54(%rip),%r12
mov    0x2e3d(%rip),%r13
mov    0x2e4e(%rip),%rbp
jmp    11bc <makePath+0x7c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,(%rbx)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11e3 <makePath+0xa3>
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1060 <fileExist@plt>
test   %eax,%eax
jne    11a0 <makePath+0x60>
mov    (%r12),%esi
or     (%r15),%esi
or     0x0(%r13),%esi
or     0x0(%rbp),%esi
mov    %r14,%rdi
call   1040 <mkdir@plt>
jmp    11a0 <makePath+0x60>
mov    %rsp,%rdi
call   1060 <fileExist@plt>
test   %eax,%eax
jne    121b <makePath+0xdb>
mov    0x2df2(%rip),%rax
mov    0x2ddb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dc0(%rip),%rax
or     (%rax),%esi
mov    0x2dcf(%rip),%rax
or     (%rax),%esi
mov    %rsp,%rdi
call   1040 <mkdir@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define void @makePath(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %5, i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %8, i8** %4
br label %9
9: ; preds = %29, %1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i8* @strchr(i8* %11, i8 signext 47)
store i8* %12, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i8*, i8** %4
store i8 0, i8* %15
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 @fileExist(i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %14
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = load i32, i32* @S_IRWXU
%22 = load i32, i32* @S_IRWXG
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IROTH
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IXOTH
%27 = or i32 %25, %26
%28 = call i32 @mkdir(i8* %20, i32 %27)
br label %29
29: ; preds = %19, %14
%30 = load i8*, i8** %4
store i8 47, i8* %30
br label %9
31: ; preds = %9
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%33 = call i32 @fileExist(i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %31
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%37 = load i32, i32* @S_IRWXU
%38 = load i32, i32* @S_IRWXG
%39 = or i32 %37, %38
%40 = load i32, i32* @S_IROTH
%41 = or i32 %39, %40
%42 = load i32, i32* @S_IXOTH
%43 = or i32 %41, %42
%44 = call i32 @mkdir(i8* %36, i32 %43)
br label %45
45: ; preds = %35, %31
ret void
}

LLVM IR (-O2):
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define void @makePath(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1
%6 = call i8* @strchr(i8* %5, i8 signext 47)
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %8
8: ; preds = %1, %21
%9 = phi i8* [ %23, %21 ], [ %6, %1 ]
store i8 0, i8* %9
%10 = call i32 @fileExist(i8* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32, i32* @S_IRWXU
%14 = load i32, i32* @S_IRWXG
%15 = or i32 %14, %13
%16 = load i32, i32* @S_IROTH
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IXOTH
%19 = or i32 %17, %18
%20 = call i32 @mkdir(i8* %3, i32 %19)
br label %21
21: ; preds = %12, %8
store i8 47, i8* %9
%22 = getelementptr inbounds i8, i8* %9, i64 1
%23 = call i8* @strchr(i8* %22, i8 signext 47)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %8
25: ; preds = %21, %1
%26 = call i32 @fileExist(i8* %3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* @S_IRWXU
%30 = load i32, i32* @S_IRWXG
%31 = or i32 %30, %29
%32 = load i32, i32* @S_IROTH
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IXOTH
%35 = or i32 %33, %34
%36 = call i32 @mkdir(i8* %3, i32 %35)
br label %37
37: ; preds = %28, %25
ret void
}