#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 */
char getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ system(char *);
void main() {
  char x;
  int n = 0, k = 0;
  while ((x = getchar()) != '#') {
    switch (x) {
    case 't':
      k++;
      break;
    case 'h':
      if (k == 1)
        k++;
      break;
    case 'e':
      if (k == 2)
        k++;
      break;
    default:
      k = 0;
    }
    if (k == 3)
      n++;
  }
  printf("%d\n", n);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     11f0 <main+0xc0>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x65,%eax
je     11b9 <main+0x89>
jmp    1171 <main+0x41>
mov    -0x10(%rbp),%eax
sub    $0x68,%eax
je     11a1 <main+0x71>
jmp    1182 <main+0x52>
mov    -0x10(%rbp),%eax
sub    $0x74,%eax
jne    11d1 <main+0xa1>
jmp    1193 <main+0x63>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <main+0xa8>
cmpl   $0x1,-0xc(%rbp)
jne    11b4 <main+0x84>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <main+0xa8>
cmpl   $0x2,-0xc(%rbp)
jne    11cc <main+0x9c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <main+0xa8>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jne    11eb <main+0xbb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
mov    -0x8(%rbp),%esi
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
lea    0xdfe(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x23,%al
jne    1160 <main+0x30>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <system@plt>
xor    %ecx,%ecx
xor    %ebx,%ebx
jmp    1185 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    $0x3,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ecx
cmp    $0x23,%al
je     1140 <main+0x10>
movsbl %al,%eax
cmp    $0x65,%eax
je     11b0 <main+0x80>
cmp    $0x68,%eax
je     11a0 <main+0x70>
cmp    $0x74,%eax
jne    11c0 <main+0x90>
add    $0x1,%ecx
jmp    11b5 <main+0x85>
nopl   0x0(%rax)
mov    $0x2,%ebp
cmp    $0x1,%ecx
je     1178 <main+0x48>
jmp    11b5 <main+0x85>
nopl   0x0(%rax)
cmp    $0x2,%ecx
je     1170 <main+0x40>
cmp    $0x3,%ecx
je     1170 <main+0x40>
mov    %ecx,%ebp
jmp    1178 <main+0x48>
xchg   %ax,%ax
xor    %ebp,%ebp
jmp    1178 <main+0x48>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [6 x i8] c"pause\00"
define void @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 35
br i1 %2, label %24, label %3
3: ; preds = %0, %19
%4 = phi i8 [ %22, %19 ], [ %1, %0 ]
%5 = phi i32 [ %20, %19 ], [ 0, %0 ]
%6 = phi i32 [ %21, %19 ], [ 0, %0 ]
%7 = sext i8 %4 to i32
switch i32 %7, label %19 [
i32 116, label %8
i32 104, label %10
i32 101, label %12
]
8: ; preds = %3
%9 = add nsw i32 %5, 1
br label %14
10: ; preds = %3
%11 = icmp eq i32 %5, 1
br i1 %11, label %19, label %14
12: ; preds = %3
%13 = icmp eq i32 %5, 2
br i1 %13, label %17, label %14
14: ; preds = %12, %10, %8
%15 = phi i32 [ %9, %8 ], [ %5, %10 ], [ %5, %12 ]
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %12, %14
%18 = add nsw i32 %6, 1
br label %19
19: ; preds = %10, %3, %14, %17
%20 = phi i32 [ 3, %17 ], [ %15, %14 ], [ 0, %3 ], [ 2, %10 ]
%21 = phi i32 [ %18, %17 ], [ %6, %14 ], [ %6, %3 ], [ %6, %10 ]
%22 = tail call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 35
br i1 %23, label %24, label %3
24: ; preds = %19, %0
%25 = phi i32 [ 0, %0 ], [ %21, %19 ]
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret void
}