#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 = 0.0, rate = 0.0, monthly_payment = 0.0;
  printf("enter amount of loan:\n");
  scanf("%f", &loan);
  printf("enter interest rate:\n");
  scanf("%f", &rate);
  printf("enter monthly payment:\n");
  scanf("%f", &monthly_payment);
  loan = loan * (1 + rate / 1200) - monthly_payment;
  printf("balance remaining after first payment: %.2f\n", loan);
  loan = loan * (1 + rate / 1200) - monthly_payment;
  printf("balance remaining after second payment: %.2f\n", loan);
  loan = loan * (1 + rate / 1200) - monthly_payment;
  printf("balance remaining after third payment: %.2f\n", loan);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xe51(%rip),%xmm2
divss  %xmm2,%xmm1
movss  0xe41(%rip),%xmm2
addss  %xmm1,%xmm2
movss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xdf9(%rip),%xmm2
divss  %xmm2,%xmm1
movss  0xde9(%rip),%xmm2
addss  %xmm1,%xmm2
movss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe33(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xda1(%rip),%xmm2
divss  %xmm2,%xmm1
movss  0xd91(%rip),%xmm2
addss  %xmm1,%xmm2
movss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
divss  0xe53(%rip),%xmm0
addss  0xe4f(%rip),%xmm0
mulss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
divss  0xe19(%rip),%xmm0
addss  0xe15(%rip),%xmm0
mulss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
divss  0xddf(%rip),%xmm0
addss  0xddb(%rip),%xmm0
mulss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.4 = [45 x i8] c"balance remaining after first payment: %.2f\0A\00"
@.str.5 = [46 x i8] c"balance remaining after second payment: %.2f\0A\00"
@.str.6 = [45 x i8] c"balance remaining after third payment: %.2f\0A\00"
@str = [22 x i8] c"enter amount of loan:\00"
@str.7 = [21 x i8] c"enter interest rate:\00"
@str.8 = [23 x i8] c"enter monthly payment:\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, 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* %1
%14 = load float, float* %2
%15 = fdiv float %14, 1.200000e+03
%16 = fadd float %15, 1.000000e+00
%17 = load float, float* %3
%18 = fneg float %17
%19 = call float @llvm.fmuladd.f32(float %13, float %16, float %18)
store float %19, float* %1
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), double %20)
%22 = load float, float* %1
%23 = load float, float* %2
%24 = fdiv float %23, 1.200000e+03
%25 = fadd float %24, 1.000000e+00
%26 = load float, float* %3
%27 = fneg float %26
%28 = call float @llvm.fmuladd.f32(float %22, float %25, float %27)
store float %28, float* %1
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), double %29)
%31 = load float, float* %1
%32 = load float, float* %2
%33 = fdiv float %32, 1.200000e+03
%34 = fadd float %33, 1.000000e+00
%35 = load float, float* %3
%36 = fneg float %35
%37 = call float @llvm.fmuladd.f32(float %31, float %34, float %36)
store float %37, float* %1
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %38)
ret i32 0
}