#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*/ make_dir(char *, int);
char *strchr(char *, char);
void make_dirs(char *dir, int was_missing) {
  char *p;
  for (p = strchr(dir + (dir[0] == '/'), '/'); p; p = strchr(p + 1, '/')) {
    *p = '\0';
    make_dir(dir, was_missing);
    *p = '/';
  }
  make_dir(dir, was_missing);
}


x86 assembly (clang, -O0):
<make_dirs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
add    %rax,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1198 <make_dirs+0x78>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <make_dir@plt>
mov    -0x18(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
jmp    1158 <make_dirs+0x38>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <make_dir@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_dirs>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edi,%edi
cmpb   $0x2f,(%rbx)
sete   %dil
add    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117c <make_dirs+0x5c>
mov    %rax,%rbp
nopl   0x0(%rax,%rax,1)
movb   $0x0,0x0(%rbp)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <make_dir@plt>
movb   $0x2f,0x0(%rbp)
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1150 <make_dirs+0x30>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <make_dir@plt>

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

LLVM IR (-O2):
define void @make_dirs(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 47
%5 = zext i1 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i8* @strchr(i8* %6, i8 signext 47)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %2, %9
%10 = phi i8* [ %13, %9 ], [ %7, %2 ]
store i8 0, i8* %10
%11 = tail call i32 @make_dir(i8* %0, i32 %1)
store i8 47, i8* %10
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = tail call i8* @strchr(i8* %12, i8 signext 47)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %9
15: ; preds = %9, %2
%16 = tail call i32 @make_dir(i8* %0, i32 %1)
ret void
}