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


x86 assembly (clang, -O0):
<_createdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
je     11c0 <_createdir+0x60>
lea    -0x110(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x118(%rbp)
movl   $0x1,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x118(%rbp),%eax
jge    128c <_createdir+0x12c>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    1273 <_createdir+0x113>
movslq -0x114(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
call   1070 <access@plt>
cmp    $0x0,%rax
je     1264 <_createdir+0x104>
lea    -0x110(%rbp),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    125f <_createdir+0xff>
lea    0xdb4(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1293 <_createdir+0x133>
jmp    1264 <_createdir+0x104>
movslq -0x114(%rbp),%rax
movb   $0x2f,-0x110(%rbp,%rax,1)
2f
jmp    1278 <_createdir+0x118>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11dc <_createdir+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_createdir>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     119a <_createdir+0x3a>
lea    0xe6e(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strcat@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
jl     120d <_createdir+0xad>
mov    %ecx,%r15d
mov    $0x1,%ebx
mov    %rsp,%r14
jmp    11cd <_createdir+0x6d>
nopl   0x0(%rax,%rax,1)
movb   $0x2f,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     120b <_createdir+0xab>
cmpb   $0x2f,(%rsp,%rbx,1)
jne    11c4 <_createdir+0x64>
movb   $0x0,(%rsp,%rbx,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <access@plt>
test   %rax,%rax
je     11c0 <_createdir+0x60>
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    11c0 <_createdir+0x60>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%eax
jmp    120d <_createdir+0xad>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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