#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 /*<<< orphan*/ S_IRWXU;
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ mkdir(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, char *);
char *strerror(int /*<<< orphan*/);
void makeDirOrFail(const char *path) {
  if (access(path, F_OK) && (mkdir(path, S_IRWXU))) {
    printf("Failed to create directory %s: %s\n", path, strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<makeDirOrFail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0x0,%rax
je     11c7 <makeDirOrFail+0x77>
mov    -0x8(%rbp),%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11c7 <makeDirOrFail+0x77>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x10(%rbp),%rsi
mov    %rax,%rdx
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeDirOrFail>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
test   %rax,%rax
je     117d <makeDirOrFail+0x2d>
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <mkdir@plt>
test   %rax,%rax
jne    117f <makeDirOrFail+0x2f>
pop    %rbx
ret
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@F_OK = global i32 0
@S_IRWXU = global i32 0
@.str = [35 x i8] c"Failed to create directory %s: %s\0A\00"
@errno = global i32 0
define void @makeDirOrFail(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i32, i32* @F_OK
%5 = call i64 @access(i8* %3, i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load i32, i32* @S_IRWXU
%10 = call i64 @mkdir(i8* %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
@F_OK = global i32 0
@S_IRWXU = global i32 0
@.str = [35 x i8] c"Failed to create directory %s: %s\0A\00"
@errno = global i32 0
define void @makeDirOrFail(i8* %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 %14, label %5
5: ; preds = %1
%6 = load i32, i32* @S_IRWXU
%7 = tail call i64 @mkdir(i8* %0, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %5, %1
ret void
}