#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__ directory_exists(char *);
char *getenv(char *);
int /*<<< orphan*/ settings_directory_name(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int system(char *);
int init_settings() {
  char directory[512];
  char command[512];
  char subdir[512];
  int retval;
  settings_directory_name(directory);
  if (directory_exists(directory) != 0)
    return 0;
  sprintf(subdir, "%s%c.config", getenv("HOME"), '/');
  if (directory_exists(subdir) == 0) {
    sprintf(command, "%s %s", "mkdir", subdir);
    retval = system(command);
  }
  sprintf(command, "%s %s", "mkdir", directory);
  retval = system(command);
  return retval;
}


x86 assembly (clang, -O0):
<init_settings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x620,%rsp
lea    -0x210(%rbp),%rdi
call   1050 <settings_directory_name@plt>
lea    -0x210(%rbp),%rdi
call   1060 <directory_exists@plt>
cmp    $0x0,%rax
je     1189 <init_settings+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1249 <init_settings+0xf9>
lea    -0x610(%rbp),%rax
mov    %rax,-0x620(%rbp)
lea    0xe6e(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x620(%rbp),%rdi
mov    %rax,%rdx
lea    0xe4c(%rip),%rsi
mov    $0x2f,%ecx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x610(%rbp),%rdi
call   1060 <directory_exists@plt>
cmp    $0x0,%rax
jne    120b <init_settings+0xbb>
lea    -0x410(%rbp),%rdi
lea    -0x610(%rbp),%rcx
lea    0xe26(%rip),%rsi
lea    0xe25(%rip),%rdx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x614(%rbp)
lea    -0x410(%rbp),%rdi
lea    -0x210(%rbp),%rcx
lea    0xdf1(%rip),%rsi
lea    0xdf0(%rip),%rdx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x614(%rbp)
mov    -0x614(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x620,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_settings>:
push   %rbx
sub    $0x600,%rsp
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <settings_directory_name@plt>
mov    %rbx,%rdi
call   1060 <directory_exists@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    120e <init_settings+0xbe>
lea    0xe87(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe6f(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
mov    $0x2f,%ecx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <directory_exists@plt>
test   %rax,%rax
jne    11de <init_settings+0x8e>
lea    0xe57(%rip),%rsi
lea    0xe56(%rip),%rdx
lea    0x200(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe2c(%rip),%rsi
lea    0xe2b(%rip),%rdx
lea    0x200(%rsp),%rbx
lea    0x400(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
add    $0x600,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%s%c.config\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.3 = [6 x i8] c"mkdir\00"
define i32 @init_settings() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%7 = call i32 @settings_directory_name(i8* %6)
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = call i64 @directory_exists(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 0, i32* %1
br label %32
12: ; preds = %0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%14 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14, i32 47)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%17 = call i64 @directory_exists(i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%24 = call i32 @system(i8* %23)
store i32 %24, i32* %5
br label %25
25: ; preds = %19, %12
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%30 = call i32 @system(i8* %29)
store i32 %30, i32* %5
%31 = load i32, i32* %5
store i32 %31, i32* %1
br label %32
32: ; preds = %25, %11
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s%c.config\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.3 = [6 x i8] c"mkdir\00"
define i32 @init_settings() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = call i32 @settings_directory_name(i8* %4)
%8 = call i64 @directory_exists(i8* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %11, i32 47)
%13 = call i64 @directory_exists(i8* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%17 = call i32 @system(i8* %5)
br label %18
18: ; preds = %15, %10
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%20 = call i32 @system(i8* %5)
br label %21
21: ; preds = %0, %18
%22 = phi i32 [ %20, %18 ], [ 0, %0 ]
ret i32 %22
}