#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*/ free(char *);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
char *mpz_get_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int i, m = 0;
  char *ns, *ds;
  mpz_t na, nb, nc;
  mpz_t da, db, dc;
  mpz_init_set_ui(na, 1);
  mpz_init_set_ui(da, 1);
  mpz_init_set_ui(nb, 3);
  mpz_init_set_ui(db, 2);
  mpz_init(nc);
  mpz_init(dc);
  for (i = 1; i < 1000; i++) {
    mpz_mul_ui(nc, nb, 2);
    mpz_mul_ui(dc, db, 2);
    mpz_add(nc, na, nc);
    mpz_add(dc, da, dc);
    ns = mpz_get_str(NULL, 10, nc);
    ds = mpz_get_str(NULL, 10, dc);
    if (strlen(ns) > strlen(ds))
      m++;
    free(ns);
    free(ds);
    mpz_set(na, nb);
    mpz_set(da, db);
    mpz_set(nb, nc);
    mpz_set(db, dc);
  }
  printf("%d\n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    -0x38(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    -0x30(%rbp),%edi
mov    $0x3,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    -0x3c(%rbp),%edi
mov    $0x2,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    -0x34(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x40(%rbp),%edi
call   1070 <mpz_init@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    12e6 <main+0x156>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    $0x2,%edx
call   10b0 <mpz_mul_ui@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    $0x2,%edx
call   10b0 <mpz_mul_ui@plt>
mov    -0x34(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1090 <mpz_add@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x40(%rbp),%edx
call   1090 <mpz_add@plt>
mov    -0x34(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %rax,-0x20(%rbp)
mov    -0x40(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jle    129a <main+0x10a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f8 <main+0x68>
mov    -0x18(%rbp),%esi
lea    0xd10(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    $0x1,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    $0x3,%esi
call   10a0 <mpz_init_set_ui@plt>
mov    $0x2,%esi
call   10a0 <mpz_init_set_ui@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
xor    %r14d,%r14d
mov    $0x3e7,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2,%edx
call   10b0 <mpz_mul_ui@plt>
mov    $0x2,%edx
call   10b0 <mpz_mul_ui@plt>
call   1090 <mpz_add@plt>
call   1090 <mpz_add@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <strlen@plt>
xor    %ecx,%ecx
cmp    %rax,%r12
setg   %cl
add    %ecx,%r14d
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
call   1040 <mpz_set@plt>
call   1040 <mpz_set@plt>
call   1040 <mpz_set@plt>
call   1040 <mpz_set@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0x50>
lea    0xd92(%rip),%rdi
mov    %r14d,%esi
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%16 = load i32, i32* %10
%17 = call i32 @mpz_init_set_ui(i32 %16, i32 1)
%18 = load i32, i32* %13
%19 = call i32 @mpz_init_set_ui(i32 %18, i32 1)
%20 = load i32, i32* %11
%21 = call i32 @mpz_init_set_ui(i32 %20, i32 3)
%22 = load i32, i32* %14
%23 = call i32 @mpz_init_set_ui(i32 %22, i32 2)
%24 = load i32, i32* %12
%25 = call i32 @mpz_init(i32 %24)
%26 = load i32, i32* %15
%27 = call i32 @mpz_init(i32 %26)
store i32 1, i32* %6
br label %28
28: ; preds = %75, %2
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 1000
br i1 %30, label %31, label %78
31: ; preds = %28
%32 = load i32, i32* %12
%33 = load i32, i32* %11
%34 = call i32 @mpz_mul_ui(i32 %32, i32 %33, i32 2)
%35 = load i32, i32* %15
%36 = load i32, i32* %14
%37 = call i32 @mpz_mul_ui(i32 %35, i32 %36, i32 2)
%38 = load i32, i32* %12
%39 = load i32, i32* %10
%40 = load i32, i32* %12
%41 = call i32 @mpz_add(i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %15
%43 = load i32, i32* %13
%44 = load i32, i32* %15
%45 = call i32 @mpz_add(i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %12
%47 = call i8* @mpz_get_str(i32* null, i32 10, i32 %46)
store i8* %47, i8** %8
%48 = load i32, i32* %15
%49 = call i8* @mpz_get_str(i32* null, i32 10, i32 %48)
store i8* %49, i8** %9
%50 = load i8*, i8** %8
%51 = call i64 @strlen(i8* %50)
%52 = load i8*, i8** %9
%53 = call i64 @strlen(i8* %52)
%54 = icmp sgt i64 %51, %53
br i1 %54, label %55, label %58
55: ; preds = %31
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %58
58: ; preds = %55, %31
%59 = load i8*, i8** %8
%60 = call i32 @free(i8* %59)
%61 = load i8*, i8** %9
%62 = call i32 @free(i8* %61)
%63 = load i32, i32* %10
%64 = load i32, i32* %11
%65 = call i32 @mpz_set(i32 %63, i32 %64)
%66 = load i32, i32* %13
%67 = load i32, i32* %14
%68 = call i32 @mpz_set(i32 %66, i32 %67)
%69 = load i32, i32* %11
%70 = load i32, i32* %12
%71 = call i32 @mpz_set(i32 %69, i32 %70)
%72 = load i32, i32* %14
%73 = load i32, i32* %15
%74 = call i32 @mpz_set(i32 %72, i32 %73)
br label %75
75: ; preds = %58
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %28
78: ; preds = %28
%79 = load i32, i32* %7
%80 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
ret i32 0
}

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