#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, int);
void writefile(long int result) {
  FILE *fp;
  char filename[100];
  sprintf(filename, "../../test_result/quality_opt_%s_%s_%d.txt", "uniform",
          "corr0", 100);
  if ((fp = fopen(filename, "a")) == NULL) {
    printf("Cannot open file strike any key exit!");
    exit(1);
  }
  fprintf(fp, "%d %ld\n", 1, result);
  fclose(fp);
}


x86 assembly (clang, -O0):
<writefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    0xeaa(%rip),%rdx
lea    0xeab(%rip),%rcx
mov    $0x64,%r8d
call   1070 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c7 <writefile+0x67>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
lea    0xe8b(%rip),%rsi
mov    $0x1,%edx
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writefile>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
lea    0xe8f(%rip),%rsi
lea    0xeb3(%rip),%rdx
lea    0xeb4(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%r8d
call   1070 <sprintf@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11cd <writefile+0x6d>
mov    %rax,%rbx
lea    0xeb3(%rip),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"../../test_result/quality_opt_%s_%s_%d.txt\00"
@.str.1 = [8 x i8] c"uniform\00"
@.str.2 = [6 x i8] c"corr0\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [38 x i8] c"Cannot open file strike any key exit!\00"
@.str.5 = [8 x i8] c"%d %ld\0A\00"
define void @writefile(i64 %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca [100 x i8]
store i64 %0, i64* %2
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 100)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %8, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = load i64, i64* %2
%16 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 1, i64 %15)
%17 = load i32*, i32** %3
%18 = call i32 @fclose(i32* %17)
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"../../test_result/quality_opt_%s_%s_%d.txt\00"
@.str.1 = [8 x i8] c"uniform\00"
@.str.2 = [6 x i8] c"corr0\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [38 x i8] c"Cannot open file strike any key exit!\00"
@.str.5 = [8 x i8] c"%d %ld\0A\00"
define void @writefile(i64 %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 100)
%5 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = tail call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 1, i64 %0)
%12 = tail call i32 @fclose(i32* %5)
ret void
}