#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 main() {
  int stateCode;
  int chargeCode;
  int pricePerKg;
  int porcentTax;
  float totalChargePrice;
  float totalTaxValue;
  float totalPrice;
  float chargeWeightTon;
  float chargeWeightKg;
  printf("Please, insert the state code: ");
  scanf("%d", &stateCode);
  printf("\nPlease, insert the charge wight value (value in ton): ");
  scanf("%f", &chargeWeightTon);
  printf("\nPlease, insert the charge code: ");
  scanf("%d", &chargeCode);
  chargeWeightKg = (chargeWeightTon * 1000);
  if ((chargeCode >= 10) && (chargeCode <= 20)) {
    pricePerKg = 100;
  } else if ((chargeCode >= 21) && (chargeCode <= 30)) {
    pricePerKg = 250;
  } else if ((chargeCode >= 31) && (chargeCode <= 40)) {
    pricePerKg = 340;
  } else {
    return 0;
  }
  switch (stateCode) {
  case 1:
    porcentTax = 35;
    break;
  case 2:
    porcentTax = 25;
    break;
  case 3:
    porcentTax = 15;
    break;
  case 4:
    porcentTax = 5;
    break;
  case 5:
    porcentTax = 0;
    break;
  }
  totalChargePrice = (pricePerKg * chargeWeightKg);
  totalTaxValue = ((chargeWeightKg / 100) * porcentTax);
  totalPrice = totalChargePrice + totalTaxValue;
  printf("\n ------------------------------- \n");
  printf("The charge wieght in kg is: %.2f \n", chargeWeightKg);
  printf("The charge price is: %.2f \n", totalChargePrice);
  printf("The value tax is: %.2f \n", totalTaxValue);
  printf("The total price of weight is: %.2f", totalPrice);
  printf("\n ------------------------------- \n \n ");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  0xe69(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     11c1 <main+0xa1>
cmpl   $0x14,-0xc(%rbp)
jg     11c1 <main+0xa1>
movl   $0x64,-0x10(%rbp)
jmp    1217 <main+0xf7>
cmpl   $0x15,-0xc(%rbp)
jl     11e1 <main+0xc1>
cmpl   $0x1e,-0xc(%rbp)
jg     11e1 <main+0xc1>
movl   $0xfa,-0x10(%rbp)
jmp    1212 <main+0xf2>
cmpl   $0x1f,-0xc(%rbp)
jl     1201 <main+0xe1>
cmpl   $0x28,-0xc(%rbp)
jg     1201 <main+0xe1>
movl   $0x154,-0x10(%rbp)
jmp    120d <main+0xed>
movl   $0x0,-0x4(%rbp)
jmp    132c <main+0x20c>
jmp    1212 <main+0xf2>
jmp    1217 <main+0xf7>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x4,%eax
ja     1277 <main+0x157>
mov    -0x30(%rbp),%rax
lea    0xdd1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x23,-0x14(%rbp)
jmp    1277 <main+0x157>
movl   $0x19,-0x14(%rbp)
jmp    1277 <main+0x157>
movl   $0xf,-0x14(%rbp)
jmp    1277 <main+0x157>
movl   $0x5,-0x14(%rbp)
jmp    1277 <main+0x157>
movl   $0x0,-0x14(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  0xd71(%rip),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdee(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfa(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe01(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee6(%rip),%rbx
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefd(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeed(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm1
mov    0x18(%rsp),%eax
lea    -0xa(%rax),%ecx
cmp    $0xb,%ecx
jae    11b3 <main+0x83>
movss  0xe53(%rip),%xmm2
jmp    11d9 <main+0xa9>
lea    -0x15(%rax),%ecx
cmp    $0xa,%ecx
jae    11c5 <main+0x95>
movss  0xe45(%rip),%xmm2
jmp    11d9 <main+0xa9>
add    $0xffffffe1,%eax
cmp    $0x9,%eax
ja     12aa <main+0x17a>
movss  0xe33(%rip),%xmm2
mulss  0xe1f(%rip),%xmm1
mov    0x1c(%rsp),%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cmp    $0x3,%eax
ja     11fe <main+0xce>
cltq
lea    0xf5f(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
mulss  %xmm1,%xmm2
movss  %xmm2,0x8(%rsp)
movaps %xmm1,%xmm3
divss  0xdf1(%rip),%xmm3
mulss  %xmm0,%xmm3
movss  %xmm3,0xc(%rsp)
movaps %xmm2,%xmm0
addss  %xmm3,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xf01(%rip),%rdi
movss  %xmm1,0x4(%rsp)
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe52(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe53(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please, insert the state code: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"\0APlease, insert the charge wight value (value in ton): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [34 x i8] c"\0APlease, insert the charge code: \00"
@.str.5 = [36 x i8] c"\0A ------------------------------- \0A\00"
@.str.6 = [35 x i8] c"The charge wieght in kg is: %.2f \0A\00"
@.str.7 = [28 x i8] c"The charge price is: %.2f \0A\00"
@.str.8 = [25 x i8] c"The value tax is: %.2f \0A\00"
@.str.9 = [35 x i8] c"The total price of weight is: %.2f\00"
@.str.10 = [39 x i8] c"\0A ------------------------------- \0A \0A \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %9)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = load float, float* %9
%18 = fmul float %17, 1.000000e+03
store float %18, float* %10
%19 = load i32, i32* %3
%20 = icmp sge i32 %19, 10
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = load i32, i32* %3
%23 = icmp sle i32 %22, 20
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 100, i32* %4
br label %42
25: ; preds = %21, %0
%26 = load i32, i32* %3
%27 = icmp sge i32 %26, 21
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp sle i32 %29, 30
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 250, i32* %4
br label %41
32: ; preds = %28, %25
%33 = load i32, i32* %3
%34 = icmp sge i32 %33, 31
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* %3
%37 = icmp sle i32 %36, 40
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 340, i32* %4
br label %40
39: ; preds = %35, %32
store i32 0, i32* %1
br label %76
40: ; preds = %38
br label %41
41: ; preds = %40, %31
br label %42
42: ; preds = %41, %24
%43 = load i32, i32* %2
switch i32 %43, label %49 [
i32 1, label %44
i32 2, label %45
i32 3, label %46
i32 4, label %47
i32 5, label %48
]
44: ; preds = %42
store i32 35, i32* %5
br label %49
45: ; preds = %42
store i32 25, i32* %5
br label %49
46: ; preds = %42
store i32 15, i32* %5
br label %49
47: ; preds = %42
store i32 5, i32* %5
br label %49
48: ; preds = %42
store i32 0, i32* %5
br label %49
49: ; preds = %42, %48, %47, %46, %45, %44
%50 = load i32, i32* %4
%51 = sitofp i32 %50 to float
%52 = load float, float* %10
%53 = fmul float %51, %52
store float %53, float* %6
%54 = load float, float* %10
%55 = fdiv float %54, 1.000000e+02
%56 = load i32, i32* %5
%57 = sitofp i32 %56 to float
%58 = fmul float %55, %57
store float %58, float* %7
%59 = load float, float* %6
%60 = load float, float* %7
%61 = fadd float %59, %60
store float %61, float* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%63 = load float, float* %10
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), double %64)
%66 = load float, float* %6
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %67)
%69 = load float, float* %7
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %70)
%72 = load float, float* %8
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), double %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %76
76: ; preds = %49, %39
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [32 x i8] c"Please, insert the state code: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"\0APlease, insert the charge wight value (value in ton): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [34 x i8] c"\0APlease, insert the charge code: \00"
@.str.6 = [35 x i8] c"The charge wieght in kg is: %.2f \0A\00"
@.str.7 = [28 x i8] c"The charge price is: %.2f \0A\00"
@.str.8 = [25 x i8] c"The value tax is: %.2f \0A\00"
@.str.9 = [35 x i8] c"The total price of weight is: %.2f\00"
@.str.10 = [39 x i8] c"\0A ------------------------------- \0A \0A \00"
@str = [35 x i8] c"\0A ------------------------------- \00"
@switch.table.main = [4 x float] [float 3.500000e+01, float 2.500000e+01, float 1.500000e+01, float 5.000000e+00]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load float, float* %3
%14 = fmul float %13, 1.000000e+03
%15 = load i32, i32* %2
%16 = add i32 %15, -10
%17 = icmp ult i32 %16, 11
br i1 %17, label %24, label %18
18: ; preds = %0
%19 = add i32 %15, -21
%20 = icmp ult i32 %19, 10
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = add i32 %15, -31
%23 = icmp ult i32 %22, 10
br i1 %23, label %24, label %49
24: ; preds = %21, %18, %0
%25 = phi float [ 1.000000e+02, %0 ], [ 2.500000e+02, %18 ], [ 3.400000e+02, %21 ]
%26 = load i32, i32* %1
%27 = add i32 %26, -1
%28 = icmp ult i32 %27, 4
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = sext i32 %27 to i64
%31 = getelementptr inbounds [4 x float], [4 x float]* @switch.table.main, i64 0, i64 %30
%32 = load float, float* %31
br label %33
33: ; preds = %29, %24
%34 = phi float [ 0.000000e+00, %24 ], [ %32, %29 ]
%35 = fmul float %14, %25
%36 = fdiv float %14, 1.000000e+02
%37 = fmul float %36, %34
%38 = fadd float %35, %37
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%40 = fpext float %14 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), double %40)
%42 = fpext float %35 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %42)
%44 = fpext float %37 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %44)
%46 = fpext float %38 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), double %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %49
49: ; preds = %21, %33
ret i32 0
}