#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*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char *argv[]) {
  char str[1024] = {0};
  unsigned counter = 2;
  mpz_t t1;
  mpz_t t2;
  mpz_t tn;
  mpz_init(t1);
  mpz_init(t2);
  mpz_init(tn);
  mpz_set_ui(t1, 1);
  mpz_set_ui(t2, 1);
  while (1) {
    ++counter;
    mpz_add(tn, t1, t2);
    mpz_get_str(str, 10, tn);
    if (strlen(str) >= 1000) {
      printf("Number: %s\n", str);
      break;
    }
    mpz_set(t1, t2);
    mpz_set(t2, tn);
  }
  mpz_clear(t1);
  mpz_clear(t2);
  mpz_clear(tn);
  printf("\n\nIndex: %d\n", counter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movl   $0x2,-0x414(%rbp)
mov    -0x418(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x41c(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x420(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x418(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpz_set_ui@plt>
mov    -0x41c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpz_set_ui@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
mov    -0x420(%rbp),%edi
mov    -0x418(%rbp),%esi
mov    -0x41c(%rbp),%edx
call   1090 <mpz_add@plt>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%edx
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3e8,%eax
jl     1275 <main+0xe5>
lea    -0x410(%rbp),%rsi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129c <main+0x10c>
mov    -0x418(%rbp),%edi
mov    -0x41c(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x41c(%rbp),%edi
mov    -0x420(%rbp),%esi
call   1030 <mpz_set@plt>
jmp    1207 <main+0x77>
mov    -0x418(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x41c(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x420(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x414(%rbp),%esi
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
mov    $0x1,%esi
call   10a0 <mpz_set_ui@plt>
mov    $0x1,%esi
call   10a0 <mpz_set_ui@plt>
call   1090 <mpz_add@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x3,%ebx
cmp    $0x3e7,%eax
jg     122e <main+0x9e>
mov    $0x3,%ebx
mov    %rsp,%r14
nopl   (%rax)
call   1030 <mpz_set@plt>
call   1030 <mpz_set@plt>
add    $0x1,%ebx
call   1090 <mpz_add@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x3e7,%eax
jle    1200 <main+0x70>
lea    0xdcb(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
lea    0xdb7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Number: %s\0A\00"
@.str.1 = [13 x i8] c"\0A\0AIndex: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [1024 x i8]* %6 to i8*
store i32 2, i32* %7
%12 = load i32, i32* %8
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %9
%15 = call i32 @mpz_init(i32 %14)
%16 = load i32, i32* %10
%17 = call i32 @mpz_init(i32 %16)
%18 = load i32, i32* %8
%19 = call i32 @mpz_set_ui(i32 %18, i32 1)
%20 = load i32, i32* %9
%21 = call i32 @mpz_set_ui(i32 %20, i32 1)
br label %22
22: ; preds = %2, %38
%23 = load i32, i32* %7
%24 = add i32 %23, 1
store i32 %24, i32* %7
%25 = load i32, i32* %10
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = call i32 @mpz_add(i32 %25, i32 %26, i32 %27)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%30 = load i32, i32* %10
%31 = call i32 @mpz_get_str(i8* %29, i32 10, i32 %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = icmp sge i32 %33, 1000
br i1 %34, label %35, label %38
35: ; preds = %22
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %36)
br label %45
38: ; preds = %22
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 @mpz_set(i32 %39, i32 %40)
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = call i32 @mpz_set(i32 %42, i32 %43)
br label %22
45: ; preds = %35
%46 = load i32, i32* %8
%47 = call i32 @mpz_clear(i32 %46)
%48 = load i32, i32* %9
%49 = call i32 @mpz_clear(i32 %48)
%50 = load i32, i32* %10
%51 = call i32 @mpz_clear(i32 %50)
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Number: %s\0A\00"
@.str.1 = [13 x i8] c"\0A\0AIndex: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_init(i32 undef)
%8 = tail call i32 @mpz_set_ui(i32 undef, i32 1)
%9 = tail call i32 @mpz_set_ui(i32 undef, i32 1)
%10 = call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%11 = call i32 @mpz_get_str(i8* %4, i32 10, i32 undef)
%12 = call i32 @strlen(i8* %4)
%13 = icmp sgt i32 %12, 999
br i1 %13, label %14, label %21
14: ; preds = %21, %2
%15 = phi i32 [ 3, %2 ], [ %25, %21 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
%17 = call i32 @mpz_clear(i32 undef)
%18 = call i32 @mpz_clear(i32 undef)
%19 = call i32 @mpz_clear(i32 undef)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret i32 0
21: ; preds = %2, %21
%22 = phi i32 [ %25, %21 ], [ 3, %2 ]
%23 = call i32 @mpz_set(i32 undef, i32 undef)
%24 = call i32 @mpz_set(i32 undef, i32 undef)
%25 = add i32 %22, 1
%26 = call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%27 = call i32 @mpz_get_str(i8* %4, i32 10, i32 undef)
%28 = call i32 @strlen(i8* %4)
%29 = icmp sgt i32 %28, 999
br i1 %29, label %14, label %21
}