#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 */
scalar_t__ EOF;
scalar_t__ check_letter(char, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, char *);
int read_line() {
  char next;
  int index = 0, found = 0;
  while (1) {
    if (scanf("%c", &next) == EOF)
      return 0;
    if (next == '\n') {
      printf(found ? "yes\n" : "no\n");
      return 1;
    }
    if (!found) {
      if (check_letter(next, index++))
        found = (index == 7);
      else
        index = (next == 'p' || next == 'P');
    }
  }
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <read_line+0x42>
movl   $0x0,-0x4(%rbp)
jmp    121a <read_line+0xea>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11a8 <read_line+0x78>
mov    -0x10(%rbp),%ecx
lea    0xe7f(%rip),%rdi
lea    0xe73(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121a <read_line+0xea>
cmpl   $0x0,-0x10(%rbp)
jne    1215 <read_line+0xe5>
mov    -0x5(%rbp),%al
mov    -0xc(%rbp),%esi
mov    %esi,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movsbl %al,%edi
call   1050 <check_letter@plt>
cmp    $0x0,%rax
je     11e6 <read_line+0xb6>
cmpl   $0x7,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
jmp    1210 <read_line+0xe0>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x70,%ecx
mov    %al,-0x11(%rbp)
je     1205 <read_line+0xd5>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
jmp    1215 <read_line+0xe5>
jmp    1146 <read_line+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
mov    0x2e91(%rip),%r12
xor    %eax,%eax
cmp    (%r12),%rcx
je     11f3 <read_line+0xc3>
xor    %ecx,%ecx
lea    0xe94(%rip),%r14
lea    0xf(%rsp),%r15
xor    %ebp,%ebp
jmp    11a3 <read_line+0x73>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
xor    %ebp,%ebp
cmp    $0x50,%al
sete   %bpl
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    %ebx,%ecx
cmp    (%r12),%rax
je     11d1 <read_line+0xa1>
movzbl 0xf(%rsp),%eax
cmp    $0xa,%al
je     11d5 <read_line+0xa5>
mov    $0x1,%ebx
test   %ecx,%ecx
jne    1190 <read_line+0x60>
movsbl %al,%edi
mov    %ebp,%esi
call   1050 <check_letter@plt>
test   %rax,%rax
je     1175 <read_line+0x45>
add    $0x1,%ebp
xor    %ebx,%ebx
cmp    $0x7,%ebp
sete   %bl
jmp    1190 <read_line+0x60>
xor    %eax,%eax
jmp    11f3 <read_line+0xc3>
test   %ecx,%ecx
lea    0xe2a(%rip),%rax
lea    0xe1e(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"yes\0A\00"
@.str.2 = [4 x i8] c"no\0A\00"
define i32 @read_line() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %0, %45
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %5
store i32 0, i32* %1
br label %46
10: ; preds = %5
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%19 = call i32 @printf(i8* %18)
store i32 1, i32* %1
br label %46
20: ; preds = %10
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %45, label %23
23: ; preds = %20
%24 = load i8, i8* %2
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = call i64 @check_letter(i8 signext %24, i32 %25)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 7
%32 = zext i1 %31 to i32
store i32 %32, i32* %4
br label %44
33: ; preds = %23
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 112
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 80
br label %41
41: ; preds = %37, %33
%42 = phi i1 [ true, %33 ], [ %40, %37 ]
%43 = zext i1 %42 to i32
store i32 %43, i32* %3
br label %44
44: ; preds = %41, %29
br label %45
45: ; preds = %44, %20
br label %5
46: ; preds = %14, %9
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"yes\0A\00"
@.str.2 = [4 x i8] c"no\0A\00"
define i32 @read_line() {
%1 = alloca i8
%2 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = load i64, i64* @EOF
%4 = icmp eq i64 %2, %3
br i1 %4, label %33, label %5
5: ; preds = %0, %27
%6 = phi i32 [ %29, %27 ], [ 0, %0 ]
%7 = phi i32 [ %28, %27 ], [ 0, %0 ]
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 10
%10 = icmp eq i32 %6, 0
br i1 %9, label %11, label %14
11: ; preds = %5
%12 = select i1 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%13 = call i32 @printf(i8* dereferenceable(1) %12)
br label %33
14: ; preds = %5
br i1 %10, label %15, label %27
15: ; preds = %14
%16 = add nsw i32 %7, 1
%17 = call i64 @check_letter(i8 signext %8, i32 %7)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = icmp eq i32 %16, 7
%21 = zext i1 %20 to i32
br label %27
22: ; preds = %15
%23 = load i8, i8* %1
%24 = and i8 %23, -33
%25 = icmp eq i8 %24, 80
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %19, %22, %14
%28 = phi i32 [ %7, %14 ], [ %16, %19 ], [ %26, %22 ]
%29 = phi i32 [ 1, %14 ], [ %21, %19 ], [ 0, %22 ]
%30 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %5
33: ; preds = %27, %0, %11
%34 = phi i32 [ 1, %11 ], [ 0, %0 ], [ 0, %27 ]
ret i32 %34
}