#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 *, unsigned int *);
int main() {
  unsigned int nmazzi;
  unsigned int incasso;
  unsigned int minprezzo;
  unsigned int maxprezzo;
  unsigned int prezzo;
  unsigned int richiesta;
  unsigned int buffer;
  unsigned int media;
  unsigned int _PREZZO_MAX;
  unsigned int i;
  _PREZZO_MAX = 101;
  minprezzo = _PREZZO_MAX;
  maxprezzo = 0;
  nmazzi = 0;
  incasso = 0;
  i = 0;
  printf("Fred v1.1. Sei un dannato Stakhanovista, ricordatelo sempre. E non "
         "chiamarmi Rosario.\n");
  while (i < 1) {
    printf("\nSpecificare una richiesta: [1] per il capo, [2] per il cliente, "
           "[3] per mandarmi (finalmente) a casa: ");
    scanf("%i", &buffer);
    richiesta = buffer;
    switch (richiesta) {
    case 1:
      if (nmazzi != 0) {
        printf("\nMAX prezzo: €%d", maxprezzo);
        printf("\nMIN prezzo: €%i", minprezzo);
        printf("\nNumero mazzi venduti: %i", nmazzi);
        media = (incasso / nmazzi);
        printf("\nPrezzo medio per mazzo: €%i", media);
        printf("\nSei un dannato Stakhanovista");
      } else {
        printf("\nPer ora non ho venduto niente, e tu sei un dannato "
               "Stakhanovista.");
      }
      break;
    case 2:
      printf("\nInserire il prezzo: ");
      scanf("%i", &buffer);
      prezzo = buffer;
      if (prezzo > _PREZZO_MAX) {
        printf("\nQui non si vendono mazzi a più di 100€. Vendita non "
               "registrata.");
      } else {
        if (prezzo < minprezzo && prezzo < _PREZZO_MAX) {
          minprezzo = prezzo;
        }
        if (prezzo > maxprezzo && prezzo < _PREZZO_MAX) {
          maxprezzo = prezzo;
        }
        nmazzi++;
        incasso += prezzo;
      }
      break;
    case 3:
      printf("Arrivederci! Ora ho perso tutte le variabili memorizzate perché "
             "sono MALVAGIO! Muahahahahah! Hai bessu, sporco capitalista. \n");
      return 0;
      break;
    default:
      printf("\nRichiesta non valida, ora ti denuncio per mobbing.");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x65,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x2c(%rbp)
jae    130c <main+0x1ec>
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf77(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x1,%eax
je     11ca <main+0xaa>
jmp    11a8 <main+0x88>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     1249 <main+0x129>
jmp    11b9 <main+0x99>
mov    -0x30(%rbp),%eax
sub    $0x3,%eax
je     12df <main+0x1bf>
jmp    12f9 <main+0x1d9>
cmpl   $0x0,-0x8(%rbp)
je     1236 <main+0x116>
mov    -0x14(%rbp),%esi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1307 <main+0x1e7>
lea    0xf2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jbe    128c <main+0x16c>
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12da <main+0x1ba>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    12aa <main+0x18a>
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    12aa <main+0x18a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jbe    12c8 <main+0x1a8>
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    12c8 <main+0x1a8>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1307 <main+0x1e7>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130c <main+0x1ec>
lea    0xf58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1166 <main+0x46>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x1074(%rip),%rdi
call   1030 <puts@plt>
movl   $0x65,(%rsp)
lea    0xeab(%rip),%r15
lea    0xf49(%rip),%rbp
lea    0x4(%rsp),%rbx
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    11a4 <main+0x74>
nopl   0x0(%rax)
lea    0xfb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x66,%eax
jb     123c <main+0x10c>
lea    0xfa1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11e0 <main+0xb0>
cmp    $0x2,%eax
je     1170 <main+0x40>
cmp    $0x3,%eax
je     1272 <main+0x142>
lea    0xfab(%rip),%rdi
jmp    119d <main+0x6d>
nopl   0x0(%rax)
test   %r14d,%r14d
je     1263 <main+0x133>
lea    0xe7c(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%eax
xor    %edx,%edx
div    %r14d
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
jmp    119d <main+0x6d>
mov    (%rsp),%ecx
cmp    %ecx,%eax
cmovb  %eax,%ecx
mov    %ecx,(%rsp)
cmp    $0x65,%eax
mov    %r12d,%ecx
cmovne %eax,%ecx
cmp    %r12d,%eax
cmova  %ecx,%r12d
add    $0x1,%r14d
add    %eax,%r13d
jmp    11a4 <main+0x74>
xor    %r14d,%r14d
lea    0xe78(%rip),%rdi
jmp    119d <main+0x6d>
lea    0xf93(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [87 x i8] c"Fred v1.1. Sei un dannato Stakhanovista, ricordatelo sempre. E non chiamarmi Rosario.\0A\00"
@.str.1 = [104 x i8] c"\0ASpecificare una richiesta: [1] per il capo, [2] per il cliente, [3] per mandarmi (finalmente) a casa: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [19 x i8] c"\0AMAX prezzo: \E2\82\AC%d\00"
@.str.4 = [19 x i8] c"\0AMIN prezzo: \E2\82\AC%i\00"
@.str.5 = [26 x i8] c"\0ANumero mazzi venduti: %i\00"
@.str.6 = [31 x i8] c"\0APrezzo medio per mazzo: \E2\82\AC%i\00"
@.str.7 = [30 x i8] c"\0ASei un dannato Stakhanovista\00"
@.str.8 = [67 x i8] c"\0APer ora non ho venduto niente, e tu sei un dannato Stakhanovista.\00"
@.str.9 = [22 x i8] c"\0AInserire il prezzo: \00"
@.str.10 = [68 x i8] c"\0AQui non si vendono mazzi a pi\C3\B9 di 100\E2\82\AC. Vendita non registrata.\00"
@.str.11 = [127 x i8] c"Arrivederci! Ora ho perso tutte le variabili memorizzate perch\C3\A9 sono MALVAGIO! Muahahahahah! Hai bessu, sporco capitalista. \0A\00"
@.str.12 = [52 x i8] c"\0ARichiesta non valida, ora ti denuncio per mobbing.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i32 101, i32* %10
%12 = load i32, i32* %10
store i32 %12, i32* %4
store i32 0, i32* %5
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %81, %0
%15 = load i32, i32* %11
%16 = icmp ult i32 %15, 1
br i1 %16, label %17, label %82
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%20 = load i32, i32* %8
store i32 %20, i32* %7
%21 = load i32, i32* %7
switch i32 %21, label %79 [
i32 1, label %22
i32 2, label %41
i32 3, label %77
]
22: ; preds = %17
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %22
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = udiv i32 %32, %33
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %40
38: ; preds = %22
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %38, %25
br label %81
41: ; preds = %17
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%44 = load i32, i32* %8
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = load i32, i32* %10
%47 = icmp ugt i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0))
br label %76
50: ; preds = %41
%51 = load i32, i32* %6
%52 = load i32, i32* %4
%53 = icmp ult i32 %51, %52
br i1 %53, label %54, label %60
54: ; preds = %50
%55 = load i32, i32* %6
%56 = load i32, i32* %10
%57 = icmp ult i32 %55, %56
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = load i32, i32* %6
store i32 %59, i32* %4
br label %60
60: ; preds = %58, %54, %50
%61 = load i32, i32* %6
%62 = load i32, i32* %5
%63 = icmp ugt i32 %61, %62
br i1 %63, label %64, label %70
64: ; preds = %60
%65 = load i32, i32* %6
%66 = load i32, i32* %10
%67 = icmp ult i32 %65, %66
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = load i32, i32* %6
store i32 %69, i32* %5
br label %70
70: ; preds = %68, %64, %60
%71 = load i32, i32* %2
%72 = add i32 %71, 1
store i32 %72, i32* %2
%73 = load i32, i32* %6
%74 = load i32, i32* %3
%75 = add i32 %74, %73
store i32 %75, i32* %3
br label %76
76: ; preds = %70, %48
br label %81
77: ; preds = %17
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %1
br label %82
79: ; preds = %17
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
br label %81
81: ; preds = %79, %76, %40
br label %14
82: ; preds = %77, %14
%83 = load i32, i32* %1
ret i32 %83
}

LLVM IR (-O2):
@.str.1 = [104 x i8] c"\0ASpecificare una richiesta: [1] per il capo, [2] per il cliente, [3] per mandarmi (finalmente) a casa: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [19 x i8] c"\0AMAX prezzo: \E2\82\AC%d\00"
@.str.4 = [19 x i8] c"\0AMIN prezzo: \E2\82\AC%i\00"
@.str.5 = [26 x i8] c"\0ANumero mazzi venduti: %i\00"
@.str.6 = [31 x i8] c"\0APrezzo medio per mazzo: \E2\82\AC%i\00"
@.str.7 = [30 x i8] c"\0ASei un dannato Stakhanovista\00"
@.str.8 = [67 x i8] c"\0APer ora non ho venduto niente, e tu sei un dannato Stakhanovista.\00"
@.str.9 = [22 x i8] c"\0AInserire il prezzo: \00"
@.str.10 = [68 x i8] c"\0AQui non si vendono mazzi a pi\C3\B9 di 100\E2\82\AC. Vendita non registrata.\00"
@.str.12 = [52 x i8] c"\0ARichiesta non valida, ora ti denuncio per mobbing.\00"
@str = [86 x i8] c"Fred v1.1. Sei un dannato Stakhanovista, ricordatelo sempre. E non chiamarmi Rosario.\00"
@str.13 = [126 x i8] c"Arrivederci! Ora ho perso tutte le variabili memorizzate perch\C3\A9 sono MALVAGIO! Muahahahahah! Hai bessu, sporco capitalista. \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %34, %0
%5 = phi i32 [ %40, %34 ], [ 0, %0 ]
%6 = phi i32 [ %36, %34 ], [ 101, %0 ]
%7 = phi i32 [ %42, %34 ], [ 0, %0 ]
%8 = phi i32 [ %41, %34 ], [ 0, %0 ]
br label %9
9: ; preds = %4, %24
%10 = phi i32 [ %8, %4 ], [ 0, %24 ]
%11 = icmp eq i32 %10, 0
br label %12
12: ; preds = %33, %9
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
switch i32 %15, label %45 [
i32 1, label %16
i32 2, label %26
i32 3, label %43
]
16: ; preds = %12
br i1 %11, label %24, label %17
17: ; preds = %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %6)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%21 = udiv i32 %7, %10
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %33
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
br label %9
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%29 = load i32, i32* %1
%30 = icmp ugt i32 %29, 101
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0))
br label %33
33: ; preds = %31, %17, %45
br label %12
34: ; preds = %26
%35 = icmp ult i32 %29, %6
%36 = select i1 %35, i32 %29, i32 %6
%37 = icmp ugt i32 %29, %5
%38 = icmp ne i32 %29, 101
%39 = and i1 %37, %38
%40 = select i1 %39, i32 %29, i32 %5
%41 = add i32 %10, 1
%42 = add i32 %29, %7
br label %4
43: ; preds = %12
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([126 x i8], [126 x i8]* @str.13, i64 0, i64 0))
ret i32 0
45: ; preds = %12
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
br label %33
}