#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*/ incrementaContatore(unsigned int *, double);
double numeroArrotondatoAIntero(double);
double percentualeSuImporto(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  double venditeSettimanali;
  double guadagnoCommissioni;
  double guadagnoTotale;
  unsigned int rangeGuadagni[10] = {0};
  int valoreSentinella = -1;
  do {
    printf("%s", "Inserire venditeSettimanali (inserisci -1 per terminare): ");
    scanf("%lf", &venditeSettimanali);
    if (venditeSettimanali >= 0) {
      rangeGuadagni[0]++;
      guadagnoCommissioni = percentualeSuImporto(venditeSettimanali, 9.00);
      guadagnoTotale = (200.00 + guadagnoCommissioni);
      guadagnoTotale = numeroArrotondatoAIntero(guadagnoTotale);
      incrementaContatore(rangeGuadagni, guadagnoTotale);
    }
  } while (venditeSettimanali != valoreSentinella);
  printf("\nI %d di vendita hanno guadagnato rispettivamente: \n",
         rangeGuadagni[0]);
  rangeGuadagni[0] = 1;
  while (rangeGuadagni[0] < 9) {
    printf("N %d Agenti tra i $%d00 - %d99\n", rangeGuadagni[rangeGuadagni[0]],
           rangeGuadagni[0] + 1, rangeGuadagni[0] + 1);
    rangeGuadagni[0]++;
  }
  printf("N %d Agenti oltre i $%d00.\n", rangeGuadagni[rangeGuadagni[0]],
         rangeGuadagni[0] + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movl   $0xffffffff,-0x54(%rbp)
lea    0xe83(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     120c <main+0xac>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe35(%rip),%xmm1
call   1080 <percentualeSuImporto@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe1b(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <numeroArrotondatoAIntero@plt>
movsd  %xmm0,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1070 <incrementaContatore@plt>
jmp    1211 <main+0xb1>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jne    1186 <main+0x26>
jp     1186 <main+0x26>
mov    -0x50(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x50(%rbp)
cmpl   $0x9,-0x50(%rbp)
jae    127c <main+0x11c>
mov    -0x50(%rbp),%eax
mov    -0x50(%rbp,%rax,4),%esi
mov    -0x50(%rbp),%edx
add    $0x1,%edx
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1243 <main+0xe3>
mov    -0x50(%rbp),%eax
mov    -0x50(%rbp,%rax,4),%esi
mov    -0x50(%rbp),%edx
add    $0x1,%edx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xea3(%rip),%r14
lea    0xe9f(%rip),%r15
lea    0xed3(%rip),%r12
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r13
jmp    11ac <main+0x5c>
nopw   0x0(%rax,%rax,1)
ucomisd 0xe68(%rip),%xmm0
jne    11ac <main+0x5c>
jnp    1203 <main+0xb3>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe46(%rip),%xmm0
jb     11a0 <main+0x50>
addl   $0x1,0x10(%rsp)
movsd  0xe1f(%rip),%xmm1
call   1070 <percentualeSuImporto@plt>
addsd  0xe1a(%rip),%xmm0
call   1040 <numeroArrotondatoAIntero@plt>
mov    %r13,%rdi
call   1060 <incrementaContatore@plt>
movsd  0x8(%rsp),%xmm0
jmp    11a0 <main+0x50>
mov    0x10(%rsp),%esi
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x1,0x10(%rsp)
mov    $0x1,%ecx
lea    0xe6e(%rip),%rbx
nopl   0x0(%rax)
mov    %ecx,%eax
mov    0x10(%rsp,%rax,4),%esi
add    $0x1,%ecx
mov    %rbx,%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
lea    0x1(%rdx),%ecx
mov    %ecx,0x10(%rsp)
cmp    $0x9,%ecx
jb     1230 <main+0xe0>
mov    %ecx,%eax
mov    0x10(%rsp,%rax,4),%esi
add    $0x2,%edx
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [59 x i8] c"Inserire venditeSettimanali (inserisci -1 per terminare): \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [53 x i8] c"\0AI %d di vendita hanno guadagnato rispettivamente: \0A\00"
@.str.4 = [32 x i8] c"N %d Agenti tra i $%d00 - %d99\0A\00"
@.str.5 = [28 x i8] c"N %d Agenti oltre i $%d00.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [10 x i32]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i32]* %5 to i8*
store i32 -1, i32* %6
br label %8
8: ; preds = %27, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%11 = load double, double* %2
%12 = fcmp oge double %11, 0.000000e+00
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%15 = load i32, i32* %14
%16 = add i32 %15, 1
store i32 %16, i32* %14
%17 = load double, double* %2
%18 = call double @percentualeSuImporto(double %17, double 9.000000e+00)
store double %18, double* %3
%19 = load double, double* %3
%20 = fadd double 2.000000e+02, %19
store double %20, double* %4
%21 = load double, double* %4
%22 = call double @numeroArrotondatoAIntero(double %21)
store double %22, double* %4
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%24 = load double, double* %4
%25 = call i32 @incrementaContatore(i32* %23, double %24)
br label %26
26: ; preds = %13, %8
br label %27
27: ; preds = %26
%28 = load double, double* %2
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to double
%31 = fcmp une double %28, %30
br i1 %31, label %8, label %32
32: ; preds = %27
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
store i32 1, i32* %36
br label %37
37: ; preds = %41, %32
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%39 = load i32, i32* %38
%40 = icmp ult i32 %39, 9
br i1 %40, label %41, label %57
41: ; preds = %37
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%43 = load i32, i32* %42
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%48 = load i32, i32* %47
%49 = add i32 %48, 1
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%51 = load i32, i32* %50
%52 = add i32 %51, 1
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %49, i32 %52)
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%55 = load i32, i32* %54
%56 = add i32 %55, 1
store i32 %56, i32* %54
br label %37
57: ; preds = %37
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%59 = load i32, i32* %58
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%64 = load i32, i32* %63
%65 = add i32 %64, 1
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %62, i32 %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [59 x i8] c"Inserire venditeSettimanali (inserisci -1 per terminare): \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [53 x i8] c"\0AI %d di vendita hanno guadagnato rispettivamente: \0A\00"
@.str.4 = [32 x i8] c"N %d Agenti tra i $%d00 - %d99\0A\00"
@.str.5 = [28 x i8] c"N %d Agenti oltre i $%d00.\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca [10 x i32]
%3 = bitcast double* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
br label %6
6: ; preds = %19, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%9 = load double, double* %1
%10 = fcmp ult double %9, 0.000000e+00
br i1 %10, label %19, label %11
11: ; preds = %6
%12 = load i32, i32* %5
%13 = add i32 %12, 1
store i32 %13, i32* %5
%14 = call double @percentualeSuImporto(double %9, double 9.000000e+00)
%15 = fadd double %14, 2.000000e+02
%16 = call double @numeroArrotondatoAIntero(double %15)
%17 = call i32 @incrementaContatore(i32* %5, double %16)
%18 = load double, double* %1
br label %19
19: ; preds = %6, %11
%20 = phi double [ %9, %6 ], [ %18, %11 ]
%21 = fcmp une double %20, -1.000000e+00
br i1 %21, label %6, label %22
22: ; preds = %19
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %23)
store i32 1, i32* %5
br label %25
25: ; preds = %22, %25
%26 = phi i32 [ 1, %22 ], [ %33, %25 ]
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = add nuw nsw i32 %26, 1
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30, i32 %30)
%32 = load i32, i32* %5
%33 = add i32 %32, 1
store i32 %33, i32* %5
%34 = icmp ult i32 %33, 9
br i1 %34, label %25, label %35
35: ; preds = %25
%36 = zext i32 %33 to i64
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = add i32 %32, 2
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %38, i32 %39)
ret i32 0
}