#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int S_IROTH;
int S_IRWXG;
int S_IRWXU;
int S_IXOTH;
char *alloca(scalar_t__);
int /*<<< orphan*/ big_file_set_error_message2(char *, char *, int, char *,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ path_join(char *, char const *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ strlen(char const *);
int big_file_mksubdir_r(const char *pathname, const char *subdir) {
  char *subdirname = alloca(strlen(subdir) + 10);
  char *mydirname = alloca(strlen(subdir) + strlen(pathname) + 10);
  strcpy(subdirname, subdir);
  char *p = subdirname;
  for (p = subdirname; *p; p++) {
    if (*p != '/')
      continue;
    *p = 0;
    path_join(mydirname, pathname, subdirname);
    mkdir(mydirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
    *p = '/';
  }
  path_join(mydirname, pathname, subdirname);
  mkdir(mydirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  struct stat buf;
  {
    if (0 != stat(mydirname, &buf)) {
      big_file_set_error_message2(
          "Failed to create directory structure at `%s' (%s)",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/marcel-sl/fastpm/refs/heads/master/"
          "bigfile/bigfile.c",
          200, mydirname, strerror(errno));
      goto ex_mkdir;
    };
  };
  return 0;
ex_mkdir:
  return -1;
}


x86 assembly (clang, -O0):
<big_file_mksubdir_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0xa,%rdi
call   1070 <alloca@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
add    $0xa,%rdi
call   1070 <alloca@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     126f <big_file_mksubdir_r+0xef>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1212 <big_file_mksubdir_r+0x92>
jmp    125e <big_file_mksubdir_r+0xde>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <path_join@plt>
mov    -0x28(%rbp),%rdi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
mov    0x2d9a(%rip),%rax
or     (%rax),%esi
mov    0x2d79(%rip),%rax
or     (%rax),%esi
mov    0x2d90(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    -0x30(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11f0 <big_file_mksubdir_r+0x70>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <path_join@plt>
mov    -0x28(%rbp),%rdi
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
mov    0x2d44(%rip),%rax
or     (%rax),%esi
mov    0x2d23(%rip),%rax
or     (%rax),%esi
mov    0x2d3a(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1080 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1302 <big_file_mksubdir_r+0x182>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x48(%rbp),%rcx
mov    %eax,%r8d
lea    0xd14(%rip),%rdi
lea    0xd3f(%rip),%rsi
mov    $0xc8,%edx
call   1090 <big_file_set_error_message2@plt>
jmp    130e <big_file_mksubdir_r+0x18e>
movl   $0x0,-0x4(%rbp)
jmp    1315 <big_file_mksubdir_r+0x195>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<big_file_mksubdir_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
lea    0xa(%rax),%rdi
call   1070 <alloca@plt>
mov    %rax,%r13
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0xa,%rdi
call   1070 <alloca@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    0x2dfe(%rip),%r12
mov    0x2ddf(%rip),%rbp
mov    %r13,%r15
jmp    122b <big_file_mksubdir_r+0xab>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%r15)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1060 <path_join@plt>
mov    (%r12),%esi
mov    0x2ddb(%rip),%rax
or     (%rax),%esi
or     0x0(%rbp),%esi
mov    0x2dc7(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
movb   $0x2f,(%r15)
add    $0x1,%r15
movzbl (%r15),%eax
cmp    $0x2f,%al
je     11f0 <big_file_mksubdir_r+0x70>
test   %al,%al
jne    1227 <big_file_mksubdir_r+0xa7>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1060 <path_join@plt>
mov    (%r12),%esi
mov    0x2d98(%rip),%rax
or     (%rax),%esi
or     0x0(%rbp),%esi
mov    0x2d84(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
test   %rax,%rax
je     12a9 <big_file_mksubdir_r+0x129>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd75(%rip),%rdi
lea    0xda0(%rip),%rsi
mov    $0xc8,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1090 <big_file_set_error_message2@plt>
mov    $0xffffffff,%eax
jmp    12ab <big_file_mksubdir_r+0x12b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [50 x i8] c"Failed to create directory structure at `%s' (%s)\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/marcel-sl/fastpm/refs/heads/master/bigfile/bigfile.c\00"
@errno = global i32 0
define i32 @big_file_mksubdir_r(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.stat
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = add nsw i64 %11, 10
%13 = call i8* @alloca(i64 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %5
%15 = call i64 @strlen(i8* %14)
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %15, %17
%19 = add nsw i64 %18, 10
%20 = call i8* @alloca(i64 %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = load i8*, i8** %5
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = load i8*, i8** %6
store i8* %24, i8** %8
%25 = load i8*, i8** %6
store i8* %25, i8** %8
br label %26
26: ; preds = %52, %2
%27 = load i8*, i8** %8
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %55
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 47
br i1 %34, label %35, label %36
35: ; preds = %30
br label %52
36: ; preds = %30
%37 = load i8*, i8** %8
store i8 0, i8* %37
%38 = load i8*, i8** %7
%39 = load i8*, i8** %4
%40 = load i8*, i8** %6
%41 = call i32 @path_join(i8* %38, i8* %39, i8* %40)
%42 = load i8*, i8** %7
%43 = load i32, i32* @S_IRWXU
%44 = load i32, i32* @S_IRWXG
%45 = or i32 %43, %44
%46 = load i32, i32* @S_IROTH
%47 = or i32 %45, %46
%48 = load i32, i32* @S_IXOTH
%49 = or i32 %47, %48
%50 = call i32 @mkdir(i8* %42, i32 %49)
%51 = load i8*, i8** %8
store i8 47, i8* %51
br label %52
52: ; preds = %36, %35
%53 = load i8*, i8** %8
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %8
br label %26
55: ; preds = %26
%56 = load i8*, i8** %7
%57 = load i8*, i8** %4
%58 = load i8*, i8** %6
%59 = call i32 @path_join(i8* %56, i8* %57, i8* %58)
%60 = load i8*, i8** %7
%61 = load i32, i32* @S_IRWXU
%62 = load i32, i32* @S_IRWXG
%63 = or i32 %61, %62
%64 = load i32, i32* @S_IROTH
%65 = or i32 %63, %64
%66 = load i32, i32* @S_IXOTH
%67 = or i32 %65, %66
%68 = call i32 @mkdir(i8* %60, i32 %67)
%69 = load i8*, i8** %7
%70 = call i64 @stat(i8* %69, %struct.stat* %9)
%71 = icmp ne i64 0, %70
br i1 %71, label %72, label %77
72: ; preds = %55
%73 = load i8*, i8** %7
%74 = load i32, i32* @errno
%75 = call i32 @strerror(i32 %74)
%76 = call i32 @big_file_set_error_message2(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 200, i8* %73, i32 %75)
br label %78
77: ; preds = %55
store i32 0, i32* %3
br label %79
78: ; preds = %72
store i32 -1, i32* %3
br label %79
79: ; preds = %78, %77
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [50 x i8] c"Failed to create directory structure at `%s' (%s)\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/marcel-sl/fastpm/refs/heads/master/bigfile/bigfile.c\00"
@errno = global i32 0
define i32 @big_file_mksubdir_r(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add nsw i64 %4, 10
%6 = tail call i8* @alloca(i64 %5)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = add i64 %7, 10
%10 = add i64 %9, %8
%11 = tail call i8* @alloca(i64 %10)
%12 = tail call i32 @strcpy(i8* %6, i8* %1)
br label %13
13: ; preds = %26, %2
%14 = phi i8* [ %6, %2 ], [ %27, %26 ]
%15 = load i8, i8* %14
switch i8 %15, label %26 [
i8 0, label %28
i8 47, label %16
]
16: ; preds = %13
store i8 0, i8* %14
%17 = tail call i32 @path_join(i8* %11, i8* %0, i8* %6)
%18 = load i32, i32* @S_IRWXU
%19 = load i32, i32* @S_IRWXG
%20 = or i32 %19, %18
%21 = load i32, i32* @S_IROTH
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IXOTH
%24 = or i32 %22, %23
%25 = tail call i32 @mkdir(i8* %11, i32 %24)
store i8 47, i8* %14
br label %26
26: ; preds = %13, %16
%27 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
28: ; preds = %13
%29 = tail call i32 @path_join(i8* %11, i8* %0, i8* %6)
%30 = load i32, i32* @S_IRWXU
%31 = load i32, i32* @S_IRWXG
%32 = or i32 %31, %30
%33 = load i32, i32* @S_IROTH
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IXOTH
%36 = or i32 %34, %35
%37 = tail call i32 @mkdir(i8* %11, i32 %36)
%38 = bitcast %struct.stat* %3 to i8*
%39 = call i64 @stat(i8* %11, %struct.stat* %3)
%40 = icmp eq i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %28
%42 = load i32, i32* @errno
%43 = call i32 @strerror(i32 %42)
%44 = call i32 @big_file_set_error_message2(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 200, i8* %11, i32 %43)
br label %45
45: ; preds = %28, %41
%46 = phi i32 [ -1, %41 ], [ 0, %28 ]
ret i32 %46
}