#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 */

/* Variables and functions */
int afficherDernierePartieJoueeSolo();
int /*<<< orphan*/ asciiArtDebut();
int /*<<< orphan*/ chargerPartieSolo();
int choixMenu(int, int);
int /*<<< orphan*/ nouvellePartieSolo();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quitter();
int /*<<< orphan*/ supprimerPartieSolo();
int /*<<< orphan*/ titre(char *);
void systemeSauvegardeSolo(void) {
  int choix;
  int retour, nbLigneMax;
  titre("Sauvegarde");
  printf("Que souhaitez-vous faire ?\n\n");
  retour = afficherDernierePartieJoueeSolo();
  if (!retour)
    nbLigneMax = 3;
  else
    nbLigneMax = 4;
  printf("\t%d - Charger partie\n", nbLigneMax - 2);
  printf("\t%d - Nouvelle partie\n", nbLigneMax - 1);
  printf("\t%d - Supprimer partie\n\n", nbLigneMax);
  choix = choixMenu(1, nbLigneMax);
  if (choix == 0)
    quitter();
  else if (choix == -1)
    asciiArtDebut();
  else if (choix == nbLigneMax - 2)
    chargerPartieSolo();
  else if (choix == nbLigneMax - 1)
    nouvellePartieSolo();
  else if (choix == nbLigneMax)
    supprimerPartieSolo();
}


x86 assembly (clang, -O0):
<systemeSauvegardeSolo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe61(%rip),%rdi
call   1090 <titre@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <afficherDernierePartieJoueeSolo@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11d2 <systemeSauvegardeSolo+0x42>
movl   $0x3,-0xc(%rbp)
jmp    11d9 <systemeSauvegardeSolo+0x49>
movl   $0x4,-0xc(%rbp)
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%esi
mov    $0x1,%edi
call   1030 <choixMenu@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1238 <systemeSauvegardeSolo+0xa8>
mov    $0x0,%al
call   1040 <quitter@plt>
jmp    12af <systemeSauvegardeSolo+0x11f>
cmpl   $0xffffffff,-0x4(%rbp)
jne    124e <systemeSauvegardeSolo+0xbe>
mov    $0x0,%al
call   1070 <asciiArtDebut@plt>
jmp    12aa <systemeSauvegardeSolo+0x11a>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jne    126b <systemeSauvegardeSolo+0xdb>
mov    $0x0,%al
call   1080 <chargerPartieSolo@plt>
jmp    12a5 <systemeSauvegardeSolo+0x115>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1288 <systemeSauvegardeSolo+0xf8>
mov    $0x0,%al
call   10b0 <nouvellePartieSolo@plt>
jmp    12a0 <systemeSauvegardeSolo+0x110>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    129b <systemeSauvegardeSolo+0x10b>
mov    $0x0,%al
call   1050 <supprimerPartieSolo@plt>
jmp    12a0 <systemeSauvegardeSolo+0x110>
jmp    12a5 <systemeSauvegardeSolo+0x115>
jmp    12aa <systemeSauvegardeSolo+0x11a>
jmp    12af <systemeSauvegardeSolo+0x11f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<systemeSauvegardeSolo>:
push   %rbp
push   %r14
push   %rbx
lea    0xe55(%rip),%rdi
call   10a0 <titre@plt>
lea    0xe9a(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <afficherDernierePartieJoueeSolo@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    $0x4,%ebp
sub    %ebx,%ebp
mov    $0x2,%r14d
sub    %ebx,%r14d
lea    0xe2a(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    $0x3,%ebx
lea    0xe2c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe33(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
mov    %ebp,%esi
call   1030 <choixMenu@plt>
cmp    $0xffffffff,%eax
je     122e <systemeSauvegardeSolo+0x8e>
test   %eax,%eax
jne    1239 <systemeSauvegardeSolo+0x99>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <quitter@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <asciiArtDebut@plt>
cmp    %r14d,%eax
jne    1249 <systemeSauvegardeSolo+0xa9>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <chargerPartieSolo@plt>
cmp    %ebx,%eax
jne    1258 <systemeSauvegardeSolo+0xb8>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    10c0 <nouvellePartieSolo@plt>
cmp    %ebp,%eax
jne    1267 <systemeSauvegardeSolo+0xc7>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <supprimerPartieSolo@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Sauvegarde\00"
@.str.1 = [29 x i8] c"Que souhaitez-vous faire ?\0A\0A\00"
@.str.2 = [22 x i8] c"\09%d - Charger partie\0A\00"
@.str.3 = [23 x i8] c"\09%d - Nouvelle partie\0A\00"
@.str.4 = [25 x i8] c"\09%d - Supprimer partie\0A\0A\00"
define void @systemeSauvegardeSolo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @titre(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (...) @afficherDernierePartieJoueeSolo()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
store i32 3, i32* %3
br label %11
10: ; preds = %0
store i32 4, i32* %3
br label %11
11: ; preds = %10, %9
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = call i32 @choixMenu(i32 1, i32 %20)
store i32 %21, i32* %1
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %11
%25 = call i32 (...) @quitter()
br label %55
26: ; preds = %11
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @asciiArtDebut()
br label %54
31: ; preds = %26
%32 = load i32, i32* %1
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 2
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (...) @chargerPartieSolo()
br label %53
38: ; preds = %31
%39 = load i32, i32* %1
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 1
%42 = icmp eq i32 %39, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 (...) @nouvellePartieSolo()
br label %52
45: ; preds = %38
%46 = load i32, i32* %1
%47 = load i32, i32* %3
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 (...) @supprimerPartieSolo()
br label %51
51: ; preds = %49, %45
br label %52
52: ; preds = %51, %43
br label %53
53: ; preds = %52, %36
br label %54
54: ; preds = %53, %29
br label %55
55: ; preds = %54, %24
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Sauvegarde\00"
@.str.2 = [22 x i8] c"\09%d - Charger partie\0A\00"
@.str.3 = [23 x i8] c"\09%d - Nouvelle partie\0A\00"
@.str.4 = [25 x i8] c"\09%d - Supprimer partie\0A\0A\00"
@str = [28 x i8] c"Que souhaitez-vous faire ?\0A\00"
define void @systemeSauvegardeSolo() {
%1 = tail call i32 @titre(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @afficherDernierePartieJoueeSolo()
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 3, i32 4
%6 = add nsw i32 %5, -2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = add nsw i32 %5, -1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%11 = tail call i32 @choixMenu(i32 1, i32 %5)
switch i32 %11, label %16 [
i32 0, label %12
i32 -1, label %14
]
12: ; preds = %0
%13 = tail call i32 (...) @quitter()
br label %28
14: ; preds = %0
%15 = tail call i32 (...) @asciiArtDebut()
br label %28
16: ; preds = %0
%17 = icmp eq i32 %11, %6
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 (...) @chargerPartieSolo()
br label %28
20: ; preds = %16
%21 = icmp eq i32 %11, %8
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 (...) @nouvellePartieSolo()
br label %28
24: ; preds = %20
%25 = icmp eq i32 %11, %5
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 (...) @supprimerPartieSolo()
br label %28
28: ; preds = %14, %22, %26, %24, %18, %12
ret void
}