#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 */
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
main() {
  double interest;
  double payment;
  double principal;
  long number_of_payments;
  printf("enter amount to be borrowed : ");
  scanf("%lf", &principal);
  printf("enter interest per year (percent) : ");
  scanf("%lf", &interest);
  interest = interest / 100.0;
  printf("enter number of years (12 payments per year) : ");
  scanf("%ld", &number_of_payments);
  number_of_payments *= 12;
  interest = interest / 12.0;
  payment = principal * interest /
            (1.0 - pow((1.0 + interest), -1.0 * (double)number_of_payments));
  printf("\nMonthly payment = %7.2lf\n", payment);
  printf("\nTotal payment   = %7.2lf\n", (double)number_of_payments * payment);
  interest /= 2.0;
  number_of_payments *= 2;
  payment = principal * interest /
            (1.0 - pow((1.0 + interest), -1.0 * (double)number_of_payments));
  printf("\nBiweekly payment = %7.2lf\n", payment);
  printf("\nTotal payment   = %7.2lf\n", (double)number_of_payments * payment);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
imul   $0xc,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe1c(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm2
movsd  0xe11(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdq -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
lea    0xe7d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xdba(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xd7e(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm2
movsd  0xd73(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xd52(%rip),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdq -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf05(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xef3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0xe7c(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xee7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
shl    $0x2,%rax
lea    (%rax,%rax,2),%rax
mov    %rax,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0xe3d(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
addsd  0xe28(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
xorpd  0xe28(%rip),%xmm1
call   1050 <pow@plt>
movsd  0xe0b(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x8(%rsp),%xmm0
mulsd  (%rsp),%xmm0
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xdc5(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rax
add    %rax,%rax
mov    %rax,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
addsd  0xd93(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
xorpd  0xd93(%rip),%xmm1
call   1050 <pow@plt>
movsd  0xd76(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdq 0x8(%rsp),%xmm0
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"enter amount to be borrowed : \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [37 x i8] c"enter interest per year (percent) : \00"
@.str.3 = [48 x i8] c"enter number of years (12 payments per year) : \00"
@.str.4 = [4 x i8] c"%ld\00"
@.str.5 = [27 x i8] c"\0AMonthly payment = %7.2lf\0A\00"
@.str.6 = [27 x i8] c"\0ATotal payment = %7.2lf\0A\00"
@.str.7 = [28 x i8] c"\0ABiweekly payment = %7.2lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i64
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = load double, double* %1
%10 = fdiv double %9, 1.000000e+02
store double %10, double* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %4)
%13 = load i64, i64* %4
%14 = mul nsw i64 %13, 12
store i64 %14, i64* %4
%15 = load double, double* %1
%16 = fdiv double %15, 1.200000e+01
store double %16, double* %1
%17 = load double, double* %3
%18 = load double, double* %1
%19 = fmul double %17, %18
%20 = load double, double* %1
%21 = fadd double 1.000000e+00, %20
%22 = load i64, i64* %4
%23 = sitofp i64 %22 to double
%24 = fmul double -1.000000e+00, %23
%25 = call double @pow(double %21, double %24)
%26 = fsub double 1.000000e+00, %25
%27 = fdiv double %19, %26
store double %27, double* %2
%28 = load double, double* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %28)
%30 = load i64, i64* %4
%31 = sitofp i64 %30 to double
%32 = load double, double* %2
%33 = fmul double %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %33)
%35 = load double, double* %1
%36 = fdiv double %35, 2.000000e+00
store double %36, double* %1
%37 = load i64, i64* %4
%38 = mul nsw i64 %37, 2
store i64 %38, i64* %4
%39 = load double, double* %3
%40 = load double, double* %1
%41 = fmul double %39, %40
%42 = load double, double* %1
%43 = fadd double 1.000000e+00, %42
%44 = load i64, i64* %4
%45 = sitofp i64 %44 to double
%46 = fmul double -1.000000e+00, %45
%47 = call double @pow(double %43, double %46)
%48 = fsub double 1.000000e+00, %47
%49 = fdiv double %41, %48
store double %49, double* %2
%50 = load double, double* %2
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %50)
%52 = load i64, i64* %4
%53 = sitofp i64 %52 to double
%54 = load double, double* %2
%55 = fmul double %53, %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"enter amount to be borrowed : \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [37 x i8] c"enter interest per year (percent) : \00"
@.str.3 = [48 x i8] c"enter number of years (12 payments per year) : \00"
@.str.4 = [4 x i8] c"%ld\00"
@.str.5 = [27 x i8] c"\0AMonthly payment = %7.2lf\0A\00"
@.str.6 = [27 x i8] c"\0ATotal payment = %7.2lf\0A\00"
@.str.7 = [28 x i8] c"\0ABiweekly payment = %7.2lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i64
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%11 = load double, double* %1
%12 = fdiv double %11, 1.000000e+02
store double %12, double* %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %3)
%15 = load i64, i64* %3
%16 = mul nsw i64 %15, 12
store i64 %16, i64* %3
%17 = load double, double* %1
%18 = fdiv double %17, 1.200000e+01
store double %18, double* %1
%19 = load double, double* %2
%20 = fmul double %18, %19
%21 = fadd double %18, 1.000000e+00
%22 = sitofp i64 %16 to double
%23 = fneg double %22
%24 = call double @pow(double %21, double %23)
%25 = fsub double 1.000000e+00, %24
%26 = fdiv double %20, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = load i64, i64* %3
%29 = sitofp i64 %28 to double
%30 = fmul double %26, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %30)
%32 = load double, double* %1
%33 = fmul double %32, 5.000000e-01
store double %33, double* %1
%34 = load i64, i64* %3
%35 = shl nsw i64 %34, 1
store i64 %35, i64* %3
%36 = load double, double* %2
%37 = fmul double %33, %36
%38 = fadd double %33, 1.000000e+00
%39 = sitofp i64 %35 to double
%40 = fneg double %39
%41 = call double @pow(double %38, double %40)
%42 = fsub double 1.000000e+00, %41
%43 = fdiv double %37, %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %43)
%45 = load i64, i64* %3
%46 = sitofp i64 %45 to double
%47 = fmul double %43, %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %47)
ret i32 0
}