#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);
int main() {
  double a = 1.0;
  double b = 1.0;
  double c = a + b;
  double limit = 10.0;
  int digits = 1;
  int index = 3;
  while (digits < 1000) {
    a = b;
    b = c;
    c = a + b;
    if (c >= limit) {
      a /= limit;
      b /= limit;
      c /= limit;
      digits++;
    }
    index++;
  }
  printf("If you can trust me, the number you are looking for is %d\n", index);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x3,-0x30(%rbp)
cmpl   $0x3e8,-0x2c(%rbp)
jge    11f3 <main+0xe3>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11e5 <main+0xd5>
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1163 <main+0x53>
mov    -0x30(%rbp),%esi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm0
movsd  0xee7(%rip),%xmm3
mov    $0x1,%eax
mov    $0x3,%esi
movsd  0xedd(%rip),%xmm1
movapd 0xee5(%rip),%xmm2
jmp    1152 <main+0x42>
nopl   (%rax)
add    $0x1,%esi
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
cmp    $0x3e8,%eax
jge    1169 <main+0x59>
addsd  %xmm3,%xmm0
ucomisd %xmm1,%xmm0
unpcklpd %xmm3,%xmm0
jb     1140 <main+0x30>
divpd  %xmm2,%xmm0
add    $0x1,%eax
jmp    1140 <main+0x30>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [59 x i8] c"If you can trust me, the number you are looking for is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 1.000000e+00, double* %3
%8 = load double, double* %2
%9 = load double, double* %3
%10 = fadd double %8, %9
store double %10, double* %4
store double 1.000000e+01, double* %5
store i32 1, i32* %6
store i32 3, i32* %7
br label %11
11: ; preds = %35, %0
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load double, double* %3
store double %15, double* %2
%16 = load double, double* %4
store double %16, double* %3
%17 = load double, double* %2
%18 = load double, double* %3
%19 = fadd double %17, %18
store double %19, double* %4
%20 = load double, double* %4
%21 = load double, double* %5
%22 = fcmp oge double %20, %21
br i1 %22, label %23, label %35
23: ; preds = %14
%24 = load double, double* %5
%25 = load double, double* %2
%26 = fdiv double %25, %24
store double %26, double* %2
%27 = load double, double* %5
%28 = load double, double* %3
%29 = fdiv double %28, %27
store double %29, double* %3
%30 = load double, double* %5
%31 = load double, double* %4
%32 = fdiv double %31, %30
store double %32, double* %4
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %35
35: ; preds = %23, %14
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %11
38: ; preds = %11
%39 = load i32, i32* %7
%40 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"If you can trust me, the number you are looking for is %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ 3, %0 ], [ %16, %13 ]
%3 = phi i32 [ 1, %0 ], [ %14, %13 ]
%4 = phi double [ 2.000000e+00, %0 ], [ %18, %13 ]
%5 = phi double [ 1.000000e+00, %0 ], [ %19, %13 ]
%6 = fadd double %5, %4
%7 = fcmp ult double %6, 1.000000e+01
%8 = insertelement <2 x double> poison, double %6, i64 0
%9 = insertelement <2 x double> %8, double %4, i64 1
br i1 %7, label %13, label %10
10: ; preds = %1
%11 = fdiv <2 x double> %9, <double 1.000000e+01, double 1.000000e+01>
%12 = add nsw i32 %3, 1
br label %13
13: ; preds = %10, %1
%14 = phi i32 [ %12, %10 ], [ %3, %1 ]
%15 = phi <2 x double> [ %11, %10 ], [ %9, %1 ]
%16 = add nuw nsw i32 %2, 1
%17 = icmp slt i32 %14, 1000
%18 = extractelement <2 x double> %15, i64 0
%19 = extractelement <2 x double> %15, i64 1
br i1 %17, label %1, label %20
20: ; preds = %13
%21 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}