#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 /*<<< orphan*/ appuyezEntree(char *);
int /*<<< orphan*/ attendre(int);
int /*<<< orphan*/ gagneRouletteRusse(int, int);
int hasard(int, int);
int /*<<< orphan*/ menuRouletteRusse(int);
int /*<<< orphan*/ nbPointsTotal();
int /*<<< orphan*/ perduRouletteRusse(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ system(char *);
void rouletteRusse(int modeDeJeux) {
  int revolver[6];
  int index, endroitBalle;
  menuRouletteRusse(modeDeJeux);
  system("clear");
  for (index = 0; index < 6; index++)
    revolver[index] = 0;
  endroitBalle = hasard(0, 6 - 1);
  revolver[endroitBalle] = 1;
  do {
    endroitBalle = hasard(0, 6 - 1);
  } while (revolver[endroitBalle] == 1);
  revolver[endroitBalle] = 1;
  printf("Que le jeu commence !\n\n");
  attendre(3);
  printf("Rechargement du canon...\n");
  attendre(2);
  printf("Le barrilet tourne...\n");
  attendre(3);
  printf("\nTout est en place !\n\n");
  endroitBalle = hasard(1, 100);
  endroitBalle %= 6;
  appuyezEntree("Appuyez sur ENTREE pour presser la detente : ");
  if (revolver[endroitBalle] == 1)
    perduRouletteRusse(nbPointsTotal(), modeDeJeux);
  else
    gagneRouletteRusse(500, modeDeJeux);
}


x86 assembly (clang, -O0):
<rouletteRusse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <menuRouletteRusse@plt>
lea    0xe56(%rip),%rdi
call   1060 <system@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    11da <rouletteRusse+0x4a>
movslq -0x24(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b6 <rouletteRusse+0x26>
xor    %edi,%edi
mov    $0x5,%esi
call   1030 <hasard@plt>
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
movl   $0x1,-0x20(%rbp,%rax,4)
xor    %edi,%edi
mov    $0x5,%esi
call   1030 <hasard@plt>
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmpl   $0x1,-0x20(%rbp,%rax,4)
je     11f5 <rouletteRusse+0x65>
movslq -0x28(%rbp),%rax
movl   $0x1,-0x20(%rbp,%rax,4)
lea    0xde0(%rip),%rdi
call   1070 <printf@plt>
mov    $0x3,%edi
call   1080 <attendre@plt>
lea    0xde2(%rip),%rdi
call   1070 <printf@plt>
mov    $0x2,%edi
call   1080 <attendre@plt>
lea    0xde6(%rip),%rdi
call   1070 <printf@plt>
mov    $0x3,%edi
call   1080 <attendre@plt>
lea    0xde7(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
mov    $0x64,%esi
call   1030 <hasard@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
lea    0xdd2(%rip),%rdi
call   10a0 <appuyezEntree@plt>
movslq -0x28(%rbp),%rax
cmpl   $0x1,-0x20(%rbp,%rax,4)
jne    12be <rouletteRusse+0x12e>
mov    $0x0,%al
call   10b0 <nbPointsTotal@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
call   1090 <perduRouletteRusse@plt>
jmp    12cb <rouletteRusse+0x13b>
mov    -0x4(%rbp),%esi
mov    $0x1f4,%edi
call   1040 <gagneRouletteRusse@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rouletteRusse>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
call   1060 <menuRouletteRusse@plt>
lea    0xe5c(%rip),%rdi
call   1070 <system@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
xor    %edi,%edi
mov    $0x5,%esi
call   1040 <hasard@plt>
cltq
movl   $0x1,(%rsp,%rax,4)
xchg   %ax,%ax
xor    %edi,%edi
mov    $0x5,%esi
call   1040 <hasard@plt>
cltq
cmpl   $0x1,(%rsp,%rax,4)
je     11d0 <rouletteRusse+0x40>
movl   $0x1,(%rsp,%rax,4)
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <attendre@plt>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1080 <attendre@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <attendre@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0x64,%esi
call   1040 <hasard@plt>
movslq %eax,%rbx
imul   $0x2aaaaaab,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
lea    0xd99(%rip),%rdi
call   10a0 <appuyezEntree@plt>
movslq %ebx,%rax
cmpl   $0x1,(%rsp,%rax,4)
jne    1291 <rouletteRusse+0x101>
xor    %eax,%eax
call   10b0 <nbPointsTotal@plt>
mov    %eax,%edi
mov    %ebp,%esi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <perduRouletteRusse@plt>
mov    $0x1f4,%edi
mov    %ebp,%esi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <gagneRouletteRusse@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [24 x i8] c"Que le jeu commence !\0A\0A\00"
@.str.2 = [26 x i8] c"Rechargement du canon...\0A\00"
@.str.3 = [23 x i8] c"Le barrilet tourne...\0A\00"
@.str.4 = [23 x i8] c"\0ATout est en place !\0A\0A\00"
@.str.5 = [46 x i8] c"Appuyez sur ENTREE pour presser la detente : \00"
define void @rouletteRusse(i32 %0) {
%2 = alloca i32
%3 = alloca [6 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @menuRouletteRusse(i32 %6)
%8 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %16, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %14
store i32 0, i32* %15
br label %16
16: ; preds = %12
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %9
19: ; preds = %9
%20 = call i32 @hasard(i32 0, i32 5)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %22
store i32 1, i32* %23
br label %24
24: ; preds = %26, %19
%25 = call i32 @hasard(i32 0, i32 5)
store i32 %25, i32* %5
br label %26
26: ; preds = %24
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 1
br i1 %31, label %24, label %32
32: ; preds = %26
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %34
store i32 1, i32* %35
%36 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @attendre(i32 3)
%38 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @attendre(i32 2)
%40 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @attendre(i32 3)
%42 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 @hasard(i32 1, i32 100)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = srem i32 %44, 6
store i32 %45, i32* %5
%46 = call i32 @appuyezEntree(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %56
52: ; preds = %32
%53 = call i32 (...) @nbPointsTotal()
%54 = load i32, i32* %2
%55 = call i32 @perduRouletteRusse(i32 %53, i32 %54)
br label %59
56: ; preds = %32
%57 = load i32, i32* %2
%58 = call i32 @gagneRouletteRusse(i32 500, i32 %57)
br label %59
59: ; preds = %56, %52
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.5 = [46 x i8] c"Appuyez sur ENTREE pour presser la detente : \00"
@str = [23 x i8] c"Que le jeu commence !\0A\00"
@str.6 = [25 x i8] c"Rechargement du canon...\00"
@str.7 = [22 x i8] c"Le barrilet tourne...\00"
@str.8 = [22 x i8] c"\0ATout est en place !\0A\00"
define void @rouletteRusse(i32 %0) {
%2 = alloca [6 x i32]
%3 = bitcast [6 x i32]* %2 to i8*
%4 = tail call i32 @menuRouletteRusse(i32 %0)
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @hasard(i32 0, i32 5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %7
store i32 1, i32* %8
br label %9
9: ; preds = %9, %1
%10 = tail call i32 @hasard(i32 0, i32 5)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 1
br i1 %14, label %9, label %15
15: ; preds = %9
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %11
store i32 1, i32* %16
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @attendre(i32 3)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%20 = tail call i32 @attendre(i32 2)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%22 = tail call i32 @attendre(i32 3)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%24 = tail call i32 @hasard(i32 1, i32 100)
%25 = srem i32 %24, 6
%26 = tail call i32 @appuyezEntree(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %15
%32 = tail call i32 (...) @nbPointsTotal()
%33 = tail call i32 @perduRouletteRusse(i32 %32, i32 %0)
br label %36
34: ; preds = %15
%35 = tail call i32 @gagneRouletteRusse(i32 500, i32 %0)
br label %36
36: ; preds = %34, %31
ret void
}