#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 */
scalar_t__ utilMkdir(char *);
int utilMkSubDirs(char *fullname, int baseoffset) {
  char *p = fullname + baseoffset;
  char c;
  while ((c = *p++)) {
    if (!(c == '/') && (*p == '/')) {
      *p = '\0';
      if (utilMkdir(fullname)) {
        *p = '/';
        return 1;
      }
      *p = '/';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<utilMkSubDirs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
cmp    $0x0,%al
je     11a0 <utilMkSubDirs+0x90>
movsbl -0x21(%rbp),%eax
cmp    $0x2f,%eax
je     119b <utilMkSubDirs+0x8b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    119b <utilMkSubDirs+0x8b>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <utilMkdir@plt>
cmp    $0x0,%rax
je     1194 <utilMkSubDirs+0x84>
mov    -0x20(%rbp),%rax
movb   $0x2f,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a7 <utilMkSubDirs+0x97>
mov    -0x20(%rbp),%rax
movb   $0x2f,(%rax)
jmp    112e <utilMkSubDirs+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utilMkSubDirs>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movslq %esi,%rax
lea    (%rax,%rdi,1),%rbx
add    $0x1,%rbx
jmp    1134 <utilMkSubDirs+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
cmp    $0x2f,%al
je     1130 <utilMkSubDirs+0x20>
test   %al,%al
je     115f <utilMkSubDirs+0x4f>
cmpb   $0x2f,(%rbx)
jne    1130 <utilMkSubDirs+0x20>
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1030 <utilMkdir@plt>
movb   $0x2f,(%rbx)
test   %rax,%rax
je     1130 <utilMkSubDirs+0x20>
mov    $0x1,%eax
jmp    1161 <utilMkSubDirs+0x51>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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