#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 */
typedef char u_char;

/* Variables and functions */
int /*<<< orphan*/ memcmp(char *, char *, int);
int /*<<< orphan*/ mkdir(char *, int);
char *strchr(char *, char);
u_char *create_dir(u_char *name) {
  u_char *stri, *strf;
  if (!memcmp(name, "..\\", 3))
    name += 3;
  stri = name;
  while ((strf = strchr(stri, '\\'))) {
    *strf = 0;
    stri = strf + 1;
    mkdir(name, 0755);
    *strf = '/';
  }
  return (name);
}


x86 assembly (clang, -O0):
<create_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%eax
jne    1166 <create_dir+0x36>
mov    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11b7 <create_dir+0x87>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
mov    -0x18(%rbp),%rax
movb   $0x2f,(%rax)
jmp    116e <create_dir+0x3e>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_dir>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,2),%r14
add    %rbx,%r14
mov    %r14,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     119c <create_dir+0x6c>
mov    %rax,%rbx
nopl   0x0(%rax)
movb   $0x0,(%rbx)
lea    0x1(%rbx),%r15
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
movb   $0x2f,(%rbx)
mov    %r15,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <create_dir+0x40>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"..\\\00"
define i8* @create_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @memcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 3
store i8* %10, i8** %2
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %2
store i8* %12, i8** %3
br label %13
13: ; preds = %17, %11
%14 = load i8*, i8** %3
%15 = call i8* @strchr(i8* %14, i8 signext 92)
store i8* %15, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i8*, i8** %4
store i8 0, i8* %18
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %3
%21 = load i8*, i8** %2
%22 = call i32 @mkdir(i8* %21, i32 493)
%23 = load i8*, i8** %4
store i8 47, i8* %23
br label %13
24: ; preds = %13
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [4 x i8] c"..\\\00"
define i8* @create_dir(i8* %0) {
%2 = tail call i32 @memcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i64 3, i64 0
%5 = getelementptr i8, i8* %0, i64 %4
%6 = tail call i8* @strchr(i8* dereferenceable(1) %5, i8 signext 92)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %1, %8
%9 = phi i8* [ %12, %8 ], [ %6, %1 ]
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i32 @mkdir(i8* %5, i32 493)
store i8 47, i8* %9
%12 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 92)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %8
14: ; preds = %8, %1
ret i8* %5
}