#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*/ R_OK;
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int mkdir(char const *, int);
int /*<<< orphan*/ printf(char *, char const *, char *);
char *strerror(int /*<<< orphan*/);
void makeDirectory(const char *name) {
  int result;
  if (access(name, R_OK)) {
    result = mkdir(name, 0x1ff);
    if (result)
      printf("cannot create dir '%s': %s\n", name, strerror(errno));
  }
}


x86 assembly (clang, -O0):
<makeDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0x0,%rax
je     11b1 <makeDirectory+0x71>
mov    -0x8(%rbp),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ac <makeDirectory+0x6c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
jmp    11b1 <makeDirectory+0x71>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeDirectory>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
test   %rax,%rax
je     1189 <makeDirectory+0x49>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %eax,%eax
je     1189 <makeDirectory+0x49>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
pop    %rbx
jmp    1040 <printf@plt>
pop    %rbx
ret

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

LLVM IR (-O2):
@R_OK = global i32 0
@.str = [28 x i8] c"cannot create dir '%s': %s\0A\00"
@errno = global i32 0
define void @makeDirectory(i8* %0) {
%2 = load i32, i32* @R_OK
%3 = tail call i64 @access(i8* %0, i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = tail call i32 @mkdir(i8* %0, i32 511)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %10)
br label %12
12: ; preds = %5, %8, %1
ret void
}