#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*/ die_errno(char *, char const *);
int dir_exists(char const *);
int mkdir(char const *, int);
void make_dir(const char *dirname) {
  int rc;
  rc = dir_exists(dirname);
  if (rc == 1)
    return;
  if (rc == -1)
    die_errno("error: opening `%s'", dirname);
  rc = mkdir(dirname, 0700);
  if (rc == -1)
    die_errno("error: creating directory `%s'", dirname);
}


x86 assembly (clang, -O0):
<make_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <dir_exists@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1157 <make_dir+0x27>
jmp    119c <make_dir+0x6c>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1171 <make_dir+0x41>
mov    -0x8(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1050 <die_errno@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    119c <make_dir+0x6c>
mov    -0x8(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1050 <die_errno@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_dir>:
push   %rbx
mov    %rdi,%rbx
call   1030 <dir_exists@plt>
cmp    $0x1,%eax
je     1164 <make_dir+0x34>
cmp    $0xffffffff,%eax
jne    1152 <make_dir+0x22>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
call   1050 <die_errno@plt>
mov    %rbx,%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
je     1166 <make_dir+0x36>
pop    %rbx
ret
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1050 <die_errno@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"error: opening `%s'\00"
@.str.1 = [31 x i8] c"error: creating directory `%s'\00"
define void @make_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @dir_exists(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %1
br label %23
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = call i32 @die_errno(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %9
%16 = load i8*, i8** %2
%17 = call i32 @mkdir(i8* %16, i32 448)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %2
%22 = call i32 @die_errno(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %8, %20, %15
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"error: opening `%s'\00"
@.str.1 = [31 x i8] c"error: creating directory `%s'\00"
define void @make_dir(i8* %0) {
%2 = tail call i32 @dir_exists(i8* %0)
switch i32 %2, label %5 [
i32 1, label %10
i32 -1, label %3
]
3: ; preds = %1
%4 = tail call i32 @die_errno(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %5
5: ; preds = %1, %3
%6 = tail call i32 @mkdir(i8* %0, i32 448)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @die_errno(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %5, %8, %1
ret void
}