#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int main() {
  FILE *in, *out;
  in = fopen("lwf_input_1.txt", "r");
  out = fopen("output.txt", "w");
  int n, f1, f2, f3, i, j, max, T = 1, maxT;
  int num[30];
  fscanf(in, "%d", &maxT);
  for (T = 1; T <= maxT; T++) {
    fscanf(in, "%d", &n);
    f1 = f2 = f3 = 1;
    i = -1;
    while (f2 <= n) {
      f1 = f2;
      f2 = f3;
      f3 = f1 + f2;
      i++;
    }
    for (j = 0; j < i; j++) {
      num[j] = 0;
    }
    max = i;
    while (n > 0) {
      if (f1 <= n) {
        n = n - f1;
        num[i] = 1;
      }
      f3 = f2;
      f2 = f1;
      f1 = f3 - f2;
      i--;
    }
    fprintf(out, "Case #%d: ", T);
    for (i = 0; i <= max; i++) {
      fprintf(out, "%d", num[i]);
    }
    fprintf(out, "\n");
  }
  fclose(in);
  fclose(out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1040 <fscanf@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1307 <main+0x1c7>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     120d <main+0xcd>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11de <main+0x9e>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    123d <main+0xfd>
movslq -0x30(%rbp),%rax
movl   $0x0,-0xc0(%rbp,%rax,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1214 <main+0xd4>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1294 <main+0x154>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1271 <main+0x131>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x2c(%rbp),%rax
movl   $0x1,-0xc0(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1243 <main+0x103>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     12e7 <main+0x1a7>
mov    -0x18(%rbp),%rdi
movslq -0x2c(%rbp),%rax
mov    -0xc0(%rbp,%rax,4),%edx
lea    0xd4d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12b0 <main+0x170>
mov    -0x18(%rbp),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11a2 <main+0x62>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe88(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe7b(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <fscanf@plt>
cmpl   $0x0,(%rsp)
jle    131f <main+0x1bf>
mov    $0x1,%r12d
lea    0xe54(%rip),%r15
mov    %r14,0x10(%rsp)
jmp    1213 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
lea    0xe38(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
lea    0x1(%r12),%eax
cmp    (%rsp),%r12d
mov    %eax,%r12d
jge    131f <main+0x1bf>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
lea    0x4(%rsp),%rdx
call   1050 <fscanf@plt>
mov    0x4(%rsp),%r13d
test   %r13d,%r13d
jle    11e0 <main+0x80>
mov    %r12,0x18(%rsp)
xor    %r12d,%r12d
mov    $0xfffffffffffffffc,%rdx
mov    $0x1,%eax
mov    $0x1,%ecx
mov    $0x1,%r14d
xchg   %ax,%ax
mov    %r14d,%r15d
mov    %ecx,%r14d
mov    %eax,%ebp
lea    (%r14,%r15,1),%ecx
add    $0x1,%r12d
add    $0x4,%rdx
lea    0x1(%rbp),%eax
cmp    %r13d,%r14d
jle    1250 <main+0xf0>
mov    %r12d,%ebx
add    $0xfffffffe,%ebx
js     1280 <main+0x120>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %r13d,%r13d
jle    12c0 <main+0x160>
add    $0xffffffff,%r12d
movslq %r12d,%rax
jmp    12a2 <main+0x142>
xchg   %ax,%ax
sub    %ecx,%r14d
add    $0xffffffffffffffff,%rax
mov    %r14d,%r15d
mov    %ecx,%r14d
test   %r13d,%r13d
jle    12c0 <main+0x160>
mov    %r15d,%ecx
mov    %r13d,%edx
sub    %r15d,%edx
jl     1290 <main+0x130>
mov    %edx,0x4(%rsp)
movl   $0x1,0x20(%rsp,%rax,4)
mov    %edx,%r13d
jmp    1290 <main+0x130>
xchg   %ax,%ax
mov    0x10(%rsp),%r14
mov    %r14,%rdi
lea    0xd53(%rip),%rsi
mov    0x18(%rsp),%r12
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    $0xffffffff,%ebx
lea    0xd37(%rip),%r15
jl     11f4 <main+0x94>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x20(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1300 <main+0x1a0>
jmp    11f4 <main+0x94>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"lwf_input_1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"Case #%d: \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [30 x i32]
store i32 0, i32* %1
%14 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %2
%15 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %15, i32** %3
store i32 1, i32* %11
%16 = load i32*, i32** %2
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %12)
store i32 1, i32* %11
br label %18
18: ; preds = %94, %0
%19 = load i32, i32* %11
%20 = load i32, i32* %12
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %97
22: ; preds = %18
%23 = load i32*, i32** %2
%24 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
store i32 1, i32* %7
store i32 1, i32* %6
store i32 1, i32* %5
store i32 -1, i32* %8
br label %25
25: ; preds = %29, %22
%26 = load i32, i32* %6
%27 = load i32, i32* %4
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load i32, i32* %6
store i32 %30, i32* %5
%31 = load i32, i32* %7
store i32 %31, i32* %6
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = add nsw i32 %32, %33
store i32 %34, i32* %7
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %25
37: ; preds = %25
store i32 0, i32* %9
br label %38
38: ; preds = %46, %37
%39 = load i32, i32* %9
%40 = load i32, i32* %8
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [30 x i32], [30 x i32]* %13, i64 0, i64 %44
store i32 0, i32* %45
br label %46
46: ; preds = %42
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %38
49: ; preds = %38
%50 = load i32, i32* %8
store i32 %50, i32* %10
br label %51
51: ; preds = %65, %49
%52 = load i32, i32* %4
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %73
54: ; preds = %51
%55 = load i32, i32* %5
%56 = load i32, i32* %4
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %65
58: ; preds = %54
%59 = load i32, i32* %4
%60 = load i32, i32* %5
%61 = sub nsw i32 %59, %60
store i32 %61, i32* %4
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [30 x i32], [30 x i32]* %13, i64 0, i64 %63
store i32 1, i32* %64
br label %65
65: ; preds = %58, %54
%66 = load i32, i32* %6
store i32 %66, i32* %7
%67 = load i32, i32* %5
store i32 %67, i32* %6
%68 = load i32, i32* %7
%69 = load i32, i32* %6
%70 = sub nsw i32 %68, %69
store i32 %70, i32* %5
%71 = load i32, i32* %8
%72 = add nsw i32 %71, -1
store i32 %72, i32* %8
br label %51
73: ; preds = %51
%74 = load i32*, i32** %3
%75 = load i32, i32* %11
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %75)
store i32 0, i32* %8
br label %77
77: ; preds = %88, %73
%78 = load i32, i32* %8
%79 = load i32, i32* %10
%80 = icmp sle i32 %78, %79
br i1 %80, label %81, label %91
81: ; preds = %77
%82 = load i32*, i32** %3
%83 = load i32, i32* %8
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [30 x i32], [30 x i32]* %13, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %81
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %77
91: ; preds = %77
%92 = load i32*, i32** %3
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %94
94: ; preds = %91
%95 = load i32, i32* %11
%96 = add nsw i32 %95, 1
store i32 %96, i32* %11
br label %18
97: ; preds = %18
%98 = load i32*, i32** %2
%99 = call i32 @fclose(i32* %98)
%100 = load i32*, i32** %3
%101 = call i32 @fclose(i32* %100)
%102 = load i32, i32* %1
ret i32 %102
}

LLVM IR (-O2):
@.str = [16 x i8] c"lwf_input_1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"Case #%d: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i32]
%4 = bitcast [30 x i32]* %3 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1
br i1 %11, label %67, label %12
12: ; preds = %0, %62
%13 = phi i32 [ %64, %62 ], [ 1, %0 ]
%14 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %13)
br label %62
19: ; preds = %24
%20 = icmp sgt i32 %25, -1
br i1 %20, label %21, label %31
21: ; preds = %19
%22 = zext i32 %29 to i64
%23 = shl nuw nsw i64 %22, 2
br label %31
24: ; preds = %12, %24
%25 = phi i32 [ %29, %24 ], [ -1, %12 ]
%26 = phi i32 [ %28, %24 ], [ 1, %12 ]
%27 = phi i32 [ %26, %24 ], [ 1, %12 ]
%28 = add nsw i32 %26, %27
%29 = add nsw i32 %25, 1
%30 = icmp sgt i32 %26, %15
br i1 %30, label %19, label %24
31: ; preds = %21, %19
%32 = icmp sgt i32 %15, 0
br i1 %32, label %33, label %49
33: ; preds = %31
%34 = sext i32 %29 to i64
br label %35
35: ; preds = %33, %44
%36 = phi i64 [ %34, %33 ], [ %47, %44 ]
%37 = phi i32 [ %27, %33 ], [ %46, %44 ]
%38 = phi i32 [ %26, %33 ], [ %37, %44 ]
%39 = phi i32 [ %15, %33 ], [ %45, %44 ]
%40 = icmp slt i32 %39, %37
br i1 %40, label %44, label %41
41: ; preds = %35
%42 = sub nsw i32 %39, %37
store i32 %42, i32* %1
%43 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %36
store i32 1, i32* %43
br label %44
44: ; preds = %41, %35
%45 = phi i32 [ %42, %41 ], [ %39, %35 ]
%46 = sub nsw i32 %38, %37
%47 = add i64 %36, -1
%48 = icmp sgt i32 %45, 0
br i1 %48, label %35, label %49
49: ; preds = %44, %31
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%51 = icmp slt i32 %25, -1
br i1 %51, label %62, label %52
52: ; preds = %49
%53 = add i32 %25, 2
%54 = zext i32 %53 to i64
br label %55
55: ; preds = %52, %55
%56 = phi i64 [ 0, %52 ], [ %60, %55 ]
%57 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %58)
%60 = add nuw nsw i64 %56, 1
%61 = icmp eq i64 %60, %54
br i1 %61, label %62, label %55
62: ; preds = %55, %17, %49
%63 = call i32 @fputc(i32 10, i32* %6)
%64 = add nuw nsw i32 %13, 1
%65 = load i32, i32* %2
%66 = icmp slt i32 %13, %65
br i1 %66, label %12, label %67
67: ; preds = %62, %0
%68 = call i32 @fclose(i32* %5)
%69 = call i32 @fclose(i32* %6)
ret i32 0
}