#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*/ fcloseall();
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
void *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ streq(char *, char *);
int strlen(char *);
int main() {
  FILE *fi = fopen("FIBISTR.INP", "r"), *fo = fopen("FIBISTR.OUT", "w");
  char **fibi = malloc(35 * sizeof(char *)), s[26], n;
  long i, c;
  fibi[0] = malloc(2);
  fibi[1] = malloc(2);
  fibi[0][0] = 65;
  fibi[1][0] = 66;
  fibi[0][1] = fibi[1][1] = 0;
  for (i = 2; i < 35; i++) {
    fibi[i] = malloc(strlen(fibi[i - 1]) + strlen(fibi[i - 2]) + 1);
    strcpy(fibi[i], fibi[i - 1]);
    strcpy(fibi[i] + strlen(fibi[i - 1]), fibi[i - 2]);
  }
  do {
    fscanf(fi, "%hhd %s\n", &n, s);
    n--;
    c = 0;
    for (i = strlen(fibi[n]) - strlen(s); i >= 0; i--)
      c += streq(s, fibi[n] + i);
    fprintf(fo, "%ld\n", c);
  } while (!feof(fi));
  fcloseall();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe51(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x118,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movb   $0x41,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movb   $0x42,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movb   $0x0,0x1(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,0x1(%rax)
movq   $0x2,-0x50(%rbp)
cmpq   $0x23,-0x50(%rbp)
jge    1301 <main+0x171>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x2,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x64(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x2,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1238 <main+0xa8>
jmp    1306 <main+0x176>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xd07(%rip),%rsi
lea    -0x41(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x41(%rbp),%al
add    $0xff,%al
mov    %al,-0x41(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsbq -0x41(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x68(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
sub    %ecx,%eax
cltq
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jl     1397 <main+0x207>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbq -0x41(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
add    -0x50(%rbp),%rsi
call   1060 <streq@plt>
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    1359 <main+0x1c9>
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xc7f(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1306 <main+0x176>
mov    $0x0,%al
call   10b0 <fcloseall@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe5b(%rip),%rdi
lea    0xe60(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x10(%rsp)
lea    0xe51(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x18(%rsp)
mov    $0x118,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %rax,(%rbx)
mov    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x8(%rbx)
movb   $0x41,(%r12)
movw   $0x42,(%rax)
movb   $0x0,0x1(%r12)
mov    $0x2,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    -0x10(%rbx,%r15,8),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    (%rax,%r13,1),%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,(%rbx,%r15,8)
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r15
mov    %rbp,%r14
cmp    $0x23,%r15
jne    1220 <main+0x90>
lea    0x20(%rsp),%r14
lea    0xda0(%rip),%r12
mov    0x10(%rsp),%r15
jmp    12af <main+0x11f>
nopl   0x0(%rax)
xor    %r13d,%r13d
mov    0x18(%rsp),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1323 <main+0x193>
mov    %r15,%rdi
lea    0xd63(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %r14,%rcx
call   1050 <fscanf@plt>
mov    0xf(%rsp),%al
add    $0xff,%al
mov    %al,0xf(%rsp)
movsbq %al,%rax
mov    (%rbx,%rax,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
sub    %eax,%r13d
js     1290 <main+0x100>
mov    %r13d,%ebp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbq 0xf(%rsp),%rax
mov    (%rbx,%rax,8),%rsi
add    %rbp,%rsi
mov    %r14,%rdi
call   1060 <streq@plt>
add    %rax,%r13
add    $0xffffffffffffffff,%rbp
jb     1300 <main+0x170>
jmp    1293 <main+0x103>
xor    %eax,%eax
call   10b0 <fcloseall@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"FIBISTR.INP\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"FIBISTR.OUT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%hhd %s\0A\00"
@.str.5 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca [26 x i8]
%6 = alloca i8
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 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* %10, i32** %3
%11 = call i8* @malloc(i32 280)
%12 = bitcast i8* %11 to i8**
store i8** %12, i8*** %4
%13 = call i8* @malloc(i32 2)
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 0
store i8* %13, i8** %15
%16 = call i8* @malloc(i32 2)
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 1
store i8* %16, i8** %18
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 65, i8* %22
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8 66, i8* %26
%27 = load i8**, i8*** %4
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 0, i8* %30
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 1
store i8 0, i8* %34
store i64 2, i64* %7
br label %35
35: ; preds = %85, %0
%36 = load i64, i64* %7
%37 = icmp slt i64 %36, 35
br i1 %37, label %38, label %88
38: ; preds = %35
%39 = load i8**, i8*** %4
%40 = load i64, i64* %7
%41 = sub nsw i64 %40, 1
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @strlen(i8* %43)
%45 = load i8**, i8*** %4
%46 = load i64, i64* %7
%47 = sub nsw i64 %46, 2
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %49)
%51 = add nsw i32 %44, %50
%52 = add nsw i32 %51, 1
%53 = call i8* @malloc(i32 %52)
%54 = load i8**, i8*** %4
%55 = load i64, i64* %7
%56 = getelementptr inbounds i8*, i8** %54, i64 %55
store i8* %53, i8** %56
%57 = load i8**, i8*** %4
%58 = load i64, i64* %7
%59 = getelementptr inbounds i8*, i8** %57, i64 %58
%60 = load i8*, i8** %59
%61 = load i8**, i8*** %4
%62 = load i64, i64* %7
%63 = sub nsw i64 %62, 1
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 @strcpy(i8* %60, i8* %65)
%67 = load i8**, i8*** %4
%68 = load i64, i64* %7
%69 = getelementptr inbounds i8*, i8** %67, i64 %68
%70 = load i8*, i8** %69
%71 = load i8**, i8*** %4
%72 = load i64, i64* %7
%73 = sub nsw i64 %72, 1
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @strlen(i8* %75)
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %70, i64 %77
%79 = load i8**, i8*** %4
%80 = load i64, i64* %7
%81 = sub nsw i64 %80, 2
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = call i32 @strcpy(i8* %78, i8* %83)
br label %85
85: ; preds = %38
%86 = load i64, i64* %7
%87 = add nsw i64 %86, 1
store i64 %87, i64* %7
br label %35
88: ; preds = %35
br label %89
89: ; preds = %127, %88
%90 = load i32*, i32** %2
%91 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%92 = call i32 @fscanf(i32* %90, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %91)
%93 = load i8, i8* %6
%94 = add i8 %93, -1
store i8 %94, i8* %6
store i64 0, i64* %8
%95 = load i8**, i8*** %4
%96 = load i8, i8* %6
%97 = sext i8 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = call i32 @strlen(i8* %99)
%101 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%102 = call i32 @strlen(i8* %101)
%103 = sub nsw i32 %100, %102
%104 = sext i32 %103 to i64
store i64 %104, i64* %7
br label %105
105: ; preds = %120, %89
%106 = load i64, i64* %7
%107 = icmp sge i64 %106, 0
br i1 %107, label %108, label %123
108: ; preds = %105
%109 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%110 = load i8**, i8*** %4
%111 = load i8, i8* %6
%112 = sext i8 %111 to i64
%113 = getelementptr inbounds i8*, i8** %110, i64 %112
%114 = load i8*, i8** %113
%115 = load i64, i64* %7
%116 = getelementptr inbounds i8, i8* %114, i64 %115
%117 = call i64 @streq(i8* %109, i8* %116)
%118 = load i64, i64* %8
%119 = add nsw i64 %118, %117
store i64 %119, i64* %8
br label %120
120: ; preds = %108
%121 = load i64, i64* %7
%122 = add nsw i64 %121, -1
store i64 %122, i64* %7
br label %105
123: ; preds = %105
%124 = load i32*, i32** %3
%125 = load i64, i64* %8
%126 = call i32 @fprintf(i32* %124, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %125)
br label %127
127: ; preds = %123
%128 = load i32*, i32** %2
%129 = call i32 @feof(i32* %128)
%130 = icmp ne i32 %129, 0
%131 = xor i1 %130, true
br i1 %131, label %89, label %132
132: ; preds = %127
%133 = call i32 (...) @fcloseall()
ret i32 0
}

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