#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ viderBuffer();
int choisirMenu(const unsigned int maximum) {
  int choixJoueur;
  unsigned int compteurErreur;
  compteurErreur = 0;
  do {
    if (compteurErreur > 0) {
      printf("Veuillez entrer un nombre correct !\n");
      viderBuffer();
    }
    printf("> ");
    scanf("%d", &choixJoueur);
    ++compteurErreur;
  } while (choixJoueur < -1 && choixJoueur > maximum);
  viderBuffer();
  return choixJoueur;
}


x86 assembly (clang, -O0):
<choisirMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jbe    115f <choisirMenu+0x2f>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <viderBuffer@plt>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jge    119f <choisirMenu+0x6f>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
seta   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1142 <choisirMenu+0x12>
mov    $0x0,%al
call   1040 <viderBuffer@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choisirMenu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeac(%rip),%r14
lea    0xea8(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe9f(%rip),%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
sub    $0x1,%ebp
jb     1184 <choisirMenu+0x44>
mov    %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <viderBuffer@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xfffffffe,%eax
jg     11a4 <choisirMenu+0x64>
cmp    %ebx,%eax
ja     1170 <choisirMenu+0x30>
xor    %eax,%eax
call   1050 <viderBuffer@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Veuillez entrer un nombre correct !\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @choisirMenu(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %4
%7 = icmp ugt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @viderBuffer()
br label %11
11: ; preds = %8, %5
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %4
%15 = add i32 %14, 1
store i32 %15, i32* %4
br label %16
16: ; preds = %11
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp ugt i32 %20, %21
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %5, label %25
25: ; preds = %23
%26 = call i32 (...) @viderBuffer()
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [36 x i8] c"Veuillez entrer un nombre correct !\00"
define i32 @choisirMenu(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %10, %1
%5 = phi i32 [ 0, %1 ], [ %13, %10 ]
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%9 = call i32 (...) @viderBuffer()
br label %10
10: ; preds = %7, %4
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%13 = add i32 %5, 1
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, -1
%16 = icmp ugt i32 %14, %0
%17 = and i1 %15, %16
br i1 %17, label %4, label %18
18: ; preds = %10
%19 = call i32 (...) @viderBuffer()
%20 = load i32, i32* %2
ret i32 %20
}