#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void save_settings(char LogFilename[], short uselog) {
  FILE *settings_file = NULL;
  if ((settings_file = fopen("settings", "w")) == NULL) {
    return;
  }
  fprintf(settings_file, "%s\n", LogFilename);
  if (uselog) {
    fprintf(settings_file, "%s\n", "true");
  } else {
    fprintf(settings_file, "%s\n", "false");
  }
  fclose(settings_file);
}


x86 assembly (clang, -O0):
<save_settings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xeae(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1171 <save_settings+0x41>
jmp    11cc <save_settings+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8b(%rip),%rsi
call   1040 <fprintf@plt>
cmpw   $0x0,-0xa(%rbp)
je     11ac <save_settings+0x7c>
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
lea    0xe6d(%rip),%rdx
call   1040 <fprintf@plt>
jmp    11c3 <save_settings+0x93>
mov    -0x18(%rbp),%rdi
lea    0xe54(%rip),%rsi
lea    0xe56(%rip),%rdx
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_settings>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xebc(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a0 <save_settings+0x70>
mov    %rax,%rbx
lea    0xeac(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <fprintf@plt>
test   %r14w,%r14w
lea    0xe9c(%rip),%rax
lea    0xe90(%rip),%rdx
cmove  %rax,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"settings\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [6 x i8] c"false\00"
define void @save_settings(i8* %0, i16 signext %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i32*
store i8* %0, i8** %3
store i16 %1, i16* %4
store i32* null, i32** %5
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %2
br label %24
9: ; preds = %2
%10 = load i32*, i32** %5
%11 = load i8*, i8** %3
%12 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i16, i16* %4
%14 = icmp ne i16 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32*, i32** %5
%17 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %21
18: ; preds = %9
%19 = load i32*, i32** %5
%20 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
%22 = load i32*, i32** %5
%23 = call i32 @fclose(i32* %22)
br label %24
24: ; preds = %21, %8
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"settings\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [6 x i8] c"false\00"
define void @save_settings(i8* %0, i16 signext %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%7 = icmp eq i16 %1, 0
%8 = select i1 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%9 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %2, %5
ret void
}