#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 TCount(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gets(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  char *psz = (char *)malloc(1000 * sizeof(char));
  scanf("%d", &n);
  gets(psz);
  while (n-- > 0) {
    gets(psz);
    printf("%d\n", TCount(psz));
  }
  free(psz);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <gets@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11cf <main+0x6f>
mov    -0x10(%rbp),%rdi
call   1050 <gets@plt>
mov    -0x10(%rbp),%rdi
call   1070 <TCount@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    1196 <main+0x36>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    11c9 <main+0x69>
lea    0xe63(%rip),%r14
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1070 <TCount@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jg     11a0 <main+0x40>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i64 @malloc(i32 1000)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i8*, i8** %3
%8 = call i32 @gets(i8* %7)
br label %9
9: ; preds = %13, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 @gets(i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @TCount(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %9
19: ; preds = %9
%20 = load i8*, i8** %3
%21 = call i32 @free(i8* %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i64 @malloc(i32 1000)
%4 = inttoptr i64 %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = call i32 @gets(i8* %4)
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %17
10: ; preds = %0, %10
%11 = call i32 @gets(i8* %4)
%12 = call i32 @TCount(i8* %4)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = add nsw i32 %14, -1
store i32 %15, i32* %1
%16 = icmp sgt i32 %14, 0
br i1 %16, label %10, label %17
17: ; preds = %10, %0
%18 = call i32 @free(i8* %4)
ret i32 0
}