#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*/ EXIT_FAILURE;
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ O_CREAT;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IRWXG;
int S_IRWXU;
int S_IWGRP;
int S_IWUSR;
int S_IXOTH;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_config_dir(char *);
int /*<<< orphan*/ get_config_path(char *);
char *getenv(char *);
int mkdir(char *, int);
int open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
void create_config_file(void) {
  int status;
  char *home_path;
  char config_path[512];
  char config_dir[512];
  home_path = getenv("HOME");
  if (!home_path) {
    fprintf(stderr, "You have to set the env:$HOME\n");
    exit(EXIT_FAILURE);
  }
  get_config_path(config_path);
  get_config_dir(config_dir);
  if (access(config_path, F_OK) == -1) {
    status = mkdir(config_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
    status = open(config_path, O_CREAT,
                  S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
  }
}


x86 assembly (clang, -O0):
<create_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xe6e(%rip),%rdi
call   1040 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c9 <create_config_file+0x49>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x210(%rbp),%rdi
call   1090 <get_config_path@plt>
lea    -0x410(%rbp),%rdi
call   1030 <get_config_dir@plt>
lea    -0x210(%rbp),%rdi
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
jne    1277 <create_config_file+0xf7>
lea    -0x410(%rbp),%rdi
mov    0x2dd3(%rip),%rax
mov    (%rax),%esi
mov    0x2dba(%rip),%rax
or     (%rax),%esi
mov    0x2d81(%rip),%rax
or     (%rax),%esi
mov    0x2db0(%rip),%rax
or     (%rax),%esi
call   1050 <mkdir@plt>
mov    %eax,-0x4(%rbp)
lea    -0x210(%rbp),%rdi
mov    0x2db8(%rip),%rax
mov    (%rax),%esi
mov    0x2d47(%rip),%rax
mov    (%rax),%edx
mov    0x2d6e(%rip),%rax
or     (%rax),%edx
mov    0x2d4d(%rip),%rax
or     (%rax),%edx
mov    0x2d64(%rip),%rax
or     (%rax),%edx
mov    0x2d33(%rip),%rax
or     (%rax),%edx
call   1070 <open@plt>
mov    %eax,-0x4(%rbp)
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_config_file>:
push   %rbx
sub    $0x400,%rsp
lea    0xe71(%rip),%rdi
call   1040 <getenv@plt>
test   %rax,%rax
je     123c <create_config_file+0xbc>
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <get_config_path@plt>
mov    %rsp,%rdi
call   1030 <get_config_dir@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
jne    1233 <create_config_file+0xb3>
mov    0x2e0e(%rip),%rax
mov    0x2df7(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dbc(%rip),%rbx
or     (%rbx),%esi
mov    0x2deb(%rip),%rax
or     (%rax),%esi
mov    %rsp,%rdi
call   1050 <mkdir@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
mov    0x2d89(%rip),%rax
mov    0x2db2(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d8f(%rip),%rax
or     (%rax),%edx
mov    0x2da6(%rip),%rax
or     (%rax),%edx
or     (%rbx),%edx
lea    0x200(%rsp),%rdi
call   1070 <open@plt>
add    $0x400,%rsp
pop    %rbx
ret
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"You have to set the env:$HOME\0A\00"
@EXIT_FAILURE = global i32 0
@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
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
define void @create_config_file() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%15 = call i32 @get_config_path(i8* %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%17 = call i32 @get_config_dir(i8* %16)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%19 = load i32, i32* @F_OK
%20 = call i32 @access(i8* %18, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %44
22: ; preds = %13
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%24 = load i32, i32* @S_IRWXU
%25 = load i32, i32* @S_IRWXG
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IROTH
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IXOTH
%30 = or i32 %28, %29
%31 = call i32 @mkdir(i8* %23, i32 %30)
store i32 %31, i32* %1
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%33 = load i32, i32* @O_CREAT
%34 = load i32, i32* @S_IRUSR
%35 = load i32, i32* @S_IWUSR
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IRGRP
%38 = or i32 %36, %37
%39 = load i32, i32* @S_IWGRP
%40 = or i32 %38, %39
%41 = load i32, i32* @S_IROTH
%42 = or i32 %40, %41
%43 = call i32 @open(i8* %32, i32 %33, i32 %42)
store i32 %43, i32* %1
br label %44
44: ; preds = %22, %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"You have to set the env:$HOME\0A\00"
@EXIT_FAILURE = global i32 0
@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
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
define void @create_config_file() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call i32 @get_config_path(i8* %3)
%14 = call i32 @get_config_dir(i8* %4)
%15 = load i32, i32* @F_OK
%16 = call i32 @access(i8* %3, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %38
18: ; preds = %12
%19 = load i32, i32* @S_IRWXU
%20 = load i32, i32* @S_IRWXG
%21 = or i32 %20, %19
%22 = load i32, i32* @S_IROTH
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IXOTH
%25 = or i32 %23, %24
%26 = call i32 @mkdir(i8* %4, i32 %25)
%27 = load i32, i32* @O_CREAT
%28 = load i32, i32* @S_IRUSR
%29 = load i32, i32* @S_IWUSR
%30 = or i32 %29, %28
%31 = load i32, i32* @S_IRGRP
%32 = or i32 %30, %31
%33 = load i32, i32* @S_IWGRP
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IROTH
%36 = or i32 %34, %35
%37 = call i32 @open(i8* %3, i32 %27, i32 %36)
br label %38
38: ; preds = %18, %12
ret void
}