#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 *);
void menu(int *dado, int *tiri) {
  printf("\n\n-----LANCIO DADI-----\n\n");
  printf("Selezionare il dado da lanciare:\n");
  printf("\t1) D2 - Due facce\n");
  printf("\t2) D3 - Tre facce\n");
  printf("\t3) D4 - Quattro facce\n");
  printf("\t4) D6 - Sei facce\n");
  printf("\t5) D8 - Otto facce\n");
  printf("\t6) D10- Dieci facce\n");
  printf("\t7) D20- Venti facce\n");
  printf("La tua scelta: ");
  scanf("%i", dado);
  printf("Quanti tiri? ");
  scanf("%i", tiri);
  switch (*dado) {
  case 1:
    *dado = 2;
    break;
  case 2:
    *dado = 3;
    break;
  case 3:
    *dado = 4;
    break;
  case 4:
    *dado = 6;
    break;
  case 5:
    *dado = 8;
    break;
  case 6:
    *dado = 10;
    break;
  case 7:
    *dado = 20;
    break;
  default:
    printf("Dado non regolamentare. Terminato.\n\n");
    return;
    break;
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
call   1030 <printf@plt>
lea    0xf2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf36(%rip),%rdi
call   1030 <printf@plt>
lea    0xf40(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xf4a(%rip),%rdi
mov    %rdi,-0x20(%rbp)
call   1040 <scanf@plt>
lea    0xf3d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     126a <menu+0x14a>
mov    -0x18(%rbp),%rax
lea    0xe08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movl   $0x2,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0x4,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0x6,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0x8,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0xa,(%rax)
jmp    1276 <menu+0x156>
mov    -0x8(%rbp),%rax
movl   $0x14,(%rax)
jmp    1276 <menu+0x156>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf45(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe72(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    (%r15),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     1200 <menu+0xd0>
lea    0xe12(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x2,(%r15)
jmp    1245 <menu+0x115>
lea    0xefe(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>
movl   $0x3,(%r15)
jmp    1245 <menu+0x115>
movl   $0x4,(%r15)
jmp    1245 <menu+0x115>
movl   $0x6,(%r15)
jmp    1245 <menu+0x115>
movl   $0x8,(%r15)
jmp    1245 <menu+0x115>
movl   $0xa,(%r15)
jmp    1245 <menu+0x115>
movl   $0x14,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A\0A-----LANCIO DADI-----\0A\0A\00"
@.str.1 = [34 x i8] c"Selezionare il dado da lanciare:\0A\00"
@.str.2 = [20 x i8] c"\091) D2 - Due facce\0A\00"
@.str.3 = [20 x i8] c"\092) D3 - Tre facce\0A\00"
@.str.4 = [24 x i8] c"\093) D4 - Quattro facce\0A\00"
@.str.5 = [20 x i8] c"\094) D6 - Sei facce\0A\00"
@.str.6 = [21 x i8] c"\095) D8 - Otto facce\0A\00"
@.str.7 = [22 x i8] c"\096) D10- Dieci facce\0A\00"
@.str.8 = [22 x i8] c"\097) D20- Venti facce\0A\00"
@.str.9 = [16 x i8] c"La tua scelta: \00"
@.str.10 = [3 x i8] c"%i\00"
@.str.11 = [14 x i8] c"Quanti tiri? \00"
@.str.12 = [37 x i8] c"Dado non regolamentare. Terminato.\0A\0A\00"
define void @menu(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%15 = load i32*, i32** %3
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%18 = load i32*, i32** %4
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %18)
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
switch i32 %21, label %36 [
i32 1, label %22
i32 2, label %24
i32 3, label %26
i32 4, label %28
i32 5, label %30
i32 6, label %32
i32 7, label %34
]
22: ; preds = %2
%23 = load i32*, i32** %3
store i32 2, i32* %23
br label %38
24: ; preds = %2
%25 = load i32*, i32** %3
store i32 3, i32* %25
br label %38
26: ; preds = %2
%27 = load i32*, i32** %3
store i32 4, i32* %27
br label %38
28: ; preds = %2
%29 = load i32*, i32** %3
store i32 6, i32* %29
br label %38
30: ; preds = %2
%31 = load i32*, i32** %3
store i32 8, i32* %31
br label %38
32: ; preds = %2
%33 = load i32*, i32** %3
store i32 10, i32* %33
br label %38
34: ; preds = %2
%35 = load i32*, i32** %3
store i32 20, i32* %35
br label %38
36: ; preds = %2
%37 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
br label %38
38: ; preds = %36, %34, %32, %30, %28, %26, %24, %22
ret void
}

LLVM IR (-O2):
@.str.9 = [16 x i8] c"La tua scelta: \00"
@.str.10 = [3 x i8] c"%i\00"
@.str.11 = [14 x i8] c"Quanti tiri? \00"
@str = [25 x i8] c"\0A\0A-----LANCIO DADI-----\0A\00"
@str.13 = [33 x i8] c"Selezionare il dado da lanciare:\00"
@str.14 = [19 x i8] c"\091) D2 - Due facce\00"
@str.15 = [19 x i8] c"\092) D3 - Tre facce\00"
@str.16 = [23 x i8] c"\093) D4 - Quattro facce\00"
@str.17 = [19 x i8] c"\094) D6 - Sei facce\00"
@str.18 = [20 x i8] c"\095) D8 - Otto facce\00"
@str.19 = [21 x i8] c"\096) D10- Dieci facce\00"
@str.20 = [21 x i8] c"\097) D20- Venti facce\00"
@str.21 = [36 x i8] c"Dado non regolamentare. Terminato.\0A\00"
define void @menu(i32* %0, i32* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.14, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.19, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.20, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%13 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %0)
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%15 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %0
switch i32 %16, label %24 [
i32 1, label %17
i32 2, label %18
i32 3, label %19
i32 4, label %20
i32 5, label %21
i32 6, label %22
i32 7, label %23
]
17: ; preds = %2
store i32 2, i32* %0
br label %26
18: ; preds = %2
store i32 3, i32* %0
br label %26
19: ; preds = %2
store i32 4, i32* %0
br label %26
20: ; preds = %2
store i32 6, i32* %0
br label %26
21: ; preds = %2
store i32 8, i32* %0
br label %26
22: ; preds = %2
store i32 10, i32* %0
br label %26
23: ; preds = %2
store i32 20, i32* %0
br label %26
24: ; preds = %2
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.21, i64 0, i64 0))
br label %26
26: ; preds = %24, %23, %22, %21, %20, %19, %18, %17
ret void
}