#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 *, ...);
main() {
  double price, total = 0, sum = 0, tax, final = 0;
  printf("Please enter your choice \n");
  int choice;
  scanf("%d", &choice);
  printf("Please enter the total purchase price \n");
  scanf("%lf", &price);
  if (choice == 1) {
    printf("Total purchases: %f \n", price);
    if (price > 100) {
      total = total + (price * 0.12);
      sum = sum + (price - total);
      printf("Teacher's discount (12%): %f \n", total);
      printf("Discounted total: %f \n", sum);
      tax = 0.05 * sum;
      final = final + tax + sum;
    } else if (price <= 100) {
      total = total + (price * 0.10);
      sum = sum + (price - total);
      printf("Teacher's discount (12%): %f \n", total);
      printf("Discounted total: %f \n", sum);
      tax = 0.05 * sum;
      final = final + tax + sum;
    }
  } else {
    total = total + price;
    sum = sum + total;
    tax = 0.05 * sum;
    final = final + tax + sum;
  }
  printf("The tax rate of 5%%: %f \n", tax);
  printf("The final price: %f \n", final);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0x34(%rbp)
jne    12e3 <main+0x1c3>
movsd  -0x10(%rbp),%xmm0
lea    0xecd(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1243 <main+0x123>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xde0(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12de <main+0x1be>
movsd  0xdbd(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     12d9 <main+0x1b9>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xda8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xde7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xdf3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xd45(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12de <main+0x1be>
jmp    1327 <main+0x207>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xcf7(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xd83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xd8a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf68(%rip),%rdi
call   1030 <puts@plt>
lea    0xed9(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf63(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x1,0xc(%rsp)
movsd  0x10(%rsp),%xmm1
jne    11b0 <main+0x80>
lea    0xea1(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm1
ucomisd 0xe61(%rip),%xmm1
movsd  %xmm1,(%rsp)
jbe    11ba <main+0x8a>
movsd  0xe62(%rip),%xmm0
jmp    11c2 <main+0x92>
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
jmp    1210 <main+0xe0>
movsd  0xe46(%rip),%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  (%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movsd  (%rsp),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm1
movsd  0xe00(%rip),%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please enter your choice \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"Please enter the total purchase price \0A\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [22 x i8] c"Total purchases: %f \0A\00"
@.str.5 = [31 x i8] c"Teacher's discount (12%): %f \0A\00"
@.str.6 = [23 x i8] c"Discounted total: %f \0A\00"
@.str.7 = [26 x i8] c"The tax rate of 5%%: %f \0A\00"
@.str.8 = [22 x i8] c"The final price: %f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %64
14: ; preds = %0
%15 = load double, double* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %15)
%17 = load double, double* %2
%18 = fcmp ogt double %17, 1.000000e+02
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = load double, double* %3
%21 = load double, double* %2
%22 = call double @llvm.fmuladd.f64(double %21, double 1.200000e-01, double %20)
store double %22, double* %3
%23 = load double, double* %4
%24 = load double, double* %2
%25 = load double, double* %3
%26 = fsub double %24, %25
%27 = fadd double %23, %26
store double %27, double* %4
%28 = load double, double* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %28)
%30 = load double, double* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %30)
%32 = load double, double* %4
%33 = fmul double 5.000000e-02, %32
store double %33, double* %5
%34 = load double, double* %6
%35 = load double, double* %5
%36 = fadd double %34, %35
%37 = load double, double* %4
%38 = fadd double %36, %37
store double %38, double* %6
br label %63
39: ; preds = %14
%40 = load double, double* %2
%41 = fcmp ole double %40, 1.000000e+02
br i1 %41, label %42, label %62
42: ; preds = %39
%43 = load double, double* %3
%44 = load double, double* %2
%45 = call double @llvm.fmuladd.f64(double %44, double 1.000000e-01, double %43)
store double %45, double* %3
%46 = load double, double* %4
%47 = load double, double* %2
%48 = load double, double* %3
%49 = fsub double %47, %48
%50 = fadd double %46, %49
store double %50, double* %4
%51 = load double, double* %3
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %51)
%53 = load double, double* %4
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %53)
%55 = load double, double* %4
%56 = fmul double 5.000000e-02, %55
store double %56, double* %5
%57 = load double, double* %6
%58 = load double, double* %5
%59 = fadd double %57, %58
%60 = load double, double* %4
%61 = fadd double %59, %60
store double %61, double* %6
br label %62
62: ; preds = %42, %39
br label %63
63: ; preds = %62, %19
br label %78
64: ; preds = %0
%65 = load double, double* %3
%66 = load double, double* %2
%67 = fadd double %65, %66
store double %67, double* %3
%68 = load double, double* %4
%69 = load double, double* %3
%70 = fadd double %68, %69
store double %70, double* %4
%71 = load double, double* %4
%72 = fmul double 5.000000e-02, %71
store double %72, double* %5
%73 = load double, double* %6
%74 = load double, double* %5
%75 = fadd double %73, %74
%76 = load double, double* %4
%77 = fadd double %75, %76
store double %77, double* %6
br label %78
78: ; preds = %64, %63
%79 = load double, double* %5
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), double %79)
%81 = load double, double* %6
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), double %81)
%83 = load i32, i32* %1
ret i32 %83
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [22 x i8] c"Total purchases: %f \0A\00"
@.str.5 = [31 x i8] c"Teacher's discount (12%): %f \0A\00"
@.str.6 = [23 x i8] c"Discounted total: %f \0A\00"
@.str.7 = [26 x i8] c"The tax rate of 5%%: %f \0A\00"
@.str.8 = [22 x i8] c"The final price: %f \0A\00"
@str = [26 x i8] c"Please enter your choice \00"
@str.9 = [39 x i8] c"Please enter the total purchase price \00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = bitcast double* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.9, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
%11 = load double, double* %1
br i1 %10, label %12, label %29
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %11)
%14 = load double, double* %1
%15 = fcmp ogt double %14, 1.000000e+02
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = call double @llvm.fmuladd.f64(double %14, double 1.200000e-01, double 0.000000e+00)
%18 = fsub double %14, %17
%19 = fadd double %18, 0.000000e+00
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %17)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %19)
br label %31
22: ; preds = %12
%23 = fcmp ole double %14, 1.000000e+02
%24 = call double @llvm.fmuladd.f64(double %14, double 1.000000e-01, double 0.000000e+00)
%25 = fsub double %14, %24
%26 = fadd double %25, 0.000000e+00
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %24)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %26)
br label %31
29: ; preds = %0
%30 = fadd double %11, 0.000000e+00
br label %31
31: ; preds = %16, %22, %29
%32 = phi double [ %19, %16 ], [ %26, %22 ], [ %30, %29 ]
%33 = fmul double %32, 5.000000e-02
%34 = fadd double %33, 0.000000e+00
%35 = fadd double %32, %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), double %33)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), double %35)
ret i32 0
}