#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*/ mkdir(char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strrchr(char *, char);
int /*<<< orphan*/ tracet(int, char *, char const *);
extern void createdir(const char *path) {
  char buff[1024], *p;
  tracet(3, "createdir: path=%s\n", path);
  strcpy(buff, path);
  if (!(p = strrchr(buff, '/'))) {
    return;
  }
  *p = '\0';
  mkdir(buff, 0777);
}


x86 assembly (clang, -O0):
<createdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
mov    $0x3,%edi
lea    0xea1(%rip),%rsi
call   1060 <tracet@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    119b <createdir+0x5b>
jmp    11b6 <createdir+0x76>
mov    -0x418(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createdir>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
lea    0xeac(%rip),%rsi
mov    $0x3,%edi
mov    %rbx,%rdx
call   1060 <tracet@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1191 <createdir+0x51>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"createdir: path=%s\0A\00"
define void @createdir(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @tracet(i32 3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = call i8* @strrchr(i8* %10, i8 signext 47)
store i8* %11, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %1
br label %18
14: ; preds = %1
%15 = load i8*, i8** %4
store i8 0, i8* %15
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 @mkdir(i8* %16, i32 511)
br label %18
18: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"createdir: path=%s\0A\00"
define void @createdir(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @tracet(i32 3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @strcpy(i8* %3, i8* %0)
%6 = call i8* @strrchr(i8* %3, i8 signext 47)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
store i8 0, i8* %6
%9 = call i32 @mkdir(i8* %3, i32 511)
br label %10
10: ; preds = %1, %8
ret void
}