#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*/ fileExist(char *);
int /*<<< orphan*/ makePath(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
void createPathForFile(char *FileName) {
  char Buffer[4 * 1024];
  char *Q = 0, *P = FileName;
  while (*P) {
    if (*P == '/')
      Q = P;
    ++P;
  }
  if (Q) {
    int N = Q - FileName;
    memcpy(Buffer, FileName, N);
    Buffer[N] = 0;
    if (!fileExist(Buffer))
      makePath(Buffer);
  }
}


x86 assembly (clang, -O0):
<createPathForFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x1018(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1020(%rbp)
mov    -0x1020(%rbp),%rax
cmpb   $0x0,(%rax)
je     119d <createPathForFile+0x6d>
mov    -0x1020(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1186 <createPathForFile+0x56>
mov    -0x1020(%rbp),%rax
mov    %rax,-0x1018(%rbp)
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
jmp    1155 <createPathForFile+0x25>
cmpq   $0x0,-0x1018(%rbp)
je     120a <createPathForFile+0xda>
mov    -0x1018(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1024(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1024(%rbp),%edx
call   1040 <memcpy@plt>
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x1010(%rbp,%rax,1)
lea    -0x1010(%rbp),%rdi
call   1050 <fileExist@plt>
cmp    $0x0,%eax
jne    1205 <createPathForFile+0xd5>
lea    -0x1010(%rbp),%rdi
call   1030 <makePath@plt>
jmp    120a <createPathForFile+0xda>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPathForFile>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdi,%rsi
xor    %ebx,%ebx
mov    %rdi,%rax
jmp    1157 <createPathForFile+0x27>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rbx
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2f,%cl
je     1150 <createPathForFile+0x20>
test   %cl,%cl
jne    1153 <createPathForFile+0x23>
test   %rbx,%rbx
je     1193 <createPathForFile+0x63>
sub    %rsi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1050 <fileExist@plt>
test   %eax,%eax
jne    1193 <createPathForFile+0x63>
mov    %rsp,%rdi
call   1030 <makePath@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @createPathForFile(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %9, %1
%5 = phi i8* [ %0, %1 ], [ %11, %9 ]
%6 = phi i8* [ null, %1 ], [ %10, %9 ]
%7 = load i8, i8* %5
switch i8 %7, label %9 [
i8 0, label %12
i8 47, label %8
]
8: ; preds = %4
br label %9
9: ; preds = %4, %8
%10 = phi i8* [ %5, %8 ], [ %6, %4 ]
%11 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
12: ; preds = %4
%13 = icmp eq i8* %6, null
br i1 %13, label %27, label %14
14: ; preds = %12
%15 = ptrtoint i8* %6 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = call i32 @memcpy(i8* %3, i8* %0, i32 %18)
%20 = shl i64 %17, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @fileExist(i8* %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = call i32 @makePath(i8* %3)
br label %27
27: ; preds = %14, %25, %12
ret void
}