#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*/ abort();
int /*<<< orphan*/ mkdir(char *, int);
char *strdup(char const *);
void create_path(const char *path) {
  char *copy = strdup(path);
  char *ptr;
  if (!copy)
    abort();
  ptr = copy;
  while (*ptr) {
    if (*ptr == '/') {
      *ptr = 0;
      mkdir(copy, 0755);
      *ptr = '/';
    }
    ptr++;
  }
}


x86 assembly (clang, -O0):
<create_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115b <create_path+0x2b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ad <create_path+0x7d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    119c <create_path+0x6c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
mov    -0x18(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1163 <create_path+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_path>:
push   %r14
push   %rbx
push   %rax
call   1050 <strdup@plt>
test   %rax,%rax
je     117a <create_path+0x4a>
mov    %rax,%r14
mov    %rax,%rbx
jmp    1167 <create_path+0x37>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
movb   $0x2f,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     1150 <create_path+0x20>
test   %al,%al
jne    1163 <create_path+0x33>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @create_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %1
%12 = load i8*, i8** %3
store i8* %12, i8** %4
br label %13
13: ; preds = %27, %11
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %4
store i8 0, i8* %23
%24 = load i8*, i8** %3
%25 = call i32 @mkdir(i8* %24, i32 493)
%26 = load i8*, i8** %4
store i8 47, i8* %26
br label %27
27: ; preds = %22, %17
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %13
30: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @create_path(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %1, %11
%7 = phi i8* [ %12, %11 ], [ %2, %1 ]
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 0, label %13
i8 47, label %9
]
9: ; preds = %6
store i8 0, i8* %7
%10 = tail call i32 @mkdir(i8* %2, i32 493)
store i8 47, i8* %7
br label %11
11: ; preds = %6, %9
%12 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
13: ; preds = %6
ret void
}