#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(void) {
  char prev = 0, now;
  int n = 0;
  while ((now = getchar()) != '#') {
    if (now == 'i' && prev == 'e')
      n++;
    prev = now;
  }
  printf("%d\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x6(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     117e <main+0x5e>
movsbl -0x6(%rbp),%eax
cmp    $0x69,%eax
jne    1173 <main+0x53>
movsbl -0x5(%rbp),%eax
cmp    $0x65,%eax
jne    1173 <main+0x53>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0x5(%rbp)
jmp    113a <main+0x1a>
mov    -0xc(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x23,%al
je     115d <main+0x3d>
xor    %ebx,%ebx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ebp
xor    $0x69,%al
xor    $0x65,%cl
xor    %edx,%edx
or     %al,%cl
sete   %dl
add    %edx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    $0x23,%al
jne    1140 <main+0x20>
lea    0xe9c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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