#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 main() {
  int count = 0;
  char ch;
  int flag = 0;
  int i = 0;
  int last_i = 0;
  while ('\n' != (ch = getchar())) {
    if ('e' == ch) {
      flag = 1;
      last_i = i;
    }
    if ('i' == ch && flag == 1) {
      if (1 == (i - last_i)) {
        count = count + 1;
        flag = 0;
      }
    }
    i++;
  }
  printf("%d", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
je     11d4 <main+0xb4>
movsbl -0x9(%rbp),%ecx
mov    $0x65,%eax
cmp    %ecx,%eax
jne    1183 <main+0x63>
movl   $0x1,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x69,%eax
cmp    %ecx,%eax
jne    11c6 <main+0xa6>
cmpl   $0x1,-0x10(%rbp)
jne    11c6 <main+0xa6>
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    11c6 <main+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <main+0x2b>
mov    -0x8(%rbp),%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%ebx
mov    %ebp,%r15d
add    $0x1,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x65,%al
je     1140 <main+0x20>
cmp    $0xa,%al
je     117b <main+0x5b>
cmp    $0x69,%al
jne    1176 <main+0x56>
cmp    $0x1,%ebx
jne    1176 <main+0x56>
lea    0x1(%r15),%eax
xor    %ebx,%ebx
xor    %ecx,%ecx
cmp    %ebp,%eax
setne  %bl
sete   %cl
add    %ecx,%r14d
add    $0x1,%ebp
jmp    114b <main+0x2b>
lea    0xe7e(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
br label %1
1: ; preds = %18, %0
%2 = phi i32 [ 0, %0 ], [ %20, %18 ]
%3 = phi i32 [ 0, %0 ], [ %21, %18 ]
%4 = phi i32 [ 0, %0 ], [ %22, %18 ]
%5 = phi i32 [ 0, %0 ], [ %19, %18 ]
%6 = tail call signext i8 (...) @getchar()
switch i8 %6, label %7 [
i8 10, label %23
i8 101, label %18
]
7: ; preds = %1
%8 = icmp eq i8 %6, 105
%9 = icmp eq i32 %3, 1
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = sub nsw i32 %4, %5
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nsw i32 %2, %14
%16 = xor i1 %13, true
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %1, %11, %7
%19 = phi i32 [ %5, %7 ], [ %5, %11 ], [ %4, %1 ]
%20 = phi i32 [ %2, %7 ], [ %15, %11 ], [ %2, %1 ]
%21 = phi i32 [ %3, %7 ], [ %17, %11 ], [ 1, %1 ]
%22 = add nuw nsw i32 %4, 1
br label %1
23: ; preds = %1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 0
}