#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*/ jouer();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
char *viewrules();
void menu() {
  int choice = 0;
  printf("\n \nvous avez 3 choix :\n 1 - les regles du jeu \n 2 - jouer  \n 3 "
         "- quitter \n");
  printf("what is your choice \n");
  printf("choix  ");
  scanf("%d", &choice);
  if (choice > 0 && choice < 4) {
    switch (choice) {
    case 1:
      printf("%s", viewrules());
      menu();
      break;
    case 2:
      jouer();
      break;
    case 3:
      printf(" MERCI A BIENTOT \n");
      break;
    }
  } else {
    printf("mauvais choix de menu merci de repeter votre choix \n");
    menu();
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1224 <menu+0xd4>
cmpl   $0x4,-0x4(%rbp)
jge    1224 <menu+0xd4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     11e3 <menu+0x93>
jmp    11c1 <menu+0x71>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1205 <menu+0xb5>
jmp    11d2 <menu+0x82>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     1211 <menu+0xc1>
jmp    121f <menu+0xcf>
mov    $0x0,%al
call   1060 <viewrules@plt>
mov    %rax,%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   1030 <menu@plt>
jmp    121f <menu+0xcf>
mov    $0x0,%al
call   1050 <jouer@plt>
jmp    121f <menu+0xcf>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1237 <menu+0xe7>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   1030 <menu@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe72(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x2,%ecx
ja     11d5 <menu+0x75>
cmp    $0x3,%eax
je     11e8 <menu+0x88>
cmp    $0x2,%eax
je     11f6 <menu+0x96>
cmp    $0x1,%eax
jne    11e6 <menu+0x86>
xor    %eax,%eax
call   1070 <viewrules@plt>
lea    0xe42(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e1 <menu+0x81>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
call   1040 <menu@plt>
pop    %rax
ret
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret
xor    %eax,%eax
call   1060 <jouer@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [75 x i8] c"\0A \0Avous avez 3 choix :\0A 1 - les regles du jeu \0A 2 - jouer \0A 3 - quitter \0A\00"
@.str.1 = [22 x i8] c"what is your choice \0A\00"
@.str.2 = [8 x i8] c"choix \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [19 x i8] c" MERCI A BIENTOT \0A\00"
@.str.6 = [53 x i8] c"mauvais choix de menu merci de repeter votre choix \0A\00"
define void @menu() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %0
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %1
switch i32 %12, label %20 [
i32 1, label %13
i32 2, label %16
i32 3, label %18
]
13: ; preds = %11
%14 = call i8* (...) @viewrules()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %11
%17 = call i32 (...) @jouer()
br label %20
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %11, %18, %16, %13
br label %23
21: ; preds = %8, %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
br label %23
23: ; preds = %21, %20
ret void
}

LLVM IR (-O2):
@.str.2 = [8 x i8] c"choix \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%s\00"
@str = [74 x i8] c"\0A \0Avous avez 3 choix :\0A 1 - les regles du jeu \0A 2 - jouer \0A 3 - quitter \00"
@str.7 = [21 x i8] c"what is your choice \00"
@str.8 = [52 x i8] c"mauvais choix de menu merci de repeter votre choix \00"
@str.9 = [18 x i8] c" MERCI A BIENTOT \00"
define void @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add i32 %7, -1
%9 = icmp ult i32 %8, 3
br i1 %9, label %10, label %18
10: ; preds = %0
switch i32 %7, label %20 [
i32 1, label %11
i32 2, label %14
i32 3, label %16
]
11: ; preds = %10
%12 = call i8* (...) @viewrules()
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %20
14: ; preds = %10
%15 = call i32 (...) @jouer()
br label %20
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.8, i64 0, i64 0))
br label %20
20: ; preds = %11, %14, %16, %10, %18
ret void
}