#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 balanceCalculator(int, double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, const char *argv[]) {
  int N, toNYearLater;
  double start, rate, yearRate;
  printf("Interest calculation program.\n");
  printf("Starting balance? ");
  scanf("%lf", &start);
  printf("Annual interest rate percentage? ");
  scanf("%lf", &rate);
  yearRate = (1 + 0.01 * rate);
  printf("Calculate for ? years: ");
  scanf("%d", &toNYearLater);
  printf("print every ? years balance: ");
  scanf("%d", &N);
  printf("Year %-3d  |  balance %10g\n", 1, balanceCalculator(1, start, rate));
  for (int i = 1; i <= toNYearLater / N; i++) {
    if ((i * N) == 1)
      continue;
    printf("Year %-3d  |  balance %10g\n", i * N,
           balanceCalculator(i * N, start, rate));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    $0x1,%edi
call   1040 <balanceCalculator@plt>
lea    0xe90(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jg     1292 <main+0x162>
mov    -0x34(%rbp),%eax
imul   -0x14(%rbp),%eax
cmp    $0x1,%eax
jne    1253 <main+0x123>
jmp    1284 <main+0x154>
mov    -0x34(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
imul   -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <balanceCalculator@plt>
mov    -0x3c(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1224 <main+0xf4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rbp
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea5(%rip),%rbp
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x1,%edi
call   1050 <balanceCalculator@plt>
lea    0xe7d(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%esi
mov    %ecx,%eax
cltd
idiv   %esi
test   %eax,%eax
jle    125f <main+0x11f>
lea    0xe59(%rip),%r14
jmp    1229 <main+0xe9>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
cmp    %eax,%ebx
jge    125f <main+0x11f>
add    $0x1,%ebx
mov    %esi,%ebp
imul   %ebx,%ebp
cmp    $0x1,%ebp
je     1220 <main+0xe0>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %ebp,%edi
call   1050 <balanceCalculator@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%esi
jmp    1220 <main+0xe0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Interest calculation program.\0A\00"
@.str.1 = [19 x i8] c"Starting balance? \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [34 x i8] c"Annual interest rate percentage? \00"
@.str.4 = [24 x i8] c"Calculate for ? years: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [30 x i8] c"print every ? years balance: \00"
@.str.7 = [28 x i8] c"Year %-3d | balance %10g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %8)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %9)
%17 = load double, double* %9
%18 = call double @llvm.fmuladd.f64(double 1.000000e-02, double %17, double 1.000000e+00)
store double %18, double* %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%23 = load double, double* %8
%24 = load double, double* %9
%25 = call double @balanceCalculator(i32 1, double %23, double %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 1, double %25)
store i32 1, i32* %11
br label %27
27: ; preds = %50, %2
%28 = load i32, i32* %11
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = sdiv i32 %29, %30
%32 = icmp sle i32 %28, %31
br i1 %32, label %33, label %53
33: ; preds = %27
%34 = load i32, i32* %11
%35 = load i32, i32* %6
%36 = mul nsw i32 %34, %35
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %39
38: ; preds = %33
br label %50
39: ; preds = %33
%40 = load i32, i32* %11
%41 = load i32, i32* %6
%42 = mul nsw i32 %40, %41
%43 = load i32, i32* %11
%44 = load i32, i32* %6
%45 = mul nsw i32 %43, %44
%46 = load double, double* %8
%47 = load double, double* %9
%48 = call double @balanceCalculator(i32 %45, double %46, double %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %42, double %48)
br label %50
50: ; preds = %39, %38
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
br label %27
53: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Starting balance? \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [34 x i8] c"Annual interest rate percentage? \00"
@.str.4 = [24 x i8] c"Calculate for ? years: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [30 x i8] c"print every ? years balance: \00"
@.str.7 = [28 x i8] c"Year %-3d | balance %10g\0A\00"
@str = [30 x i8] c"Interest calculation program.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%20 = load double, double* %5
%21 = load double, double* %6
%22 = call double @balanceCalculator(i32 1, double %20, double %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 1, double %22)
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = sdiv i32 %24, %25
%27 = icmp slt i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %42, %2
ret i32 0
29: ; preds = %2, %42
%30 = phi i32 [ %43, %42 ], [ %25, %2 ]
%31 = phi i32 [ %44, %42 ], [ %24, %2 ]
%32 = phi i32 [ %45, %42 ], [ 1, %2 ]
%33 = mul nsw i32 %30, %32
%34 = icmp eq i32 %33, 1
br i1 %34, label %42, label %35
35: ; preds = %29
%36 = load double, double* %5
%37 = load double, double* %6
%38 = call double @balanceCalculator(i32 %33, double %36, double %37)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %33, double %38)
%40 = load i32, i32* %4
%41 = load i32, i32* %3
br label %42
42: ; preds = %29, %35
%43 = phi i32 [ %30, %29 ], [ %41, %35 ]
%44 = phi i32 [ %31, %29 ], [ %40, %35 ]
%45 = add nuw nsw i32 %32, 1
%46 = sdiv i32 %44, %43
%47 = icmp slt i32 %32, %46
br i1 %47, label %29, label %28
}