#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 *, ...);
void fig04_06() {
  double amount;
  double principal = 1000;
  double rate = .05;
  unsigned int year;
  printf("%4s%21s\n", "Year", "Amount on deposit");
  for (year = 1; year <= 10; ++year) {
    amount = principal * pow(1.0 + rate, year);
    printf("%4u%21.2f\n", year, amount);
  }
}


x86 assembly (clang, -O0):
<fig04_06>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xecf(%rip),%rdi
lea    0xed1(%rip),%rsi
lea    0xecf(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
ja     11c3 <fig04_06+0xa3>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8f(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1040 <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    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <fig04_06+0x45>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig04_06>:
push   %rbx
lea    0xee8(%rip),%rdi
lea    0xeea(%rip),%rsi
lea    0xee8(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xebb(%rip),%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
mulsd  0xeb1(%rip),%xmm0
lea    0xed2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe8b(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mulsd  0xe81(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe62(%rip),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
mulsd  0xe58(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe39(%rip),%xmm0
mov    $0x4,%edi
call   1040 <pow@plt>
mulsd  0xe2f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe10(%rip),%xmm0
mov    $0x5,%edi
call   1040 <pow@plt>
mulsd  0xe06(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xde7(%rip),%xmm0
mov    $0x6,%edi
call   1040 <pow@plt>
mulsd  0xddd(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xdbe(%rip),%xmm0
mov    $0x7,%edi
call   1040 <pow@plt>
mulsd  0xdb4(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xd95(%rip),%xmm0
mov    $0x8,%edi
call   1040 <pow@plt>
mulsd  0xd8b(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xd6c(%rip),%xmm0
mov    $0x9,%edi
call   1040 <pow@plt>
mulsd  0xd62(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xd43(%rip),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
mulsd  0xd39(%rip),%xmm0
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%al
pop    %rbx
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [9 x i8] c"%4s%21s\0A\00"
@.str.1 = [5 x i8] c"Year\00"
@.str.2 = [18 x i8] c"Amount on deposit\00"
@.str.3 = [11 x i8] c"%4u%21.2f\0A\00"
define void @fig04_06() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call double @pow(double 1.050000e+00, i32 1)
%3 = fmul double %2, 1.000000e+03
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 1, double %3)
%5 = tail call double @pow(double 1.050000e+00, i32 2)
%6 = fmul double %5, 1.000000e+03
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 2, double %6)
%8 = tail call double @pow(double 1.050000e+00, i32 3)
%9 = fmul double %8, 1.000000e+03
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 3, double %9)
%11 = tail call double @pow(double 1.050000e+00, i32 4)
%12 = fmul double %11, 1.000000e+03
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 4, double %12)
%14 = tail call double @pow(double 1.050000e+00, i32 5)
%15 = fmul double %14, 1.000000e+03
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 5, double %15)
%17 = tail call double @pow(double 1.050000e+00, i32 6)
%18 = fmul double %17, 1.000000e+03
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 6, double %18)
%20 = tail call double @pow(double 1.050000e+00, i32 7)
%21 = fmul double %20, 1.000000e+03
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 7, double %21)
%23 = tail call double @pow(double 1.050000e+00, i32 8)
%24 = fmul double %23, 1.000000e+03
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 8, double %24)
%26 = tail call double @pow(double 1.050000e+00, i32 9)
%27 = fmul double %26, 1.000000e+03
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 9, double %27)
%29 = tail call double @pow(double 1.050000e+00, i32 10)
%30 = fmul double %29, 1.000000e+03
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10, double %30)
ret void
}