#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*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int mkdir(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
int create_dir(const char *sFullPath) {
  char DirName[1024];
  int i;
  int len;
  strcpy(DirName, sFullPath);
  len = strlen(DirName);
  if (len != 0) {
    if (DirName[len - 1] != '/')
      strcat(DirName, "/");
  }
  len = strlen(DirName);
  for (i = 1; i < len; i++) {
    if (DirName[i] == '/') {
      DirName[i] = 0;
      if (access(DirName, R_OK) != 0) {
        if (mkdir(DirName, 0755) == -1)
          return -1;
      }
      DirName[i] = '/';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x0,-0x418(%rbp)
je     11c2 <create_dir+0x72>
mov    -0x418(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
je     11bd <create_dir+0x6d>
lea    -0x410(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1070 <strcat@plt>
jmp    11c2 <create_dir+0x72>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x418(%rbp)
movl   $0x1,-0x414(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x418(%rbp),%eax
jge    1289 <create_dir+0x139>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    1270 <create_dir+0x120>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     1261 <create_dir+0x111>
lea    -0x410(%rbp),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    125c <create_dir+0x10c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1290 <create_dir+0x140>
jmp    1261 <create_dir+0x111>
movslq -0x414(%rbp),%rax
movb   $0x2f,-0x410(%rbp,%rax,1)
2f
jmp    1275 <create_dir+0x125>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11de <create_dir+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_dir>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     1191 <create_dir+0x41>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     1191 <create_dir+0x41>
lea    0xe77(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcat@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x2,%eax
jl     1200 <create_dir+0xb0>
mov    %eax,%ebp
mov    $0x1,%ebx
mov    0x2e31(%rip),%r12
mov    %rsp,%r15
jmp    11cd <create_dir+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1200 <create_dir+0xb0>
cmpb   $0x2f,(%rsp,%rbx,1)
jne    11c4 <create_dir+0x74>
movb   $0x0,(%rsp,%rbx,1)
mov    (%r12),%esi
mov    %r15,%rdi
call   1060 <access@plt>
test   %rax,%rax
je     11c0 <create_dir+0x70>
mov    %r15,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    11c0 <create_dir+0x70>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@R_OK = global i32 0
define i32 @create_dir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %1
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 47
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %22, %14
br label %26
26: ; preds = %25, %1
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %6
store i32 1, i32* %5
br label %29
29: ; preds = %59, %26
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %62
33: ; preds = %29
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 47
br i1 %39, label %40, label %58
40: ; preds = %33
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%45 = load i32, i32* @R_OK
%46 = call i64 @access(i8* %44, i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %40
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%50 = call i32 @mkdir(i8* %49, i32 493)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 -1, i32* %2
br label %63
53: ; preds = %48
br label %54
54: ; preds = %53, %40
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %56
store i8 47, i8* %57
br label %58
58: ; preds = %54, %33
br label %59
59: ; preds = %58
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %29
62: ; preds = %29
store i32 0, i32* %2
br label %63
63: ; preds = %62, %52
%64 = load i32, i32* %2
ret i32 %64
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@R_OK = global i32 0
define i32 @create_dir(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 = call i32 @strlen(i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = add nsw i32 %5, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 47
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %7, %13, %1
%16 = call i32 @strlen(i8* %3)
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %36
18: ; preds = %15
%19 = zext i32 %16 to i64
br label %20
20: ; preds = %18, %33
%21 = phi i64 [ 1, %18 ], [ %34, %33 ]
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 47
br i1 %24, label %25, label %33
25: ; preds = %20
store i8 0, i8* %22
%26 = load i32, i32* @R_OK
%27 = call i64 @access(i8* %3, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = call i32 @mkdir(i8* %3, i32 493)
%31 = icmp eq i32 %30, -1
br i1 %31, label %36, label %32
32: ; preds = %29, %25
store i8 47, i8* %22
br label %33
33: ; preds = %20, %32
%34 = add nuw nsw i64 %21, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %36, label %20
36: ; preds = %29, %33, %15
%37 = phi i32 [ 0, %15 ], [ 0, %33 ], [ -1, %29 ]
ret i32 %37
}