#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 EXIT_FAILURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getuid();
int /*<<< orphan*/ printf(char *, char *);
int write_config_file(char *file_name) {
  FILE *file;
  file = fopen(file_name, "w");
  if (file == NULL) {
    printf("Failed to open %s.\n", file_name);
    return EXIT_FAILURE;
  }
  fprintf(file, "banned.users=bannedUser\n");
  fprintf(file, "min.user.id=%d\n", getuid());
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<write_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119c <write_config_file+0x4c>
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <write_config_file+0x91>
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_config_file>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
lea    0xe93(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b9 <write_config_file+0x59>
mov    %rax,%rbx
lea    0xe95(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getuid@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11d1 <write_config_file+0x71>
lea    0xe42(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [20 x i8] c"Failed to open %s.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"banned.users=bannedUser\0A\00"
@.str.3 = [16 x i8] c"min.user.id=%d\0A\00"
define i32 @write_config_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %2
br label %21
13: ; preds = %1
%14 = load i32*, i32** %4
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32*, i32** %4
%17 = call i32 (...) @getuid()
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
store i32 0, i32* %2
br label %21
21: ; preds = %13, %9
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [20 x i8] c"Failed to open %s.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"banned.users=bannedUser\0A\00"
@.str.3 = [16 x i8] c"min.user.id=%d\0A\00"
define i32 @write_config_file(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @EXIT_FAILURE
br label %12
7: ; preds = %1
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 24, i64 1, i32* %2)
%9 = tail call i32 (...) @getuid()
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = tail call i32 @fclose(i32* %2)
br label %12
12: ; preds = %7, %4
%13 = phi i32 [ %6, %4 ], [ 0, %7 ]
ret i32 %13
}