#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 *, double);
char *getLogDir();
int /*<<< orphan*/ sprintf(char *, char *, char *);
void SaveBestScore(double score) {
  char score_name[256];
  sprintf(score_name, "%s/best_score/score_0", getLogDir());
  FILE *f_score = fopen(score_name, "w");
  fprintf(f_score, "%.5g\n", score);
  fclose(f_score);
}


x86 assembly (clang, -O0):
<SaveBestScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    $0x0,%al
call   1050 <getLogDir@plt>
mov    -0x120(%rbp),%rdi
mov    %rax,%rdx
lea    0xe7a(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x118(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SaveBestScore>:
push   %rbx
sub    $0x110,%rsp
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <getLogDir@plt>
lea    0xe94(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1070 <sprintf@plt>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe83(%rip),%rsi
mov    %rax,%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <fprintf@plt>
mov    %rbx,%rdi
add    $0x110,%rsp
pop    %rbx
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"%s/best_score/score_0\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"%.5g\0A\00"
define void @SaveBestScore(double %0) {
%2 = alloca double
%3 = alloca [256 x i8]
%4 = alloca i32*
store double %0, double* %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i8* (...) @getLogDir()
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = load double, double* %2
%12 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s/best_score/score_0\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"%.5g\0A\00"
define void @SaveBestScore(double %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i8* (...) @getLogDir()
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %0)
%8 = tail call i32 @fclose(i32* %6)
ret void
}