#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, double);
int /*<<< orphan*/ printf(char *, int);
int main() {
  double LENGTH = 1000;
  double BASE = 10;
  double maxval = pow(BASE, LENGTH - 1);
  printf("%f\n", maxval);
  int a = 0;
  int b = 1;
  int h;
  int x = 1;
  while (b < maxval) {
    h = b;
    b = a + b;
    a = h;
    x++;
  }
  printf("%d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xea5(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c6 <main+0xa6>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    118f <main+0x6f>
mov    -0x30(%rbp),%esi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xed7(%rip),%xmm0
movsd  0xed7(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
cvttsd2si %xmm0,%esi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
movsd  (%rsp),%xmm1
mov    $0x1,%esi
ucomisd 0xeb3(%rip),%xmm1
jbe    1188 <main+0x68>
xor    %ecx,%ecx
mov    $0x1,%esi
mov    $0x1,%eax
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
add    %eax,%edx
add    $0x1,%esi
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
ucomisd %xmm0,%xmm1
mov    %eax,%ecx
mov    %edx,%eax
ja     1170 <main+0x50>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store double 1.000000e+03, double* %2
store double 1.000000e+01, double* %3
%9 = load double, double* %3
%10 = load double, double* %2
%11 = fsub double %10, 1.000000e+00
%12 = call double @pow(double %9, double %11)
store double %12, double* %4
%13 = load double, double* %4
%14 = fptosi double %13 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 0, i32* %5
store i32 1, i32* %6
store i32 1, i32* %8
br label %16
16: ; preds = %21, %0
%17 = load i32, i32* %6
%18 = sitofp i32 %17 to double
%19 = load double, double* %4
%20 = fcmp olt double %18, %19
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i32, i32* %6
store i32 %22, i32* %7
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
store i32 %25, i32* %6
%26 = load i32, i32* %7
store i32 %26, i32* %5
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %16
29: ; preds = %16
%30 = load i32, i32* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call double @pow(double 1.000000e+01, double 9.990000e+02)
%2 = fptosi double %1 to i32
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = fcmp ogt double %1, 1.000000e+00
br i1 %4, label %5, label %13
5: ; preds = %0, %5
%6 = phi i32 [ %10, %5 ], [ 1, %0 ]
%7 = phi i32 [ %8, %5 ], [ 0, %0 ]
%8 = phi i32 [ %9, %5 ], [ 1, %0 ]
%9 = add nsw i32 %7, %8
%10 = add nuw nsw i32 %6, 1
%11 = sitofp i32 %9 to double
%12 = fcmp ogt double %1, %11
br i1 %12, label %5, label %13
13: ; preds = %5, %0
%14 = phi i32 [ 1, %0 ], [ %10, %5 ]
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}