#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*/ free(void *);
char *getSettingsDir();
char *getSettingsFile(char *);
int /*<<< orphan*/ printf(char *, ...);
int zomfg(int argc, char **argv) {
  const char *settingsDir = getSettingsDir();
  if (settingsDir) {
    printf("Settings dir:  %s\n", settingsDir);
  } else {
    printf("Failed to create settings dir\n");
  }
  const char *settingsFile = getSettingsFile("sms_sdl.dat");
  printf("Settings file: %s\n", settingsFile);
  free((void *)settingsFile);
  return 0;
}


x86 assembly (clang, -O0):
<zomfg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getSettingsDir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117c <zomfg+0x3c>
mov    -0x18(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118a <zomfg+0x4a>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
call   1060 <getSettingsFile@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zomfg>:
push   %rbx
xor    %eax,%eax
call   1060 <getSettingsDir@plt>
test   %rax,%rax
je     1170 <zomfg+0x20>
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    117c <zomfg+0x2c>
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe90(%rip),%rdi
call   1070 <getSettingsFile@plt>
mov    %rax,%rbx
lea    0xe8d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Settings dir: %s\0A\00"
@.str.1 = [31 x i8] c"Failed to create settings dir\0A\00"
@.str.2 = [12 x i8] c"sms_sdl.dat\00"
@.str.3 = [19 x i8] c"Settings file: %s\0A\00"
define i32 @zomfg(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i8* (...) @getSettingsDir()
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = call i8* @getSettingsFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %6
%20 = call i32 @free(i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Settings dir: %s\0A\00"
@.str.2 = [12 x i8] c"sms_sdl.dat\00"
@.str.3 = [19 x i8] c"Settings file: %s\0A\00"
@str = [30 x i8] c"Failed to create settings dir\00"
define i32 @zomfg(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @getSettingsDir()
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = tail call i8* @getSettingsFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = tail call i32 @free(i8* %10)
ret i32 0
}