#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*/ all(char, char, int);
int /*<<< orphan*/ farfallino(char, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fiorentina(char, char, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ urlata(char, int);
int /*<<< orphan*/ vamavvo(char, int);
int main(void) {
  int mode = 0;
  char c = '0', prev = ' ';
  printf("Modalita' disponibili:\n1=Alfabeto Farfallino, \n2=Variante del "
         "vamavvo, \n3=Variante urlata, \n4=Variante fiorentina, "
         "\n5=Tutto!\n\nInserisci la modalita': ");
  scanf("%d", &mode);
  if (mode < 1 || mode > 5)
    mode = 5;
  printf("\nInserisci la stringa:\n");
  fflush(stdin);
  scanf("%c", &c);
  while (c != '\n') {
    switch (mode) {
    case 1:
      farfallino(c, 1);
      break;
    case 2:
      vamavvo(c, 1);
      break;
    case 3:
      urlata(c, 1);
      break;
    case 4:
      fiorentina(c, prev, 1);
      break;
    case 5:
      all(c, prev, 1);
      break;
    }
    prev = c;
    scanf("%c", &c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x30,-0x9(%rbp)
movb   $0x20,-0xa(%rbp)
lea    0xe6f(%rip),%rdi
call   1070 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     11d0 <main+0x50>
cmpl   $0x5,-0x8(%rbp)
jle    11d7 <main+0x57>
movl   $0x5,-0x8(%rbp)
lea    0xed0(%rip),%rdi
call   1070 <printf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    0xece(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     12bc <main+0x13c>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     129f <main+0x11f>
mov    -0x18(%rbp),%rax
lea    0xdd0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%esi
movsbl -0x9(%rbp),%edi
call   10a0 <farfallino@plt>
jmp    129f <main+0x11f>
mov    $0x1,%esi
movsbl -0x9(%rbp),%edi
call   1040 <vamavvo@plt>
jmp    129f <main+0x11f>
mov    $0x1,%esi
movsbl -0x9(%rbp),%edi
call   1050 <urlata@plt>
jmp    129f <main+0x11f>
mov    -0x9(%rbp),%al
mov    $0x1,%edx
movsbl %al,%edi
movsbl -0xa(%rbp),%esi
call   1060 <fiorentina@plt>
jmp    129f <main+0x11f>
mov    -0x9(%rbp),%al
mov    $0x1,%edx
movsbl %al,%edi
movsbl -0xa(%rbp),%esi
call   1030 <all@plt>
mov    -0x9(%rbp),%al
mov    %al,-0xa(%rbp)
lea    0xe1a(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
jmp    1203 <main+0x83>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movb   $0x30,0x3(%rsp)
lea    0xe68(%rip),%rdi
call   1080 <printf@plt>
lea    0xef3(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffa,%eax
cmp    $0xfffffffa,%eax
ja     11d8 <main+0x48>
movl   $0x5,0x4(%rsp)
lea    0xed2(%rip),%rdi
call   1050 <puts@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    0xeb5(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x3(%rsp),%al
cmp    $0xa,%al
jne    121b <main+0x8b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x20,%bl
lea    0xe8a(%rip),%r14
lea    0x3(%rsp),%r15
lea    0xdd0(%rip),%r12
jmp    126b <main+0xdb>
movsbl %al,%edi
movsbl %bl,%esi
mov    $0x1,%edx
call   1030 <all@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x3(%rsp),%ebx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
movzbl 0x3(%rsp),%eax
cmp    $0xa,%al
je     120d <main+0x7d>
mov    0x4(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
ja     1250 <main+0xc0>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
movsbl %al,%edi
mov    $0x1,%esi
call   10b0 <farfallino@plt>
jmp    1250 <main+0xc0>
movsbl %al,%edi
mov    $0x1,%esi
call   1040 <vamavvo@plt>
jmp    1250 <main+0xc0>
movsbl %al,%edi
mov    $0x1,%esi
call   1060 <urlata@plt>
jmp    1250 <main+0xc0>
movsbl %al,%edi
movsbl %bl,%esi
mov    $0x1,%edx
call   1070 <fiorentina@plt>
jmp    1250 <main+0xc0>

LLVM IR (-O0):
@.str = [151 x i8] c"Modalita' disponibili:\0A1=Alfabeto Farfallino, \0A2=Variante del vamavvo, \0A3=Variante urlata, \0A4=Variante fiorentina, \0A5=Tutto!\0A\0AInserisci la modalita': \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"\0AInserisci la stringa:\0A\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i8 48, i8* %3
store i8 32, i8* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 5
br i1 %11, label %12, label %13
12: ; preds = %9, %0
store i32 5, i32* %2
br label %13
13: ; preds = %12, %9
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fflush(i32 %15)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %41, %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %44
22: ; preds = %18
%23 = load i32, i32* %2
switch i32 %23, label %41 [
i32 1, label %24
i32 2, label %27
i32 3, label %30
i32 4, label %33
i32 5, label %37
]
24: ; preds = %22
%25 = load i8, i8* %3
%26 = call i32 @farfallino(i8 signext %25, i32 1)
br label %41
27: ; preds = %22
%28 = load i8, i8* %3
%29 = call i32 @vamavvo(i8 signext %28, i32 1)
br label %41
30: ; preds = %22
%31 = load i8, i8* %3
%32 = call i32 @urlata(i8 signext %31, i32 1)
br label %41
33: ; preds = %22
%34 = load i8, i8* %3
%35 = load i8, i8* %4
%36 = call i32 @fiorentina(i8 signext %34, i8 signext %35, i32 1)
br label %41
37: ; preds = %22
%38 = load i8, i8* %3
%39 = load i8, i8* %4
%40 = call i32 @all(i8 signext %38, i8 signext %39, i32 1)
br label %41
41: ; preds = %22, %37, %33, %30, %27, %24
%42 = load i8, i8* %3
store i8 %42, i8* %4
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %18
44: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str = [151 x i8] c"Modalita' disponibili:\0A1=Alfabeto Farfallino, \0A2=Variante del vamavvo, \0A3=Variante urlata, \0A4=Variante fiorentina, \0A5=Tutto!\0A\0AInserisci la modalita': \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%c\00"
@str = [23 x i8] c"\0AInserisci la stringa:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
store i8 48, i8* %2
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([151 x i8], [151 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -6
%8 = icmp ult i32 %7, -5
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 5, i32* %1
br label %10
10: ; preds = %0, %9
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fflush(i32 %12)
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%15 = load i8, i8* %2
%16 = icmp eq i8 %15, 10
br i1 %16, label %36, label %17
17: ; preds = %10, %31
%18 = phi i8 [ %34, %31 ], [ %15, %10 ]
%19 = phi i8 [ %32, %31 ], [ 32, %10 ]
%20 = load i32, i32* %1
switch i32 %20, label %31 [
i32 1, label %21
i32 2, label %23
i32 3, label %25
i32 4, label %27
i32 5, label %29
]
21: ; preds = %17
%22 = call i32 @farfallino(i8 signext %18, i32 1)
br label %31
23: ; preds = %17
%24 = call i32 @vamavvo(i8 signext %18, i32 1)
br label %31
25: ; preds = %17
%26 = call i32 @urlata(i8 signext %18, i32 1)
br label %31
27: ; preds = %17
%28 = call i32 @fiorentina(i8 signext %18, i8 signext %19, i32 1)
br label %31
29: ; preds = %17
%30 = call i32 @all(i8 signext %18, i8 signext %19, i32 1)
br label %31
31: ; preds = %17, %29, %27, %25, %23, %21
%32 = load i8, i8* %2
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%34 = load i8, i8* %2
%35 = icmp eq i8 %34, 10
br i1 %35, label %36, label %17
36: ; preds = %31, %10
ret i32 0
}