#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();
unsigned int choisirMenuSansOperationPossible(const unsigned int maximum) {
  int choixJoueur;
  unsigned int compteurErreur;
  compteurErreur = 0;
  do {
    if (choixJoueur == -1 || (choixJoueur == 0 && compteurErreur > 0)) {
      printf("Operation impossible !\n");
      viderBuffer();
    } else 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):
<choisirMenuSansOperationPossible>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1160 <choisirMenuSansOperationPossible+0x30>
cmpl   $0x0,-0x8(%rbp)
jne    1178 <choisirMenuSansOperationPossible+0x48>
cmpl   $0x0,-0xc(%rbp)
jbe    1178 <choisirMenuSansOperationPossible+0x48>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <viderBuffer@plt>
jmp    119a <choisirMenuSansOperationPossible+0x6a>
cmpl   $0x0,-0xc(%rbp)
jbe    1195 <choisirMenuSansOperationPossible+0x65>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <viderBuffer@plt>
jmp    119a <choisirMenuSansOperationPossible+0x6a>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jl     11da <choisirMenuSansOperationPossible+0xaa>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
seta   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1142 <choisirMenuSansOperationPossible+0x12>
mov    $0x0,%al
call   1040 <viderBuffer@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choisirMenuSansOperationPossible>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xed6(%rip),%rbx
lea    0xea5(%rip),%r14
lea    0xea1(%rip),%r15
lea    0x4(%rsp),%r12
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
cmp    $0xffffffff,%eax
je     1198 <choisirMenuSansOperationPossible+0x58>
test   %eax,%eax
sete   %al
test   %r13d,%r13d
setne  %cl
mov    %rbx,%rdi
test   %cl,%al
jne    1191 <choisirMenuSansOperationPossible+0x51>
lea    0xe75(%rip),%rdi
jne    1198 <choisirMenuSansOperationPossible+0x58>
test   %r13d,%r13d
je     11a4 <choisirMenuSansOperationPossible+0x64>
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
add    $0xffffffff,%r13d
test   %eax,%eax
jle    1170 <choisirMenuSansOperationPossible+0x30>
cmp    %ebp,%eax
ja     1170 <choisirMenuSansOperationPossible+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 = [24 x i8] c"Operation impossible !\0A\00"
@.str.1 = [37 x i8] c"Veuillez entrer un nombre correct !\0A\00"
@.str.2 = [3 x i8] c"> \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @choisirMenuSansOperationPossible(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 = %36, %1
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp ugt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11, %5
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @viderBuffer()
br label %24
17: ; preds = %11, %8
%18 = load i32, i32* %4
%19 = icmp ugt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @viderBuffer()
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23, %14
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %4
%28 = add i32 %27, 1
store i32 %28, i32* %4
br label %29
29: ; preds = %24
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 1
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = load i32, i32* %3
%34 = load i32, i32* %2
%35 = icmp ugt i32 %33, %34
br label %36
36: ; preds = %32, %29
%37 = phi i1 [ true, %29 ], [ %35, %32 ]
br i1 %37, label %5, label %38
38: ; preds = %36
%39 = call i32 (...) @viderBuffer()
%40 = load i32, i32* %3
ret i32 %40
}

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