int main() {
  int maxlen = 1000;
  int i = 0;
  char **vector = (char **)calloc(1, sizeof(char *));
  fib(i, &vector);
  while (strlen(vector[i]) < maxlen)
    fib(++i, &vector);
  int j;
  for (j = 0; j <= i; ++j)
    free(vector[j]);
  free(vector);
  printf("%d\n", i);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <fib@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11d5 <main+0x75>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0xc(%rbp)
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <fib@plt>
jmp    119e <main+0x3e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1207 <main+0xa7>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <main+0x7c>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,(%rsp)
xor    %r15d,%r15d
mov    %rsp,%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1070 <fib@plt>
mov    (%rsp),%r12
mov    (%r12),%rdi
call   1040 <strlen@plt>
cmp    $0x3e7,%rax
ja     11da <main+0x7a>
mov    %rsp,%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rbx
add    $0x1,%r15
mov    %r15d,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <fib@plt>
mov    (%rsp),%r12
mov    0x8(%r12,%rbx,8),%rdi
call   1040 <strlen@plt>
cmp    $0x3e8,%rax
jb     11b0 <main+0x50>
mov    (%r12),%rdi
call   1030 <free@plt>
test   %r15d,%r15d
je     1216 <main+0xb6>
lea    0x1(%r15),%r14d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1200 <main+0xa0>
mov    (%rsp),%rdi
call   1030 <free@plt>
lea    0xdda(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 0, i32* %1
store i32 1000, i32* %2
store i32 0, i32* %3
%6 = call i8* @calloc(i64 1, i64 8)
%7 = bitcast i8* %6 to i8**
store i8** %7, i8*** %4
%8 = load i32, i32* %3
%9 = call i32 (i32, i8***, ...) bitcast (i32 (...)* @fib to i32 (i32, i8***, ...)*)(i32 %8, i8*** %4)
br label %10
10: ; preds = %20, %0
%11 = load i8**, i8*** %4
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = icmp ult i64 %16, %18
br i1 %19, label %20, label %24
20: ; preds = %10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = call i32 (i32, i8***, ...) bitcast (i32 (...)* @fib to i32 (i32, i8***, ...)*)(i32 %22, i8*** %4)
br label %10
24: ; preds = %10
store i32 0, i32* %5
br label %25
25: ; preds = %35, %24
%26 = load i32, i32* %5
%27 = load i32, i32* %3
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i8**, i8*** %4
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
br label %35
35: ; preds = %29
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %25
38: ; preds = %25
%39 = load i8**, i8*** %4
%40 = bitcast i8** %39 to i8*
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i8**
%2 = bitcast i8*** %1 to i8*
%3 = tail call dereferenceable_or_null(8) i8* @calloc(i64 1, i64 8)
%4 = bitcast i8*** %1 to i8**
store i8* %3, i8** %4
%5 = call i32 (i32, i8***, ...) bitcast (i32 (...)* @fib to i32 (i32, i8***, ...)*)(i32 0, i8*** %1)
%6 = load i8**, i8*** %1
%7 = load i8*, i8** %6
%8 = call i64 @strlen(i8* dereferenceable(1) %7)
%9 = icmp ult i64 %8, 1000
br i1 %9, label %19, label %12
10: ; preds = %19
%11 = trunc i64 %21 to i32
br label %12
12: ; preds = %10, %0
%13 = phi i8** [ %6, %0 ], [ %24, %10 ]
%14 = phi i32 [ 0, %0 ], [ %11, %10 ]
%15 = add i32 %14, 1
%16 = zext i32 %15 to i64
%17 = load i8*, i8** %13
%18 = icmp eq i32 %14, 0
br i1 %18, label %36, label %29
19: ; preds = %0, %19
%20 = phi i64 [ %21, %19 ], [ 0, %0 ]
%21 = add nuw nsw i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i32 (i32, i8***, ...) bitcast (i32 (...)* @fib to i32 (i32, i8***, ...)*)(i32 %22, i8*** %1)
%24 = load i8**, i8*** %1
%25 = getelementptr inbounds i8*, i8** %24, i64 %21
%26 = load i8*, i8** %25
%27 = call i64 @strlen(i8* dereferenceable(1) %26)
%28 = icmp ult i64 %27, 1000
br i1 %28, label %19, label %10
29: ; preds = %12, %29
%30 = phi i64 [ %34, %29 ], [ 1, %12 ]
%31 = load i8**, i8*** %1
%32 = getelementptr inbounds i8*, i8** %31, i64 %30
%33 = load i8*, i8** %32
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %16
br i1 %35, label %36, label %29
36: ; preds = %29, %12
%37 = load i8*, i8** %4
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
unreachable
}