#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 main(int argc, char const *argv[]) {
  double current, total;
  int count = 1;
  printf("square grains total  ");
  printf("fraction of \n");
  printf("    added      grain        ");
  printf("US total\n");
  total = current = 1.0;
  printf("%4d %13.2e %12.2e %12.2e \n", count, current, total, total / 1E15);
  while (count < 64) {
    count = count + 1;
    current = 2.0 * current;
    total = total + current;
    printf("%4d %13.2e %12.2e %12.2e\n", count, current, total, total / 1E15);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xe67(%rip),%xmm3
divsd  %xmm3,%xmm2
lea    0xebf(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
cmpl   $0x40,-0x24(%rbp)
jge    1210 <main+0x100>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  0xe4a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xe07(%rip),%xmm3
divsd  %xmm3,%xmm2
lea    0xe7a(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    11ab <main+0x9b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeea(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
movsd  0xe96(%rip),%xmm0
movsd  0xe96(%rip),%xmm2
mov    $0x1,%esi
movapd %xmm0,%xmm1
mov    $0x3,%al
call   1040 <printf@plt>
mov    $0x2,%ebx
lea    0xed8(%rip),%r14
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe5c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
divsd  0xe40(%rip),%xmm2
mov    %r14,%rdi
mov    %ebx,%esi
movsd  0x10(%rsp),%xmm0
movsd  %xmm1,0x8(%rsp)
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x41,%ebx
jne    11b0 <main+0x90>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"square grains total \00"
@.str.1 = [14 x i8] c"fraction of \0A\00"
@.str.2 = [29 x i8] c" added grain \00"
@.str.3 = [10 x i8] c"US total\0A\00"
@.str.4 = [27 x i8] c"%4d %13.2e %12.2e %12.2e \0A\00"
@.str.5 = [26 x i8] c"%4d %13.2e %12.2e %12.2e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store double 1.000000e+00, double* %6
store double 1.000000e+00, double* %7
%13 = load i32, i32* %8
%14 = load double, double* %6
%15 = load double, double* %7
%16 = load double, double* %7
%17 = fdiv double %16, 1.000000e+15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %13, double %14, double %15, double %17)
br label %19
19: ; preds = %22, %2
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 64
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
%25 = load double, double* %6
%26 = fmul double 2.000000e+00, %25
store double %26, double* %6
%27 = load double, double* %7
%28 = load double, double* %6
%29 = fadd double %27, %28
store double %29, double* %7
%30 = load i32, i32* %8
%31 = load double, double* %6
%32 = load double, double* %7
%33 = load double, double* %7
%34 = fdiv double %33, 1.000000e+15
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %30, double %31, double %32, double %34)
br label %19
36: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"square grains total \00"
@.str.2 = [29 x i8] c" added grain \00"
@.str.4 = [27 x i8] c"%4d %13.2e %12.2e %12.2e \0A\00"
@.str.5 = [26 x i8] c"%4d %13.2e %12.2e %12.2e\0A\00"
@str = [13 x i8] c"fraction of \00"
@str.6 = [9 x i8] c"US total\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 1, double 1.000000e+00, double 1.000000e+00, double 1.000000e-15)
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 1, %2 ], [ %12, %8 ]
%10 = phi double [ 1.000000e+00, %2 ], [ %14, %8 ]
%11 = phi double [ 1.000000e+00, %2 ], [ %13, %8 ]
%12 = add nuw nsw i32 %9, 1
%13 = fmul double %11, 2.000000e+00
%14 = fadd double %10, %13
%15 = fdiv double %14, 1.000000e+15
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %12, double %13, double %14, double %15)
%17 = icmp eq i32 %12, 64
br i1 %17, label %18, label %8
18: ; preds = %8
ret i32 0
}