#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 */
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, scalar_t__);
void _save_default_config(void) {
  errno = 0;
  FILE *handle = fopen("my.config", "w");
  if (errno != 0) {
    printf("Could not save default config! Errno = %d\n", errno);
    return;
  }
  fprintf(handle, "port: 2302\n");
  fprintf(handle, "max_players: 60\n");
  fprintf(handle, "server_name: Arma3 Server | SQF Sucks\n");
  fclose(handle);
}


x86 assembly (clang, -O0):
<_save_default_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
movq   $0x0,(%rax)
lea    0xea3(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    0x2e6c(%rip),%rax
cmpq   $0x0,(%rax)
je     1199 <_save_default_config+0x59>
mov    0x2e5b(%rip),%rax
mov    (%rax),%rsi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
jmp    11d2 <_save_default_config+0x92>
mov    -0x8(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_save_default_config>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rbx
movq   $0x0,(%rbx)
lea    0xea7(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <fopen@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1180 <_save_default_config+0x40>
lea    0xe98(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
mov    %rax,%r14
lea    0xead(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
lea    0xea0(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
lea    0xe98(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [10 x i8] c"my.config\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"Could not save default config! Errno = %d\0A\00"
@.str.3 = [12 x i8] c"port: 2302\0A\00"
@.str.4 = [17 x i8] c"max_players: 60\0A\00"
@.str.5 = [39 x i8] c"server_name: Arma3 Server | SQF Sucks\0A\00"
define void @_save_default_config() {
%1 = alloca i32*
store i64 0, i64* @errno
%2 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %2, i32** %1
%3 = load i64, i64* @errno
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i64 %6)
br label %17
8: ; preds = %0
%9 = load i32*, i32** %1
%10 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32*, i32** %1
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %1
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%15 = load i32*, i32** %1
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %8, %5
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [10 x i8] c"my.config\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"Could not save default config! Errno = %d\0A\00"
@.str.3 = [12 x i8] c"port: 2302\0A\00"
@.str.4 = [17 x i8] c"max_players: 60\0A\00"
@.str.5 = [39 x i8] c"server_name: Arma3 Server | SQF Sucks\0A\00"
define void @_save_default_config() {
store i64 0, i64* @errno
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = load i64, i64* @errno
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i64 %2)
br label %11
6: ; preds = %0
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 11, i64 1, i32* %1)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 16, i64 1, i32* %1)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i64 38, i64 1, i32* %1)
%10 = tail call i32 @fclose(i32* %1)
br label %11
11: ; preds = %6, %4
ret void
}