#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 int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_fib2_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                               unsigned long const);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, unsigned long const);
int mpz_sizeinbase(int /*<<< orphan*/, int);
int Problem025(void) {
  const unsigned long int start = 0;
  mpz_t n, F, Fsub1, temp;
  mpz_init(n);
  mpz_init(F);
  mpz_init(Fsub1);
  mpz_init(temp);
  mpz_set_ui(n, start);
  mpz_fib2_ui(F, Fsub1, start);
  do {
    mpz_set(temp, F);
    mpz_add_ui(n, n, 1);
    mpz_add(F, F, Fsub1);
    mpz_set(Fsub1, temp);
  } while (mpz_sizeinbase(F, 10) < 1000);
  mpz_set(temp, F);
  mpz_add_ui(n, n, 1);
  mpz_add(F, F, Fsub1);
  mpz_set(Fsub1, temp);
  gmp_printf("%30Zd", n);
  mpz_clear(n);
  mpz_clear(F);
  mpz_clear(Fsub1);
  mpz_clear(temp);
  return 0;
}


x86 assembly (clang, -O0):
<Problem025>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x10(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x14(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <mpz_set_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <mpz_fib2_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <mpz_add@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x10(%rbp),%edi
mov    $0xa,%esi
call   1080 <mpz_sizeinbase@plt>
cmp    $0x3e8,%eax
jl     11db <Problem025+0x4b>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <mpz_add@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0xc(%rbp),%esi
lea    0xd9b(%rip),%rdi
call   10b0 <gmp_printf@plt>
mov    -0xc(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x10(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   10a0 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   10a0 <mpz_clear@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Problem025>:
push   %rax
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
xor    %esi,%esi
call   1090 <mpz_set_ui@plt>
xor    %edx,%edx
call   1030 <mpz_fib2_ui@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <mpz_set@plt>
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
call   1070 <mpz_add@plt>
call   1040 <mpz_set@plt>
mov    $0xa,%esi
call   1080 <mpz_sizeinbase@plt>
cmp    $0x3e8,%eax
jl     11c0 <Problem025+0x30>
call   1040 <mpz_set@plt>
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
call   1070 <mpz_add@plt>
call   1040 <mpz_set@plt>
lea    0xdf6(%rip),%rdi
call   10b0 <gmp_printf@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
call   10a0 <mpz_clear@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%30Zd\00"
define i32 @Problem025() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i64 0, i64* %1
%6 = load i32, i32* %2
%7 = call i32 @mpz_init(i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @mpz_init(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %5
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @mpz_set_ui(i32 %14, i64 0)
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 @mpz_fib2_ui(i32 %16, i32 %17, i64 0)
br label %19
19: ; preds = %33, %0
%20 = load i32, i32* %5
%21 = load i32, i32* %3
%22 = call i32 @mpz_set(i32 %20, i32 %21)
%23 = load i32, i32* %2
%24 = load i32, i32* %2
%25 = call i32 @mpz_add_ui(i32 %23, i32 %24, i32 1)
%26 = load i32, i32* %3
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 @mpz_add(i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = call i32 @mpz_set(i32 %30, i32 %31)
br label %33
33: ; preds = %19
%34 = load i32, i32* %3
%35 = call i32 @mpz_sizeinbase(i32 %34, i32 10)
%36 = icmp slt i32 %35, 1000
br i1 %36, label %19, label %37
37: ; preds = %33
%38 = load i32, i32* %5
%39 = load i32, i32* %3
%40 = call i32 @mpz_set(i32 %38, i32 %39)
%41 = load i32, i32* %2
%42 = load i32, i32* %2
%43 = call i32 @mpz_add_ui(i32 %41, i32 %42, i32 1)
%44 = load i32, i32* %3
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = call i32 @mpz_add(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = call i32 @mpz_set(i32 %48, i32 %49)
%51 = load i32, i32* %2
%52 = call i32 @gmp_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %2
%54 = call i32 @mpz_clear(i32 %53)
%55 = load i32, i32* %3
%56 = call i32 @mpz_clear(i32 %55)
%57 = load i32, i32* %4
%58 = call i32 @mpz_clear(i32 %57)
%59 = load i32, i32* %5
%60 = call i32 @mpz_clear(i32 %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%30Zd\00"
define i32 @Problem025() {
%1 = tail call i32 @mpz_init(i32 undef)
%2 = tail call i32 @mpz_init(i32 undef)
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_set_ui(i32 undef, i64 0)
%6 = tail call i32 @mpz_fib2_ui(i32 undef, i32 undef, i64 0)
br label %7
7: ; preds = %7, %0
%8 = tail call i32 @mpz_set(i32 undef, i32 undef)
%9 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
%10 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%11 = tail call i32 @mpz_set(i32 undef, i32 undef)
%12 = tail call i32 @mpz_sizeinbase(i32 undef, i32 10)
%13 = icmp slt i32 %12, 1000
br i1 %13, label %7, label %14
14: ; preds = %7
%15 = tail call i32 @mpz_set(i32 undef, i32 undef)
%16 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
%17 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%18 = tail call i32 @mpz_set(i32 undef, i32 undef)
%19 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 undef)
%20 = tail call i32 @mpz_clear(i32 undef)
%21 = tail call i32 @mpz_clear(i32 undef)
%22 = tail call i32 @mpz_clear(i32 undef)
%23 = tail call i32 @mpz_clear(i32 undef)
ret i32 0
}