#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 *, int);
int /*<<< orphan*/ printf(char *);
void inscriptionScore(char name[], int score) {
  FILE *sauv = NULL;
  sauv = fopen("score.txt", "a");
  if (sauv != NULL) {
    fprintf(sauv, "%s %d\n", name, score);
    fclose(sauv);
  } else {
    printf("Erreur lors de l'ouverture du fichier pour ecriture");
  }
}


x86 assembly (clang, -O0):
<inscriptionScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119e <inscriptionScore+0x5e>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11aa <inscriptionScore+0x6a>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inscriptionScore>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xeaf(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1186 <inscriptionScore+0x46>
mov    %rax,%rbp
lea    0xea0(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe86(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"score.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%s %d\0A\00"
@.str.3 = [52 x i8] c"Erreur lors de l'ouverture du fichier pour ecriture\00"
define void @inscriptionScore(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32* null, i32** %5
%6 = 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* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32*, i32** %5
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %11, i32 %12)
%14 = load i32*, i32** %5
%15 = call i32 @fclose(i32* %14)
br label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %9
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"score.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%s %d\0A\00"
@.str.3 = [52 x i8] c"Erreur lors de l'ouverture du fichier pour ecriture\00"
define void @inscriptionScore(i8* %0, i32 %1) {
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %1)
%7 = tail call i32 @fclose(i32* %3)
br label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
ret void
}