#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*/ _createdir(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int createdir(char *file) {
  char pathname[255];
  memset(pathname, 0, 255);
  strcpy(pathname, file);
  int i;
  for (i = strlen(file); i > 0; i--) {
    if ('/' == pathname[i]) {
      pathname[i + 1] = '\0';
      break;
    }
  }
  _createdir(pathname);
  return 0;
}


x86 assembly (clang, -O0):
<createdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jle    11db <createdir+0x9b>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%ecx
ff
mov    $0x2f,%eax
cmp    %ecx,%eax
jne    11c2 <createdir+0x82>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
jmp    11db <createdir+0x9b>
jmp    11c7 <createdir+0x87>
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
jmp    1181 <createdir+0x41>
lea    -0x110(%rbp),%rdi
call   1060 <_createdir@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createdir>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    119b <createdir+0x5b>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ecx
cmpb   $0x2f,(%rsp,%rcx,1)
je     1194 <createdir+0x54>
lea    -0x1(%rax),%ecx
cmp    $0x1,%eax
mov    %ecx,%eax
jg     1180 <createdir+0x40>
jmp    119b <createdir+0x5b>
add    $0x1,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1060 <_createdir@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @createdir(i8* %0) {
%2 = alloca i8*
%3 = alloca [255 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 255)
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
br label %12
12: ; preds = %28, %1
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 47, %20
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
br label %31
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %12
31: ; preds = %22, %12
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%33 = call i32 @_createdir(i8* %32)
ret i32 0
}

LLVM IR (-O2):
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 @memset(i8* %3, i32 0, i32 255)
%5 = call i32 @strcpy(i8* %3, i8* %0)
%6 = call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %1, %18
%9 = phi i32 [ %19, %18 ], [ %6, %1 ]
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = add nuw nsw i32 %9, 1
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
br label %21
18: ; preds = %8
%19 = add nsw i32 %9, -1
%20 = icmp sgt i32 %9, 1
br i1 %20, label %8, label %21
21: ; preds = %18, %1, %14
%22 = call i32 @_createdir(i8* %3)
ret i32 0
}