#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 *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char tolower(char);
int main(void) {
  int i, count = 0;
  char word[12], text[1001];
  scanf(" %s", word);
  while (1) {
    scanf(" %s", text);
    if (strcmp(text, "END_OF_TEXT") == 0)
      break;
    for (i = 0; i < strlen(text); i++)
      text[i] = tolower(text[i]);
    if (strcmp(text, word) == 0)
      count++;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x18(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x410(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ae <main+0x5e>
jmp    122e <main+0xde>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x414(%rbp),%eax
cmp    %ecx,%eax
jge    1206 <main+0xb6>
movslq -0x8(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b5 <main+0x65>
lea    -0x410(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1229 <main+0xd9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1179 <main+0x29>
mov    -0xc(%rbp),%esi
lea    0xdd8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe98(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1223 <main+0xd3>
lea    0x10(%rsp),%rbx
lea    0x4(%rsp),%r15
lea    0xe4f(%rip),%r12
lea    0xe4c(%rip),%r13
jmp    11ee <main+0x9e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
cmp    $0x1,%rax
adc    $0x0,%r14d
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1223 <main+0xd3>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11c0 <main+0x70>
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl 0x10(%rsp,%rbp,1),%edi
call   1060 <tolower@plt>
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1200 <main+0xb0>
jmp    11c0 <main+0x70>
lea    0xde6(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c" %s\00"
@.str.1 = [12 x i8] c"END_OF_TEXT\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = alloca [1001 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %30, label %9
9: ; preds = %0, %22
%10 = phi i32 [ %26, %22 ], [ 0, %0 ]
%11 = call i32 @strlen(i8* %4)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %9, %13
%14 = phi i64 [ %18, %13 ], [ 0, %9 ]
%15 = getelementptr inbounds [1001 x i8], [1001 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = call signext i8 @tolower(i8 signext %16)
store i8 %17, i8* %15
%18 = add nuw nsw i64 %14, 1
%19 = call i32 @strlen(i8* %4)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %13, label %22
22: ; preds = %13, %9
%23 = call i64 @strcmp(i8* %4, i8* %3)
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
%26 = add nuw nsw i32 %10, %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%28 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %9
30: ; preds = %22, %0
%31 = phi i32 [ 0, %0 ], [ %26, %22 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
ret i32 0
}