#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 */
typedef scalar_t__ ssize_t;

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int /*<<< orphan*/, char *, int);
void pass_fail(void) {
  ssize_t got;
  char ch;
  got = read(0, &ch, 1);
  if (got < 0) {
    if (errno == EAGAIN)
      return;
    perror("read");
    exit(1);
  }
  switch (ch) {
  case 'P':
  case 'p':
    exit(0);
  case 'F':
  case 'f':
  case 'Q':
  case 'q':
  case 3:
    exit(1);
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<pass_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <read@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    118c <pass_fail+0x5c>
mov    0x2e82(%rip),%rax
mov    (%rax),%rax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
jne    1176 <pass_fail+0x46>
jmp    121d <pass_fail+0xed>
lea    0xe83(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movsbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x3,%eax
je     120e <pass_fail+0xde>
jmp    11a1 <pass_fail+0x71>
mov    -0x10(%rbp),%eax
sub    $0x46,%eax
je     120e <pass_fail+0xde>
jmp    11b2 <pass_fail+0x82>
mov    -0x10(%rbp),%eax
sub    $0x50,%eax
je     1207 <pass_fail+0xd7>
jmp    11c3 <pass_fail+0x93>
mov    -0x10(%rbp),%eax
sub    $0x51,%eax
je     120e <pass_fail+0xde>
jmp    11d4 <pass_fail+0xa4>
mov    -0x10(%rbp),%eax
sub    $0x66,%eax
je     120e <pass_fail+0xde>
jmp    11e5 <pass_fail+0xb5>
mov    -0x10(%rbp),%eax
sub    $0x70,%eax
je     1207 <pass_fail+0xd7>
jmp    11f6 <pass_fail+0xc6>
mov    -0x10(%rbp),%eax
sub    $0x71,%eax
je     120e <pass_fail+0xde>
jmp    1218 <pass_fail+0xe8>
xor    %edi,%edi
call   1050 <exit@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    121d <pass_fail+0xed>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pass_fail>:
push   %rax
lea    0x7(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1030 <read@plt>
test   %rax,%rax
js     1183 <pass_fail+0x53>
movsbl 0x7(%rsp),%eax
lea    -0x46(%rax),%ecx
cmp    $0x2b,%ecx
ja     1174 <pass_fail+0x44>
movabs $0x80100000801,%rdx
bt     %rcx,%rdx
jb     1179 <pass_fail+0x49>
movabs $0x40000000400,%rdx
bt     %rcx,%rdx
jb     119b <pass_fail+0x6b>
cmp    $0x3,%eax
jne    1199 <pass_fail+0x69>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%rax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
jne    11a2 <pass_fail+0x72>
pop    %rax
ret
xor    %edi,%edi
call   1050 <exit@plt>
lea    0xe57(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"read\00"
define void @pass_fail() {
%1 = alloca i64
%2 = alloca i8
%3 = call i64 @read(i32 0, i8* %2, i32 1)
store i64 %3, i64* %1
%4 = load i64, i64* %1
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @EAGAIN
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %6
br label %22
11: ; preds = %6
%12 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %21 [
i32 80, label %17
i32 112, label %17
i32 70, label %19
i32 102, label %19
i32 81, label %19
i32 113, label %19
i32 3, label %19
]
17: ; preds = %14, %14
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %14, %14, %14, %14, %14
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %14
br label %22
22: ; preds = %10, %21
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"read\00"
define void @pass_fail() {
%1 = alloca i8
%2 = call i64 @read(i32 0, i8* %1, i32 1)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EAGAIN
%7 = icmp eq i64 %5, %6
br i1 %7, label %18, label %8
8: ; preds = %4
%9 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
switch i32 %13, label %18 [
i32 80, label %14
i32 112, label %14
i32 70, label %16
i32 102, label %16
i32 81, label %16
i32 113, label %16
i32 3, label %16
]
14: ; preds = %11, %11
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %11, %11, %11, %11, %11
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %11, %4
ret void
}