#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double, int, int);
main() {
  static double a[1000], b[1000];
  int i, j;
  clock_t t1, t2;
  a[0] = 0.9;
  b[0] = 0.9;
  t1 = clock();
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 999; j++) {
      b[j + 1] = b[j] + a[j];
      b[j + 1] = b[j + 1] - a[j];
      a[j + 1] = b[j] / a[j];
      a[j + 1] = b[j + 1] * a[j + 1];
    }
  }
  t2 = clock();
  printf("Answer is %f, %d loops in %d secs\n", a[999], 10,
         (int)(t2 - t1) / 100);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,0x2f01(%rip)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,0x4e31(%rip)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1283 <main+0x163>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e7,-0xc(%rbp)
jge    1270 <main+0x150>
movslq -0xc(%rbp),%rcx
lea    0x4df6(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movslq -0xc(%rbp),%rcx
lea    0x2ea6(%rip),%rax
addsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x4dd1(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x4dbc(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movslq -0xc(%rbp),%rcx
lea    0x2e6c(%rip),%rax
subsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x4d97(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
movslq -0xc(%rbp),%rcx
lea    0x4d87(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movslq -0xc(%rbp),%rcx
lea    0x2e37(%rip),%rax
divsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e22(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x4d4d(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2df8(%rip),%rax
mulsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2de3(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x52>
jmp    1275 <main+0x155>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1161 <main+0x41>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movsd  0x4ce2(%rip),%xmm0
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xd59(%rip),%rdi
mov    $0xa,%esi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movabs $0x3feccccccccccccd,%rax
cc ec 3f
mov    %rax,0x2f0c(%rip)
mov    %rax,0x4e45(%rip)
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
lea    0x4e32(%rip),%rax
lea    0x2eeb(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x4e18(%rip),%xmm0
mov    $0x1,%edx
movsd  0x2ecb(%rip),%xmm2
movapd %xmm0,%xmm1
nopl   0x0(%rax)
addsd  %xmm2,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,(%rax,%rdx,8)
divsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx,%rdx,8)
add    $0x1,%rdx
movapd %xmm0,%xmm2
movapd %xmm1,%xmm0
cmp    $0x3e8,%rdx
jne    1180 <main+0x60>
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1160 <main+0x40>
xor    %eax,%eax
call   1030 <clock@plt>
movsd  0x4db2(%rip),%xmm0
sub    %ebx,%eax
cltq
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x25,%rdx
add    %eax,%edx
lea    0xe1b(%rip),%rdi
mov    $0xa,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@main.a = internal global [1000 x double] zeroinitializer
@main.b = internal global [1000 x double] zeroinitializer
@.str = [35 x i8] c"Answer is %f, %d loops in %d secs\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store double 9.000000e-01, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.a, i64 0, i64 0)
store double 9.000000e-01, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.b, i64 0, i64 0)
%6 = call i64 (...) @clock()
store i64 %6, i64* %4
store i32 0, i32* %2
br label %7
7: ; preds = %74, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %77
10: ; preds = %7
store i32 0, i32* %3
br label %11
11: ; preds = %70, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 999
br i1 %13, label %14, label %73
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %16
%18 = load double, double* %17
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %20
%22 = load double, double* %21
%23 = fadd double %18, %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %26
store double %23, double* %27
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %30
%32 = load double, double* %31
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %34
%36 = load double, double* %35
%37 = fsub double %32, %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %40
store double %37, double* %41
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %47
%49 = load double, double* %48
%50 = fdiv double %45, %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %53
store double %50, double* %54
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %57
%59 = load double, double* %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %62
%64 = load double, double* %63
%65 = fmul double %59, %64
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %68
store double %65, double* %69
br label %70
70: ; preds = %14
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %11
73: ; preds = %11
br label %74
74: ; preds = %73
%75 = load i32, i32* %2
%76 = add nsw i32 %75, 1
store i32 %76, i32* %2
br label %7
77: ; preds = %7
%78 = call i64 (...) @clock()
store i64 %78, i64* %5
%79 = load double, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.a, i64 0, i64 999)
%80 = load i64, i64* %5
%81 = load i64, i64* %4
%82 = sub nsw i64 %80, %81
%83 = trunc i64 %82 to i32
%84 = sdiv i32 %83, 100
%85 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %79, i32 10, i32 %84)
%86 = load i32, i32* %1
ret i32 %86
}

LLVM IR (-O2):
@main.a = internal unnamed_addr global [1000 x double] zeroinitializer
@main.b = internal unnamed_addr global [1000 x double] zeroinitializer
@.str = [35 x i8] c"Answer is %f, %d loops in %d secs\0A\00"
define i32 @main() {
store double 9.000000e-01, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.a, i64 0, i64 0)
store double 9.000000e-01, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.b, i64 0, i64 0)
%1 = tail call i64 (...) @clock()
br label %2
2: ; preds = %0, %18
%3 = phi i32 [ 0, %0 ], [ %19, %18 ]
%4 = load double, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.b, i64 0, i64 0)
%5 = load double, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.a, i64 0, i64 0)
br label %6
6: ; preds = %2, %6
%7 = phi double [ %5, %2 ], [ %16, %6 ]
%8 = phi double [ %4, %2 ], [ %13, %6 ]
%9 = phi i64 [ 0, %2 ], [ %11, %6 ]
%10 = fadd double %8, %7
%11 = add nuw nsw i64 %9, 1
%12 = getelementptr inbounds [1000 x double], [1000 x double]* @main.b, i64 0, i64 %11
%13 = fsub double %10, %7
store double %13, double* %12
%14 = fdiv double %8, %7
%15 = getelementptr inbounds [1000 x double], [1000 x double]* @main.a, i64 0, i64 %11
%16 = fmul double %14, %13
store double %16, double* %15
%17 = icmp eq i64 %11, 999
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = add nuw nsw i32 %3, 1
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %2
21: ; preds = %18
%22 = tail call i64 (...) @clock()
%23 = load double, double* getelementptr inbounds ([1000 x double], [1000 x double]* @main.a, i64 0, i64 999)
%24 = sub nsw i64 %22, %1
%25 = trunc i64 %24 to i32
%26 = sdiv i32 %25, 100
%27 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %23, i32 10, i32 %26)
ret i32 0
}