#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 /*<<< orphan*/ file_exists(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, '/'))) {
    if (P[1] == '.' && P[2] == '/') {
      strcpy(P, P + 2);
    }
    *P = 0;
    if (!file_exists(T))
      mkdir(T, 0775);
    *P = '/';
  }
  if (!file_exists(T))
    mkdir(T, 0775);
}


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   1060 <strchr@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     1211 <makePath+0xd1>
mov    -0x418(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    11d2 <makePath+0x92>
mov    -0x418(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x2f,%eax
jne    11d2 <makePath+0x92>
mov    -0x418(%rbp),%rdi
mov    -0x418(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
mov    -0x418(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
call   1040 <file_exists@plt>
cmp    $0x0,%eax
jne    1202 <makePath+0xc2>
lea    -0x410(%rbp),%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
mov    -0x418(%rbp),%rax
movb   $0x2f,(%rax)
jmp    116d <makePath+0x2d>
lea    -0x410(%rbp),%rdi
call   1040 <file_exists@plt>
cmp    $0x0,%eax
jne    1237 <makePath+0xf7>
lea    -0x410(%rbp),%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makePath>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0x1(%rsp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11df <makePath+0x9f>
mov    %rax,%rbx
mov    %rsp,%r14
jmp    11ab <makePath+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbx),%r15
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1040 <file_exists@plt>
test   %eax,%eax
je     11d0 <makePath+0x90>
movb   $0x2f,(%rbx)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11df <makePath+0x9f>
cmpb   $0x2e,0x1(%rbx)
jne    1180 <makePath+0x40>
cmpb   $0x2f,0x2(%rbx)
jne    1180 <makePath+0x40>
lea    0x2(%rbx),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    1180 <makePath+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
jmp    1193 <makePath+0x53>
mov    %rsp,%rdi
call   1040 <file_exists@plt>
test   %eax,%eax
jne    11f8 <makePath+0xb8>
mov    %rsp,%rdi
mov    $0x1fd,%esi
call   1050 <mkdir@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
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 = %39, %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 %41
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 46
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 47
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = call i32 @strcpy(i8* %27, i8* %29)
br label %31
31: ; preds = %26, %20, %14
%32 = load i8*, i8** %4
store i8 0, i8* %32
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%34 = call i32 @file_exists(i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %31
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%38 = call i32 @mkdir(i8* %37, i32 509)
br label %39
39: ; preds = %36, %31
%40 = load i8*, i8** %4
store i8 47, i8* %40
br label %9
41: ; preds = %9
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%43 = call i32 @file_exists(i8* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %41
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%47 = call i32 @mkdir(i8* %46, i32 509)
br label %48
48: ; preds = %45, %41
ret void
}

LLVM IR (-O2):
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 %27, label %8
8: ; preds = %1, %24
%9 = phi i8* [ %25, %24 ], [ %6, %1 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 46
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %9, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @strcpy(i8* %9, i8* %14)
br label %19
19: ; preds = %17, %13, %8
store i8 0, i8* %9
%20 = call i32 @file_exists(i8* %3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @mkdir(i8* %3, i32 509)
br label %24
24: ; preds = %22, %19
store i8 47, i8* %9
%25 = call i8* @strchr(i8* %10, i8 signext 47)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %8
27: ; preds = %24, %1
%28 = call i32 @file_exists(i8* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @mkdir(i8* %3, i32 509)
br label %32
32: ; preds = %30, %27
ret void
}