#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 */
scalar_t__ EEXIST;
int /*<<< orphan*/ err(char *, char *, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ inf(char *, char *);
char *make_targetname(char *);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ strerror(scalar_t__);
int make_home_dir(void) {
  char *name;
  name = make_targetname("home");
  if (mkdir(name, 0700)) {
    if (errno == EEXIST)
      inf("portable home directory '%s' already exists - fine", name);
    else {
      err("error creating portable home directory '%s': %s", name,
          strerror(errno));
      free(name);
      return 1;
    }
  } else
    inf("portable home directory '%s' created", name);
  free(name);
  return 0;
}


x86 assembly (clang, -O0):
<make_home_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1050 <make_targetname@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
je     1202 <make_home_dir+0xa2>
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
jne    11bf <make_home_dir+0x5f>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1060 <inf@plt>
jmp    11fd <make_home_dir+0x9d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe55(%rip),%rdi
call   1070 <err@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1222 <make_home_dir+0xc2>
jmp    1212 <make_home_dir+0xb2>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <inf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_home_dir>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1050 <make_targetname@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
je     11a3 <make_home_dir+0x43>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rdi
mov    0x2e4b(%rip),%rax
cmp    (%rax),%rdi
jne    11b6 <make_home_dir+0x56>
lea    0xe64(%rip),%rdi
jmp    11aa <make_home_dir+0x4a>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
call   1060 <inf@plt>
xor    %ebp,%ebp
jmp    11d1 <make_home_dir+0x71>
call   1080 <strerror@plt>
lea    0xe76(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <err@plt>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"home\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [51 x i8] c"portable home directory '%s' already exists - fine\00"
@.str.2 = [48 x i8] c"error creating portable home directory '%s': %s\00"
@.str.3 = [37 x i8] c"portable home directory '%s' created\00"
define i32 @make_home_dir() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @make_targetname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @mkdir(i8* %4, i32 448)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EEXIST
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = call i32 @inf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %21
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = load i64, i64* @errno
%17 = call i32 @strerror(i64 %16)
%18 = call i32 @err(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %17)
%19 = load i8*, i8** %2
%20 = call i32 @free(i8* %19)
store i32 1, i32* %1
br label %28
21: ; preds = %11
br label %25
22: ; preds = %0
%23 = load i8*, i8** %2
%24 = call i32 @inf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %21
%26 = load i8*, i8** %2
%27 = call i32 @free(i8* %26)
store i32 0, i32* %1
br label %28
28: ; preds = %25, %14
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [5 x i8] c"home\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [51 x i8] c"portable home directory '%s' already exists - fine\00"
@.str.2 = [48 x i8] c"error creating portable home directory '%s': %s\00"
@.str.3 = [37 x i8] c"portable home directory '%s' created\00"
define i32 @make_home_dir() {
%1 = tail call i8* @make_targetname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @mkdir(i8* %1, i32 448)
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EEXIST
%7 = icmp eq i64 %5, %6
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @strerror(i64 %5)
%10 = tail call i32 @err(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %9)
br label %14
11: ; preds = %0, %4
%12 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), %0 ]
%13 = tail call i32 @inf(i8* %12, i8* %1)
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ 0, %11 ], [ 1, %8 ]
%16 = tail call i32 @free(i8* %1)
ret i32 %15
}