#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__ EEXIST;
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ isns_assert_failed(char *, char *, int);
scalar_t__ mkdir(char const *, int);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
char *strdup(char const *);
char *strrchr(char *, char);
int isns_mkdir_recursive(const char *pathname) {
  const char *orig_pathname = pathname;
  char *squirrel[64];
  char *copy = NULL, *s;
  int ns = 0;
  if (!pathname || !strcmp(pathname, "."))
    return 0;
  while (1) {
    if (mkdir(pathname, 0755) >= 0) {
      if (ns == 0)
        break;
      *squirrel[--ns] = '/';
      continue;
    }
    if (errno == EEXIST)
      goto good;
    if (errno != ENOENT)
      goto bad;
    if (copy == NULL) {
      copy = strdup(pathname);
      pathname = copy;
    }
    s = strrchr(copy, '/');
    while (s > copy && s[-1] == '/')
      --s;
    *s = '\0';
    do {
      if (!(ns < 64))
        isns_assert_failed("ns < 64",
                           "/scratch/repos/new/home/jordi_armengol_estape/"
                           "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                           "Akasurde/open-iscsi/refs/heads/master/util.c",
                           229);
    } while (0);
    squirrel[ns++] = s;
    if (s == copy)
      goto bad;
  }
good:
  if (copy)
    free(copy);
  errno = 0;
  return 0;
bad:
  if (copy)
    free(copy);
  perror(orig_pathname);
  return -1;
}


x86 assembly (clang, -O0):
<isns_mkdir_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x228(%rbp)
movl   $0x0,-0x234(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c0 <isns_mkdir_recursive+0x50>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11cc <isns_mkdir_recursive+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    13cf <isns_mkdir_recursive+0x25f>
jmp    11d1 <isns_mkdir_recursive+0x61>
mov    -0x10(%rbp),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
jl     121c <isns_mkdir_recursive+0xac>
cmpl   $0x0,-0x234(%rbp)
jne    11fb <isns_mkdir_recursive+0x8b>
jmp    136c <isns_mkdir_recursive+0x1fc>
mov    -0x234(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x234(%rbp)
cltq
mov    -0x220(%rbp,%rax,8),%rax
ff
movb   $0x2f,(%rax)
jmp    11d1 <isns_mkdir_recursive+0x61>
mov    0x2db5(%rip),%rax
mov    (%rax),%rax
mov    0x2db3(%rip),%rcx
cmp    (%rcx),%rax
jne    123b <isns_mkdir_recursive+0xcb>
jmp    1371 <isns_mkdir_recursive+0x201>
mov    0x2d96(%rip),%rax
mov    (%rax),%rax
mov    0x2d7c(%rip),%rcx
cmp    (%rcx),%rax
je     125a <isns_mkdir_recursive+0xea>
jmp    13a5 <isns_mkdir_recursive+0x235>
cmpq   $0x0,-0x228(%rbp)
jne    1283 <isns_mkdir_recursive+0x113>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x228(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rcx
xor    %eax,%eax
cmp    -0x228(%rbp),%rcx
mov    %al,-0x235(%rbp)
jbe    12ce <isns_mkdir_recursive+0x15e>
mov    -0x230(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x235(%rbp)
mov    -0x235(%rbp),%al
test   $0x1,%al
jne    12e1 <isns_mkdir_recursive+0x171>
jmp    12f8 <isns_mkdir_recursive+0x188>
mov    -0x230(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x230(%rbp)
jmp    129b <isns_mkdir_recursive+0x12b>
mov    -0x230(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x40,-0x234(%rbp)
jl     1327 <isns_mkdir_recursive+0x1b7>
lea    0xcec(%rip),%rdi
lea    0xced(%rip),%rsi
mov    $0xe5,%edx
call   1080 <isns_assert_failed@plt>
jmp    132c <isns_mkdir_recursive+0x1bc>
mov    -0x230(%rbp),%rcx
mov    -0x234(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x234(%rbp)
cltq
mov    %rcx,-0x220(%rbp,%rax,8)
ff
mov    -0x230(%rbp),%rax
cmp    -0x228(%rbp),%rax
jne    1367 <isns_mkdir_recursive+0x1f7>
jmp    13a5 <isns_mkdir_recursive+0x235>
jmp    11d1 <isns_mkdir_recursive+0x61>
jmp    1371 <isns_mkdir_recursive+0x201>
cmpq   $0x0,-0x228(%rbp)
je     138b <isns_mkdir_recursive+0x21b>
mov    -0x228(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c46(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    13cf <isns_mkdir_recursive+0x25f>
cmpq   $0x0,-0x228(%rbp)
je     13bf <isns_mkdir_recursive+0x24f>
mov    -0x228(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isns_mkdir_recursive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     12b5 <isns_mkdir_recursive+0x145>
mov    %rdi,%r14
lea    0xe6a(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12b5 <isns_mkdir_recursive+0x145>
xor    %ebx,%ebx
mov    0x2e2c(%rip),%rbp
mov    %r14,%r13
xor    %r12d,%r12d
jmp    11d4 <isns_mkdir_recursive+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %r12d,%rax
add    $0x1,%r12d
mov    %r15,(%rsp,%rax,8)
cmp    %rbx,%r15
je     12c9 <isns_mkdir_recursive+0x159>
mov    %r13,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
js     1213 <isns_mkdir_recursive+0xa3>
movslq %r12d,%r12
nopl   0x0(%rax)
sub    $0x1,%r12
jb     129e <isns_mkdir_recursive+0x12e>
mov    (%rsp,%r12,8),%rax
movb   $0x2f,(%rax)
mov    %r13,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
jns    11f0 <isns_mkdir_recursive+0x80>
mov    0x0(%rbp),%rax
mov    0x2dc2(%rip),%rcx
cmp    (%rcx),%rax
je     129e <isns_mkdir_recursive+0x12e>
mov    0x2d9e(%rip),%rcx
cmp    (%rcx),%rax
jne    12c9 <isns_mkdir_recursive+0x159>
test   %rbx,%rbx
jne    1246 <isns_mkdir_recursive+0xd6>
mov    %r13,%rdi
call   1090 <strdup@plt>
mov    %rax,%r13
mov    %rax,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%r15
cmp    %rbx,%rax
jbe    1273 <isns_mkdir_recursive+0x103>
lea    -0x1(%r15),%rax
cmpb   $0x2f,-0x1(%r15)
je     1260 <isns_mkdir_recursive+0xf0>
movb   $0x0,(%r15)
cmp    $0x40,%r12d
jl     11c0 <isns_mkdir_recursive+0x50>
lea    0xd7a(%rip),%rdi
lea    0xd7b(%rip),%rsi
mov    $0xe5,%edx
call   1080 <isns_assert_failed@plt>
jmp    11c0 <isns_mkdir_recursive+0x50>
test   %rbx,%rbx
je     12ab <isns_mkdir_recursive+0x13b>
mov    %rbx,%rdi
call   1030 <free@plt>
movq   $0x0,0x0(%rbp)
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %rbx,%rbx
je     12d6 <isns_mkdir_recursive+0x166>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebx
jmp    12b5 <isns_mkdir_recursive+0x145>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@errno = global i64 0
@EEXIST = global i64 0
@ENOENT = global i64 0
@.str.1 = [8 x i8] c"ns < 64\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Akasurde/open-iscsi/refs/heads/master/util.c\00"
define i32 @isns_mkdir_recursive(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [64 x i8*]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
store i8* %9, i8** %4
store i8* null, i8** %6
store i32 0, i32* %8
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12, %1
store i32 0, i32* %2
br label %103
17: ; preds = %12
br label %18
18: ; preds = %17, %26, %85
%19 = load i8*, i8** %3
%20 = call i64 @mkdir(i8* %19, i32 493)
%21 = icmp sge i64 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
br label %86
26: ; preds = %22
%27 = load i32, i32* %8
%28 = add nsw i32 %27, -1
store i32 %28, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [64 x i8*], [64 x i8*]* %5, i64 0, i64 %29
%31 = load i8*, i8** %30
store i8 47, i8* %31
br label %18
32: ; preds = %18
%33 = load i64, i64* @errno
%34 = load i64, i64* @EEXIST
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
br label %87
37: ; preds = %32
%38 = load i64, i64* @errno
%39 = load i64, i64* @ENOENT
%40 = icmp ne i64 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %37
br label %94
42: ; preds = %37
%43 = load i8*, i8** %6
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i8*, i8** %3
%47 = call i8* @strdup(i8* %46)
store i8* %47, i8** %6
%48 = load i8*, i8** %6
store i8* %48, i8** %3
br label %49
49: ; preds = %45, %42
%50 = load i8*, i8** %6
%51 = call i8* @strrchr(i8* %50, i8 signext 47)
store i8* %51, i8** %7
br label %52
52: ; preds = %64, %49
%53 = load i8*, i8** %7
%54 = load i8*, i8** %6
%55 = icmp ugt i8* %53, %54
br i1 %55, label %56, label %62
56: ; preds = %52
%57 = load i8*, i8** %7
%58 = getelementptr inbounds i8, i8* %57, i64 -1
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 47
br label %62
62: ; preds = %56, %52
%63 = phi i1 [ false, %52 ], [ %61, %56 ]
br i1 %63, label %64, label %67
64: ; preds = %62
%65 = load i8*, i8** %7
%66 = getelementptr inbounds i8, i8* %65, i32 -1
store i8* %66, i8** %7
br label %52
67: ; preds = %62
%68 = load i8*, i8** %7
store i8 0, i8* %68
br label %69
69: ; preds = %67
%70 = load i32, i32* %8
%71 = icmp slt i32 %70, 64
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = call i32 @isns_assert_failed(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 229)
br label %74
74: ; preds = %72, %69
br label %75
75: ; preds = %74
%76 = load i8*, i8** %7
%77 = load i32, i32* %8
%78 = add nsw i32 %77, 1
store i32 %78, i32* %8
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds [64 x i8*], [64 x i8*]* %5, i64 0, i64 %79
store i8* %76, i8** %80
%81 = load i8*, i8** %7
%82 = load i8*, i8** %6
%83 = icmp eq i8* %81, %82
br i1 %83, label %84, label %85
84: ; preds = %75
br label %94
85: ; preds = %75
br label %18
86: ; preds = %25
br label %87
87: ; preds = %86, %36
%88 = load i8*, i8** %6
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i8*, i8** %6
%92 = call i32 @free(i8* %91)
br label %93
93: ; preds = %90, %87
store i64 0, i64* @errno
store i32 0, i32* %2
br label %103
94: ; preds = %84, %41
%95 = load i8*, i8** %6
%96 = icmp ne i8* %95, null
br i1 %96, label %97, label %100
97: ; preds = %94
%98 = load i8*, i8** %6
%99 = call i32 @free(i8* %98)
br label %100
100: ; preds = %97, %94
%101 = load i8*, i8** %4
%102 = call i32 @perror(i8* %101)
store i32 -1, i32* %2
br label %103
103: ; preds = %100, %93, %16
%104 = load i32, i32* %2
ret i32 %104
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@errno = global i64 0
@EEXIST = global i64 0
@ENOENT = global i64 0
@.str.1 = [8 x i8] c"ns < 64\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Akasurde/open-iscsi/refs/heads/master/util.c\00"
define i32 @isns_mkdir_recursive(i8* %0) {
%2 = alloca [64 x i8*]
%3 = bitcast [64 x i8*]* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %71, label %5
5: ; preds = %1
%6 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %71, label %8
8: ; preds = %5, %54
%9 = phi i8* [ %40, %54 ], [ %0, %5 ]
%10 = phi i8* [ %41, %54 ], [ null, %5 ]
%11 = phi i32 [ %55, %54 ], [ 0, %5 ]
%12 = tail call i64 @mkdir(i8* %9, i32 493)
%13 = icmp sgt i64 %12, -1
br i1 %13, label %14, label %27
14: ; preds = %8
%15 = sext i32 %11 to i64
br label %16
16: ; preds = %14, %19
%17 = phi i64 [ %15, %14 ], [ %20, %19 ]
%18 = icmp eq i64 %17, 0
br i1 %18, label %59, label %19
19: ; preds = %16
%20 = add nsw i64 %17, -1
%21 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 %20
%22 = load i8*, i8** %21
store i8 47, i8* %22
%23 = tail call i64 @mkdir(i8* %9, i32 493)
%24 = icmp sgt i64 %23, -1
br i1 %24, label %16, label %25
25: ; preds = %19
%26 = trunc i64 %20 to i32
br label %27
27: ; preds = %25, %8
%28 = phi i32 [ %11, %8 ], [ %26, %25 ]
%29 = load i64, i64* @errno
%30 = load i64, i64* @EEXIST
%31 = icmp eq i64 %29, %30
br i1 %31, label %59, label %32
32: ; preds = %27
%33 = load i64, i64* @ENOENT
%34 = icmp eq i64 %29, %33
br i1 %34, label %35, label %64
35: ; preds = %32
%36 = icmp eq i8* %10, null
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = tail call i8* @strdup(i8* %9)
br label %39
39: ; preds = %37, %35
%40 = phi i8* [ %38, %37 ], [ %9, %35 ]
%41 = phi i8* [ %38, %37 ], [ %10, %35 ]
%42 = tail call i8* @strrchr(i8* dereferenceable(1) %41, i8 signext 47)
br label %43
43: ; preds = %46, %39
%44 = phi i8* [ %42, %39 ], [ %47, %46 ]
%45 = icmp ugt i8* %44, %41
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = getelementptr inbounds i8, i8* %44, i64 -1
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 47
br i1 %49, label %43, label %50
50: ; preds = %43, %46
store i8 0, i8* %44
%51 = icmp slt i32 %28, 64
br i1 %51, label %54, label %52
52: ; preds = %50
%53 = tail call i32 @isns_assert_failed(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 229)
br label %54
54: ; preds = %52, %50
%55 = add nsw i32 %28, 1
%56 = sext i32 %28 to i64
%57 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 %56
store i8* %44, i8** %57
%58 = icmp eq i8* %44, %41
br i1 %58, label %64, label %8
59: ; preds = %27, %16
%60 = icmp eq i8* %10, null
br i1 %60, label %63, label %61
61: ; preds = %59
%62 = tail call i32 @free(i8* %10)
br label %63
63: ; preds = %61, %59
store i64 0, i64* @errno
br label %71
64: ; preds = %54, %32
%65 = phi i8* [ %10, %32 ], [ %41, %54 ]
%66 = icmp eq i8* %65, null
br i1 %66, label %69, label %67
67: ; preds = %64
%68 = tail call i32 @free(i8* %65)
br label %69
69: ; preds = %67, %64
%70 = tail call i32 @perror(i8* %0)
br label %71
71: ; preds = %1, %5, %69, %63
%72 = phi i32 [ 0, %63 ], [ -1, %69 ], [ 0, %5 ], [ 0, %1 ]
ret i32 %72
}