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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  int t, n, i, x;
  int inc[8][2] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
  char in[41], initial[4] = "abc";
  scanf("%d", &t);
  while (t--) {
    int out[8] = {0};
    scanf("%d", &n);
    scanf("%s", in);
    initial[0] = in[0];
    initial[1] = in[1];
    initial[2] = in[2];
    if (strcmp(initial, "TTT") == 0) {
      out[0]++;
      x = 0;
    }
    if (strcmp(initial, "TTH") == 0) {
      out[1]++;
      x = 1;
    }
    if (strcmp(initial, "THT") == 0) {
      out[2]++;
      x = 2;
    }
    if (strcmp(initial, "THH") == 0) {
      out[3]++;
      x = 3;
    }
    if (strcmp(initial, "HTT") == 0) {
      out[4]++;
      x = 4;
    }
    if (strcmp(initial, "HTH") == 0) {
      out[5]++;
      x = 5;
    }
    if (strcmp(initial, "HHT") == 0) {
      out[6]++;
      x = 6;
    }
    if (strcmp(initial, "HHH") == 0) {
      out[7]++;
      x = 7;
    }
    for (i = 3; i < 40; i++) {
      if (in[i] == 'T')
        x = inc[x][0];
      else
        x = inc[x][1];
      out[x]++;
    }
    printf("%d ", n);
    for (i = 0; i < 7; i++)
      printf("%d ", out[i]);
    printf("%d\n", out[7]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
mov    0xec3(%rip),%eax
mov    %eax,-0x94(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     145f <main+0x30f>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    0xe81(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x90(%rbp),%al
mov    %al,-0x94(%rbp)
mov    -0x8f(%rbp),%al
mov    %al,-0x93(%rbp)
mov    -0x8e(%rbp),%al
mov    %al,-0x92(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123a <main+0xea>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    126d <main+0x11d>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12a0 <main+0x150>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
movl   $0x2,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12d3 <main+0x183>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
movl   $0x3,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1306 <main+0x1b6>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
movl   $0x4,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xd4a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1339 <main+0x1e9>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xd1b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    136c <main+0x21c>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
movl   $0x6,-0x14(%rbp)
lea    -0x94(%rbp),%rdi
lea    0xcec(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    139f <main+0x24f>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
movl   $0x7,-0x14(%rbp)
movl   $0x3,-0x10(%rbp)
cmpl   $0x28,-0x10(%rbp)
jge    1403 <main+0x2b3>
movslq -0x10(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x54,%eax
jne    13d5 <main+0x285>
movslq -0x14(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%eax
mov    %eax,-0x14(%rbp)
jmp    13e0 <main+0x290>
movslq -0x14(%rbp),%rax
mov    -0x5c(%rbp,%rax,8),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc0(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    13a6 <main+0x256>
mov    -0xc(%rbp),%esi
lea    0xc5d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    1448 <main+0x2f8>
movslq -0x10(%rbp),%rax
mov    -0xc0(%rbp,%rax,4),%esi
lea    0xc35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1419 <main+0x2c9>
mov    -0xa4(%rbp),%esi
lea    0xc19(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <main+0x45>
xor    %eax,%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    $0x78,%rsp
movl   $0x636261,0x8(%rsp)
lea    0xef3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1171 <main+0x41>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%rbp
lea    0xee5(%rip),%r15
lea    0xe7c(%rip),%rbx
lea    0xedb(%rip),%r12
lea    0xed8(%rip),%r13
jmp    1217 <main+0xe7>
nopw   0x0(%rax,%rax,1)
mov    0x3c(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %r13,%rdi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1160 <main+0x30>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe15(%rip),%rdi
lea    0x3c(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe05(%rip),%rdi
lea    0x40(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x40(%rsp),%al
mov    %al,0x8(%rsp)
movzwl 0x41(%rsp),%eax
mov    %ax,0x9(%rsp)
mov    %rbp,%rdi
lea    0xde0(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    127b <main+0x14b>
movl   $0x1,0x10(%rsp)
xor    %r14d,%r14d
mov    %rbp,%rdi
lea    0xdc5(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    129d <main+0x16d>
movl   $0x1,0x14(%rsp)
mov    $0x1,%r14d
mov    %rbp,%rdi
lea    0xda7(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12bf <main+0x18f>
movl   $0x1,0x18(%rsp)
mov    $0x2,%r14d
mov    %rbp,%rdi
lea    0xd89(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12e1 <main+0x1b1>
movl   $0x1,0x1c(%rsp)
mov    $0x3,%r14d
mov    %rbp,%rdi
lea    0xd6b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1303 <main+0x1d3>
movl   $0x1,0x20(%rsp)
mov    $0x4,%r14d
mov    %rbp,%rdi
lea    0xd4d(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1325 <main+0x1f5>
movl   $0x1,0x24(%rsp)
mov    $0x5,%r14d
mov    %rbp,%rdi
lea    0xd2f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1347 <main+0x217>
movl   $0x1,0x28(%rsp)
mov    $0x6,%r14d
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1365 <main+0x235>
movl   $0x1,0x2c(%rsp)
mov    $0x7,%r14d
mov    $0x4,%eax
nopw   0x0(%rax,%rax,1)
cmpb   $0x54,0x3f(%rsp,%rax,1)
movslq %r14d,%rcx
lea    (%rbx,%rcx,8),%rdx
lea    0x4(%rbx,%rcx,8),%rcx
cmove  %rdx,%rcx
mov    (%rcx),%r14d
movslq %r14d,%rcx
addl   $0x1,0x10(%rsp,%rcx,4)
cmp    $0x28,%rax
je     11a0 <main+0x70>
cmpb   $0x54,0x40(%rsp,%rax,1)
lea    (%rbx,%rcx,8),%rdx
lea    0x4(%rbx,%rcx,8),%rcx
cmove  %rdx,%rcx
movslq (%rcx),%r14
addl   $0x1,0x10(%rsp,%r14,4)
add    $0x2,%rax
jmp    1370 <main+0x240>

LLVM IR (-O0):
@__const.main.inc = [8 x [2 x i32]] [[2 x i32] [i32 0, i32 1], [2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 6, i32 7], [2 x i32] [i32 0, i32 1], [2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 6, i32 7]]
@__const.main.initial = [4 x i8] c"abc\00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"TTT\00"
@.str.3 = [4 x i8] c"TTH\00"
@.str.4 = [4 x i8] c"THT\00"
@.str.5 = [4 x i8] c"THH\00"
@.str.6 = [4 x i8] c"HTT\00"
@.str.7 = [4 x i8] c"HTH\00"
@.str.8 = [4 x i8] c"HHT\00"
@.str.9 = [4 x i8] c"HHH\00"
@.str.10 = [4 x i8] c"%d \00"
@.str.11 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [8 x [2 x i32]]
%7 = alloca [41 x i8]
%8 = alloca [4 x i8]
%9 = alloca [8 x i32]
store i32 0, i32* %1
%10 = bitcast [8 x [2 x i32]]* %6 to i8*
%11 = bitcast [4 x i8]* %8 to i8*
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %141, %0
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
%16 = icmp ne i32 %14, 0
br i1 %16, label %17, label %145
17: ; preds = %13
%18 = bitcast [8 x i32]* %9 to i8*
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%23 = load i8, i8* %22
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
store i8 %23, i8* %24
%25 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 1
%26 = load i8, i8* %25
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 1
store i8 %26, i8* %27
%28 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 2
%29 = load i8, i8* %28
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 2
store i8 %29, i8* %30
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %17
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 0
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %35
store i32 0, i32* %5
br label %38
38: ; preds = %34, %17
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 1
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
store i32 1, i32* %5
br label %46
46: ; preds = %42, %38
%47 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 2
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
store i32 %53, i32* %51
store i32 2, i32* %5
br label %54
54: ; preds = %50, %46
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 3
%60 = load i32, i32* %59
%61 = add nsw i32 %60, 1
store i32 %61, i32* %59
store i32 3, i32* %5
br label %62
62: ; preds = %58, %54
%63 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 4
%68 = load i32, i32* %67
%69 = add nsw i32 %68, 1
store i32 %69, i32* %67
store i32 4, i32* %5
br label %70
70: ; preds = %66, %62
%71 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 5
%76 = load i32, i32* %75
%77 = add nsw i32 %76, 1
store i32 %77, i32* %75
store i32 5, i32* %5
br label %78
78: ; preds = %74, %70
%79 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 6
%84 = load i32, i32* %83
%85 = add nsw i32 %84, 1
store i32 %85, i32* %83
store i32 6, i32* %5
br label %86
86: ; preds = %82, %78
%87 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 7
%92 = load i32, i32* %91
%93 = add nsw i32 %92, 1
store i32 %93, i32* %91
store i32 7, i32* %5
br label %94
94: ; preds = %90, %86
store i32 3, i32* %4
br label %95
95: ; preds = %123, %94
%96 = load i32, i32* %4
%97 = icmp slt i32 %96, 40
br i1 %97, label %98, label %126
98: ; preds = %95
%99 = load i32, i32* %4
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 84
br i1 %104, label %105, label %111
105: ; preds = %98
%106 = load i32, i32* %5
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* %6, i64 0, i64 %107
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %108, i64 0, i64 0
%110 = load i32, i32* %109
store i32 %110, i32* %5
br label %117
111: ; preds = %98
%112 = load i32, i32* %5
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* %6, i64 0, i64 %113
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %114, i64 0, i64 1
%116 = load i32, i32* %115
store i32 %116, i32* %5
br label %117
117: ; preds = %111, %105
%118 = load i32, i32* %5
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 %119
%121 = load i32, i32* %120
%122 = add nsw i32 %121, 1
store i32 %122, i32* %120
br label %123
123: ; preds = %117
%124 = load i32, i32* %4
%125 = add nsw i32 %124, 1
store i32 %125, i32* %4
br label %95
126: ; preds = %95
%127 = load i32, i32* %3
%128 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %127)
store i32 0, i32* %4
br label %129
129: ; preds = %138, %126
%130 = load i32, i32* %4
%131 = icmp slt i32 %130, 7
br i1 %131, label %132, label %141
132: ; preds = %129
%133 = load i32, i32* %4
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 %134
%136 = load i32, i32* %135
%137 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %136)
br label %138
138: ; preds = %132
%139 = load i32, i32* %4
%140 = add nsw i32 %139, 1
store i32 %140, i32* %4
br label %129
141: ; preds = %129
%142 = getelementptr inbounds [8 x i32], [8 x i32]* %9, i64 0, i64 7
%143 = load i32, i32* %142
%144 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %143)
br label %13
145: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.inc = [8 x [2 x i32]] [[2 x i32] [i32 0, i32 1], [2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 6, i32 7], [2 x i32] [i32 0, i32 1], [2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 6, i32 7]]
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"TTT\00"
@.str.3 = [4 x i8] c"TTH\00"
@.str.4 = [4 x i8] c"THT\00"
@.str.5 = [4 x i8] c"THH\00"
@.str.6 = [4 x i8] c"HTT\00"
@.str.7 = [4 x i8] c"HTH\00"
@.str.8 = [4 x i8] c"HHT\00"
@.str.9 = [4 x i8] c"HHH\00"
@.str.10 = [4 x i8] c"%d \00"
@.str.11 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [41 x i8]
%4 = alloca i32
%5 = bitcast i32* %4 to [4 x i8]*
%6 = alloca [8 x i32]
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
store i32 6513249, i32* %4
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
store i32 %13, i32* %1
%14 = icmp eq i32 %12, 0
br i1 %14, label %129, label %15
15: ; preds = %0
%16 = bitcast [8 x i32]* %6 to i8*
%17 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 1
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
%19 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 2
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 1
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 2
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 3
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 4
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 5
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 6
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 7
br label %29
29: ; preds = %15, %107
%30 = phi i32 [ undef, %15 ], [ %86, %107 ]
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%33 = load i8, i8* %9
store i8 %33, i8* %10
%34 = load i8, i8* %17
store i8 %34, i8* %18
%35 = load i8, i8* %19
store i8 %35, i8* %20
%36 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %29
store i32 1, i32* %21
br label %39
39: ; preds = %38, %29
%40 = phi i32 [ 0, %38 ], [ %30, %29 ]
%41 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 1, i32* %22
br label %44
44: ; preds = %43, %39
%45 = phi i32 [ 1, %43 ], [ %40, %39 ]
%46 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 1, i32* %23
br label %49
49: ; preds = %48, %44
%50 = phi i32 [ 2, %48 ], [ %45, %44 ]
%51 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %49
store i32 1, i32* %24
br label %54
54: ; preds = %53, %49
%55 = phi i32 [ 3, %53 ], [ %50, %49 ]
%56 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 1, i32* %25
br label %59
59: ; preds = %58, %54
%60 = phi i32 [ 4, %58 ], [ %55, %54 ]
%61 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %59
store i32 1, i32* %26
br label %64
64: ; preds = %63, %59
%65 = phi i32 [ 5, %63 ], [ %60, %59 ]
%66 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64
store i32 1, i32* %27
br label %69
69: ; preds = %68, %64
%70 = phi i32 [ 6, %68 ], [ %65, %64 ]
%71 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %69
store i32 1, i32* %28
br label %74
74: ; preds = %73, %69
%75 = phi i32 [ %70, %69 ], [ 7, %73 ]
br label %76
76: ; preds = %93, %74
%77 = phi i64 [ 3, %74 ], [ %106, %93 ]
%78 = phi i32 [ %75, %74 ], [ %101, %93 ]
%79 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 %77
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 84
%82 = sext i32 %78 to i64
%83 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* @__const.main.inc, i64 0, i64 %82, i64 0
%84 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* @__const.main.inc, i64 0, i64 %82, i64 1
%85 = select i1 %81, i32* %83, i32* %84
%86 = load i32, i32* %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = add nsw i32 %89, 1
store i32 %90, i32* %88
%91 = add nuw nsw i64 %77, 1
%92 = icmp eq i64 %91, 40
br i1 %92, label %107, label %93
93: ; preds = %76
%94 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 %91
%95 = load i8, i8* %94
%96 = icmp eq i8 %95, 84
%97 = sext i32 %86 to i64
%98 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* @__const.main.inc, i64 0, i64 %97, i64 0
%99 = getelementptr inbounds [8 x [2 x i32]], [8 x [2 x i32]]* @__const.main.inc, i64 0, i64 %97, i64 1
%100 = select i1 %96, i32* %98, i32* %99
%101 = load i32, i32* %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = add nsw i32 %104, 1
store i32 %105, i32* %103
%106 = add nuw nsw i64 %77, 2
br label %76
107: ; preds = %76
%108 = load i32, i32* %2
%109 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %21
%111 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %110)
%112 = load i32, i32* %22
%113 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %112)
%114 = load i32, i32* %23
%115 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %24
%117 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %25
%119 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %118)
%120 = load i32, i32* %26
%121 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %120)
%122 = load i32, i32* %27
%123 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %122)
%124 = load i32, i32* %28
%125 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %1
%127 = add nsw i32 %126, -1
store i32 %127, i32* %1
%128 = icmp eq i32 %126, 0
br i1 %128, label %129, label %29
129: ; preds = %107, %0
ret i32 0
}