#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 *, ...);
int main(void) {
  float loan = -1;
  float yearlyInterest = -1;
  float monthlyInterest = -1;
  float monthlyPayment = -1;
  int n = -1;
  float balance;
  int counter = 1;
  float lastPay;
  while (loan < 0) {
    printf("Please enter the loan value: ");
    scanf("%f", &loan);
  }
  while (yearlyInterest < 0) {
    printf("Please enter the yearly interest value: ");
    scanf("%f", &yearlyInterest);
  }
  while (monthlyPayment < 0) {
    printf("Please enter the monthly payment value: ");
    scanf("%f", &monthlyPayment);
  }
  while (n < 0) {
    printf("Please enter the value of the number of monthly payments: ");
    scanf("%d", &n);
  }
  yearlyInterest = yearlyInterest / 100;
  monthlyInterest = yearlyInterest / 12;
  balance = loan;
  while ((counter <= n) && (balance >= 0)) {
    lastPay = balance + (balance * monthlyInterest);
    balance = balance + (balance * monthlyInterest) - monthlyPayment;
    printf("The balance after %d payment(s): \n", counter);
    if (balance < 0) {
      printf("0.00 \n");
    } else {
      printf("%.2f \n", balance);
    }
    if (balance <= 0) {
      printf("The amount of the last payment is: %.2f \n", lastPay);
    }
    counter++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xebc(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11a3 <main+0x83>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1171 <main+0x51>
jmp    11a8 <main+0x88>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11da <main+0xba>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    11a8 <main+0x88>
jmp    11df <main+0xbf>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1211 <main+0xf1>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe29(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    11df <main+0xbf>
jmp    1216 <main+0xf6>
cmpl   $0x0,-0x18(%rbp)
jge    1245 <main+0x125>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1216 <main+0xf6>
movss  -0xc(%rbp),%xmm0
movss  0xdb6(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xd9c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x25(%rbp)
jg     129d <main+0x17d>
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
setae  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    12ad <main+0x18d>
jmp    1364 <main+0x244>
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    131b <main+0x1fb>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1332 <main+0x212>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jb     1356 <main+0x236>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    127b <main+0x15b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0xbf800000,0x18(%rsp)
bf
movl   $0xbf800000,0x4(%rsp)
bf
movl   $0xbf800000,0x14(%rsp)
bf
movl   $0xffffffff,0x10(%rsp)
ff
lea    0xea8(%rip),%r14
lea    0xebf(%rip),%r15
lea    0x18(%rsp),%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss 0x18(%rsp),%xmm0
ja     1170 <main+0x40>
lea    0xe95(%rip),%r14
lea    0xe8b(%rip),%r15
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss 0x4(%rsp),%xmm0
ja     11b0 <main+0x80>
lea    0xe7e(%rip),%r14
lea    0xe4b(%rip),%r15
lea    0x14(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss 0x14(%rsp),%xmm0
ja     11f0 <main+0xc0>
lea    0xe67(%rip),%r14
lea    0xe9b(%rip),%r15
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
js     1230 <main+0x100>
movss  0x4(%rsp),%xmm0
divss  0xda4(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
movss  %xmm0,0x4(%rsp)
je     135b <main+0x22b>
movss  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     135b <main+0x22b>
movss  0x8(%rsp),%xmm0
divss  0xd76(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
mov    $0x1,%ebx
lea    0xe1d(%rip),%r14
lea    0xe63(%rip),%r15
lea    0xe32(%rip),%r12
lea    0xe4e(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
movaps %xmm1,%xmm0
mulss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x1c(%rsp)
subss  0x14(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    1310 <main+0x1e0>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    131e <main+0x1ee>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jb     1349 <main+0x219>
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm0,%xmm0
cmp    0x10(%rsp),%ebx
jge    135b <main+0x22b>
add    $0x1,%ebx
ucomiss %xmm0,%xmm1
jae    12c0 <main+0x190>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please enter the loan value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [41 x i8] c"Please enter the yearly interest value: \00"
@.str.3 = [41 x i8] c"Please enter the monthly payment value: \00"
@.str.4 = [59 x i8] c"Please enter the value of the number of monthly payments: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [35 x i8] c"The balance after %d payment(s): \0A\00"
@.str.7 = [7 x i8] c"0.00 \0A\00"
@.str.8 = [7 x i8] c"%.2f \0A\00"
@.str.9 = [42 x i8] c"The amount of the last payment is: %.2f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %1
store float -1.000000e+00, float* %2
store float -1.000000e+00, float* %3
store float -1.000000e+00, float* %4
store float -1.000000e+00, float* %5
store i32 -1, i32* %6
store i32 1, i32* %8
br label %10
10: ; preds = %13, %0
%11 = load float, float* %2
%12 = fcmp olt float %11, 0.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
br label %10
16: ; preds = %10
br label %17
17: ; preds = %20, %16
%18 = load float, float* %3
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
br label %17
23: ; preds = %17
br label %24
24: ; preds = %27, %23
%25 = load float, float* %5
%26 = fcmp olt float %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
br label %24
30: ; preds = %24
br label %31
31: ; preds = %34, %30
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
br label %31
37: ; preds = %31
%38 = load float, float* %3
%39 = fdiv float %38, 1.000000e+02
store float %39, float* %3
%40 = load float, float* %3
%41 = fdiv float %40, 1.200000e+01
store float %41, float* %4
%42 = load float, float* %2
store float %42, float* %7
br label %43
43: ; preds = %80, %37
%44 = load i32, i32* %8
%45 = load i32, i32* %6
%46 = icmp sle i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load float, float* %7
%49 = fcmp oge float %48, 0.000000e+00
br label %50
50: ; preds = %47, %43
%51 = phi i1 [ false, %43 ], [ %49, %47 ]
br i1 %51, label %52, label %83
52: ; preds = %50
%53 = load float, float* %7
%54 = load float, float* %7
%55 = load float, float* %4
%56 = call float @llvm.fmuladd.f32(float %54, float %55, float %53)
store float %56, float* %9
%57 = load float, float* %7
%58 = load float, float* %7
%59 = load float, float* %4
%60 = call float @llvm.fmuladd.f32(float %58, float %59, float %57)
%61 = load float, float* %5
%62 = fsub float %60, %61
store float %62, float* %7
%63 = load i32, i32* %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %63)
%65 = load float, float* %7
%66 = fcmp olt float %65, 0.000000e+00
br i1 %66, label %67, label %69
67: ; preds = %52
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %73
69: ; preds = %52
%70 = load float, float* %7
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %71)
br label %73
73: ; preds = %69, %67
%74 = load float, float* %7
%75 = fcmp ole float %74, 0.000000e+00
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load float, float* %9
%78 = fpext float %77 to double
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), double %78)
br label %80
80: ; preds = %76, %73
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %43
83: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Please enter the loan value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [41 x i8] c"Please enter the yearly interest value: \00"
@.str.3 = [41 x i8] c"Please enter the monthly payment value: \00"
@.str.4 = [59 x i8] c"Please enter the value of the number of monthly payments: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [35 x i8] c"The balance after %d payment(s): \0A\00"
@.str.8 = [7 x i8] c"%.2f \0A\00"
@.str.9 = [42 x i8] c"The amount of the last payment is: %.2f \0A\00"
@str = [6 x i8] c"0.00 \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = bitcast float* %1 to i8*
store float -1.000000e+00, float* %1
%6 = bitcast float* %2 to i8*
store float -1.000000e+00, float* %2
%7 = bitcast float* %3 to i8*
store float -1.000000e+00, float* %3
%8 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
br label %9
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%12 = load float, float* %1
%13 = fcmp olt float %12, 0.000000e+00
br i1 %13, label %9, label %14
14: ; preds = %9, %14
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%17 = load float, float* %2
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %14, label %19
19: ; preds = %14, %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%22 = load float, float* %3
%23 = fcmp olt float %22, 0.000000e+00
br i1 %23, label %19, label %24
24: ; preds = %19, %24
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 0
br i1 %28, label %24, label %29
29: ; preds = %24
%30 = icmp ne i32 %27, 0
%31 = load float, float* %2
%32 = fdiv float %31, 1.000000e+02
store float %32, float* %2
%33 = fdiv float %32, 1.200000e+01
%34 = load float, float* %1
%35 = fcmp oge float %34, 0.000000e+00
%36 = select i1 %30, i1 %35, i1 false
br i1 %36, label %37, label %61
37: ; preds = %29, %55
%38 = phi i32 [ %56, %55 ], [ 1, %29 ]
%39 = phi float [ %42, %55 ], [ %34, %29 ]
%40 = call float @llvm.fmuladd.f32(float %39, float %33, float %39)
%41 = load float, float* %3
%42 = fsub float %40, %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%44 = fcmp olt float %42, 0.000000e+00
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %50
47: ; preds = %37
%48 = fpext float %42 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %48)
br label %50
50: ; preds = %47, %45
%51 = fcmp ugt float %42, 0.000000e+00
br i1 %51, label %55, label %52
52: ; preds = %50
%53 = fpext float %40 to double
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), double %53)
br label %55
55: ; preds = %52, %50
%56 = add nuw nsw i32 %38, 1
%57 = load i32, i32* %4
%58 = icmp slt i32 %38, %57
%59 = fcmp oge float %42, 0.000000e+00
%60 = select i1 %58, i1 %59, i1 false
br i1 %60, label %37, label %61
61: ; preds = %55, %29
ret i32 0
}