#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, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, double *);
void CompoundInterest() {
  double amount;
  double principal;
  puts("Give initial deposit: ");
  scanf("%lf", &principal);
  double rate = .05;
  unsigned int year;
  printf("%4s%21s\n", "Year", "Acount on deposit");
  for (year = 1; year <= 10; year++) {
    amount = principal * pow(1.0 + rate, year);
    printf("%4u%21.02f\n", year, amount);
  }
}


x86 assembly (clang, -O0):
<CompoundInterest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
lea    0xeb5(%rip),%rsi
lea    0xeb3(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
ja     11f2 <CompoundInterest+0xb2>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe58(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <CompoundInterest+0x54>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CompoundInterest>:
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
lea    0xeba(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe6f(%rip),%xmm0
mov    $0x1,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
lea    0xe9c(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe37(%rip),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe06(%rip),%xmm0
mov    $0x3,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdd5(%rip),%xmm0
mov    $0x4,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xda4(%rip),%xmm0
mov    $0x5,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd73(%rip),%xmm0
mov    $0x6,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd42(%rip),%xmm0
mov    $0x7,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd11(%rip),%xmm0
mov    $0x8,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xce0(%rip),%xmm0
mov    $0x9,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xcaf(%rip),%xmm0
mov    $0xa,%edi
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Give initial deposit: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [9 x i8] c"%4s%21s\0A\00"
@.str.3 = [5 x i8] c"Year\00"
@.str.4 = [18 x i8] c"Acount on deposit\00"
@.str.5 = [12 x i8] c"%4u%21.02f\0A\00"
define void @CompoundInterest() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
store double 5.000000e-02, double* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %4
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %4
%10 = icmp ule i32 %9, 10
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load double, double* %2
%13 = load double, double* %3
%14 = fadd double 1.000000e+00, %13
%15 = load i32, i32* %4
%16 = call double @pow(double %14, i32 %15)
%17 = fmul double %12, %16
store double %17, double* %1
%18 = load i32, i32* %4
%19 = load double, double* %1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %18, double %19)
br label %21
21: ; preds = %11
%22 = load i32, i32* %4
%23 = add i32 %22, 1
store i32 %23, i32* %4
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Give initial deposit: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [9 x i8] c"%4s%21s\0A\00"
@.str.3 = [5 x i8] c"Year\00"
@.str.4 = [18 x i8] c"Acount on deposit\00"
@.str.5 = [12 x i8] c"%4u%21.02f\0A\00"
define void @CompoundInterest() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%6 = load double, double* %1
%7 = call double @pow(double 1.050000e+00, i32 1)
%8 = fmul double %6, %7
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 1, double %8)
%10 = load double, double* %1
%11 = call double @pow(double 1.050000e+00, i32 2)
%12 = fmul double %10, %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 2, double %12)
%14 = load double, double* %1
%15 = call double @pow(double 1.050000e+00, i32 3)
%16 = fmul double %14, %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 3, double %16)
%18 = load double, double* %1
%19 = call double @pow(double 1.050000e+00, i32 4)
%20 = fmul double %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 4, double %20)
%22 = load double, double* %1
%23 = call double @pow(double 1.050000e+00, i32 5)
%24 = fmul double %22, %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 5, double %24)
%26 = load double, double* %1
%27 = call double @pow(double 1.050000e+00, i32 6)
%28 = fmul double %26, %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 6, double %28)
%30 = load double, double* %1
%31 = call double @pow(double 1.050000e+00, i32 7)
%32 = fmul double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 7, double %32)
%34 = load double, double* %1
%35 = call double @pow(double 1.050000e+00, i32 8)
%36 = fmul double %34, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 8, double %36)
%38 = load double, double* %1
%39 = call double @pow(double 1.050000e+00, i32 9)
%40 = fmul double %38, %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 9, double %40)
%42 = load double, double* %1
%43 = call double @pow(double 1.050000e+00, i32 10)
%44 = fmul double %42, %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 10, double %44)
ret void
}