#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 *, float *);
int main(void) {
  float loan_amount, interest_rate, payment, monthly_interest_rate;
  printf("Enter amount of loan: ");
  scanf("%f", &loan_amount);
  printf("Enter interest rate: ");
  scanf("%f", &interest_rate);
  printf("Enter monthly payment: ");
  scanf("%f", &payment);
  monthly_interest_rate = (interest_rate / 100) / 12;
  loan_amount = (loan_amount - payment) + (loan_amount * monthly_interest_rate);
  printf("Balance remaining after 1st payment: $%.2f\n", loan_amount);
  loan_amount = (loan_amount - payment) + (loan_amount * monthly_interest_rate);
  printf("Balance remaining after 2nd payment: $%.2f\n", loan_amount);
  loan_amount = (loan_amount - payment) + (loan_amount * monthly_interest_rate);
  printf("Balance remaining after 3rd payment: $%.2f\n", loan_amount);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  0xe6e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe5e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm2
divss  0xe77(%rip),%xmm2
divss  0xe73(%rip),%xmm2
movss  %xmm2,0x8(%rsp)
movss  (%rsp),%xmm0
movaps %xmm0,%xmm1
subss  0x4(%rsp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe93(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  (%rsp),%xmm0
movaps %xmm0,%xmm1
subss  0x4(%rsp),%xmm1
mulss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe90(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  (%rsp),%xmm0
movaps %xmm0,%xmm1
subss  0x4(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter amount of loan: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter interest rate: \00"
@.str.3 = [24 x i8] c"Enter monthly payment: \00"
@.str.4 = [44 x i8] c"Balance remaining after 1st payment: $%.2f\0A\00"
@.str.5 = [44 x i8] c"Balance remaining after 2nd payment: $%.2f\0A\00"
@.str.6 = [44 x i8] c"Balance remaining after 3rd payment: $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%12 = load float, float* %3
%13 = fdiv float %12, 1.000000e+02
%14 = fdiv float %13, 1.200000e+01
store float %14, float* %5
%15 = load float, float* %2
%16 = load float, float* %4
%17 = fsub float %15, %16
%18 = load float, float* %2
%19 = load float, float* %5
%20 = call float @llvm.fmuladd.f32(float %18, float %19, float %17)
store float %20, float* %2
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = load float, float* %2
%25 = load float, float* %4
%26 = fsub float %24, %25
%27 = load float, float* %2
%28 = load float, float* %5
%29 = call float @llvm.fmuladd.f32(float %27, float %28, float %26)
store float %29, float* %2
%30 = load float, float* %2
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %31)
%33 = load float, float* %2
%34 = load float, float* %4
%35 = fsub float %33, %34
%36 = load float, float* %2
%37 = load float, float* %5
%38 = call float @llvm.fmuladd.f32(float %36, float %37, float %35)
store float %38, float* %2
%39 = load float, float* %2
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter amount of loan: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter interest rate: \00"
@.str.3 = [24 x i8] c"Enter monthly payment: \00"
@.str.4 = [44 x i8] c"Balance remaining after 1st payment: $%.2f\0A\00"
@.str.5 = [44 x i8] c"Balance remaining after 2nd payment: $%.2f\0A\00"
@.str.6 = [44 x i8] c"Balance remaining after 3rd payment: $%.2f\0A\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = load float, float* %2
%14 = fdiv float %13, 1.000000e+02
%15 = fdiv float %14, 1.200000e+01
%16 = load float, float* %1
%17 = load float, float* %3
%18 = fsub float %16, %17
%19 = call float @llvm.fmuladd.f32(float %16, float %15, float %18)
store float %19, float* %1
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %20)
%22 = load float, float* %1
%23 = load float, float* %3
%24 = fsub float %22, %23
%25 = call float @llvm.fmuladd.f32(float %22, float %15, float %24)
store float %25, float* %1
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = load float, float* %1
%29 = load float, float* %3
%30 = fsub float %28, %29
%31 = call float @llvm.fmuladd.f32(float %28, float %15, float %30)
store float %31, float* %1
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %32)
ret i32 0
}