#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*/ F_OK;
int S_IROTH;
int S_IRWXG;
int S_IRWXU;
int S_IXOTH;
scalar_t__ access(unsigned char const *, int /*<<< orphan*/);
scalar_t__ mkdir(unsigned char const *, int);
int /*<<< orphan*/ perror(char *);
int dirinit(const unsigned char *path) {
  if (access(path, F_OK)) {
    if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
      perror("mkdir");
      return 0x80001101;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<dirinit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
je     11ac <dirinit+0x7c>
mov    -0x10(%rbp),%rdi
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
mov    0x2e6c(%rip),%rax
or     (%rax),%esi
mov    0x2e53(%rip),%rax
or     (%rax),%esi
mov    0x2e62(%rip),%rax
or     (%rax),%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11a7 <dirinit+0x77>
lea    0xe6a(%rip),%rdi
call   1050 <perror@plt>
movl   $0x80001101,-0x4(%rbp)
jmp    11b3 <dirinit+0x83>
jmp    11ac <dirinit+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirinit>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     117c <dirinit+0x4c>
mov    0x2e96(%rip),%rax
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e64(%rip),%rax
or     (%rax),%esi
mov    0x2e73(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1030 <mkdir@plt>
test   %rax,%rax
jne    1185 <dirinit+0x55>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe74(%rip),%rdi
call   1050 <perror@plt>
mov    $0x80001101,%ebp
jmp    117c <dirinit+0x4c>

LLVM IR (-O0):
@F_OK = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [6 x i8] c"mkdir\00"
define i32 @dirinit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i32, i32* @F_OK
%6 = call i64 @access(i8* %4, i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i32, i32* @S_IRWXU
%11 = load i32, i32* @S_IRWXG
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IROTH
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IXOTH
%16 = or i32 %14, %15
%17 = call i64 @mkdir(i8* %9, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %8
%20 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 -2147479295, i32* %2
br label %23
21: ; preds = %8
br label %22
22: ; preds = %21, %1
store i32 0, i32* %2
br label %23
23: ; preds = %22, %19
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@F_OK = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@.str = [6 x i8] c"mkdir\00"
define i32 @dirinit(i8* nocapture %0) {
%2 = load i32, i32* @F_OK
%3 = tail call i64 @access(i8* %0, i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = load i32, i32* @S_IRWXU
%7 = load i32, i32* @S_IRWXG
%8 = or i32 %7, %6
%9 = load i32, i32* @S_IROTH
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IXOTH
%12 = or i32 %10, %11
%13 = tail call i64 @mkdir(i8* %0, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %5
%16 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %1, %5, %15
%18 = phi i32 [ -2147479295, %15 ], [ 0, %5 ], [ 0, %1 ]
ret i32 %18
}