#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 */
float getDiscount(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
int main() {
  float annual_rate, loan_total_pay, monthly_pay, extra_pay, discnt, amount,
      years;
  printf("Please enter Loan Amount, Years and Interest rate. Use space to "
         "separate them. \n");
  scanf("%f %f %f", &amount, &years, &annual_rate);
  discnt = getDiscount(years, annual_rate);
  monthly_pay = amount / discnt;
  loan_total_pay = monthly_pay * 12 * years;
  extra_pay = loan_total_pay - amount;
  printf("Monthly payment is: %.2f. \nTotal payback is: %.2f\nExtra pay to the "
         "loan is: %.2f\n",
         monthly_pay, loan_total_pay, extra_pay);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <scanf@plt>
movss  -0x20(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <getDiscount@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe70(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe8e(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
call   1050 <getDiscount@plt>
movss  0x10(%rsp),%xmm2
movaps %xmm2,%xmm3
divss  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulss  0xe68(%rip),%xmm3
mulss  0xc(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
subss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
lea    0xe56(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [81 x i8] c"Please enter Loan Amount, Years and Interest rate. Use space to separate them. \0A\00"
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.2 = [82 x i8] c"Monthly payment is: %.2f. \0ATotal payback is: %.2f\0AExtra pay to the loan is: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %7, float* %8, float* %2)
%11 = load float, float* %8
%12 = load float, float* %2
%13 = call float @getDiscount(float %11, float %12)
store float %13, float* %6
%14 = load float, float* %7
%15 = load float, float* %6
%16 = fdiv float %14, %15
store float %16, float* %4
%17 = load float, float* %4
%18 = fmul float %17, 1.200000e+01
%19 = load float, float* %8
%20 = fmul float %18, %19
store float %20, float* %3
%21 = load float, float* %3
%22 = load float, float* %7
%23 = fsub float %21, %22
store float %23, float* %5
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = load float, float* %3
%27 = fpext float %26 to double
%28 = load float, float* %5
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), double %25, double %27, double %29)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.2 = [82 x i8] c"Monthly payment is: %.2f. \0ATotal payback is: %.2f\0AExtra pay to the loan is: %.2f\0A\00"
@str = [80 x i8] c"Please enter Loan Amount, Years and Interest rate. Use space to separate them. \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %1)
%9 = load float, float* %3
%10 = load float, float* %1
%11 = call float @getDiscount(float %9, float %10)
%12 = load float, float* %2
%13 = fdiv float %12, %11
%14 = fmul float %13, 1.200000e+01
%15 = load float, float* %3
%16 = fmul float %15, %14
%17 = fsub float %16, %12
%18 = fpext float %13 to double
%19 = fpext float %16 to double
%20 = fpext float %17 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), double %18, double %19, double %20)
ret i32 0
}