#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/ *const);
int /*<<< orphan*/ pm_error(char *);
char pm_getc(FILE *const fileP) {
  int ich;
  char ch;
  ich = getc(fileP);
  if (ich == EOF)
    pm_error("EOF / read error reading a byte");
  ch = (char)ich;
  if (ch == '#') {
    do {
      ich = getc(fileP);
      if (ich == EOF)
        pm_error("EOF / read error reading a byte");
      ch = (char)ich;
    } while (ch != '\n' && ch != '\r');
  }
  return ch;
}


x86 assembly (clang, -O0):
<pm_getc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ea6(%rip),%rcx
cmp    (%rcx),%eax
jne    1156 <pm_getc+0x36>
lea    0xeaf(%rip),%rdi
call   1040 <pm_error@plt>
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x23,%eax
jne    11cd <pm_getc+0xad>
jmp    116e <pm_getc+0x4e>
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%eax
jne    1198 <pm_getc+0x78>
lea    0xe6d(%rip),%rdi
call   1040 <pm_error@plt>
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xe(%rbp)
je     11bd <pm_getc+0x9d>
movsbl -0xd(%rbp),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    116e <pm_getc+0x4e>
jmp    11cd <pm_getc+0xad>
movsbl -0xd(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_getc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getc@plt>
mov    %eax,%ebp
mov    0x2eb0(%rip),%r15
cmp    (%r15),%eax
jne    1149 <pm_getc+0x29>
lea    0xebc(%rip),%rdi
call   1040 <pm_error@plt>
cmp    $0x23,%bpl
jne    118a <pm_getc+0x6a>
lea    0xeaa(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    1177 <pm_getc+0x57>
mov    %r14,%rdi
call   1040 <pm_error@plt>
mov    %ebp,%eax
shl    $0x18,%eax
cmp    $0xd000000,%eax
je     118a <pm_getc+0x6a>
cmp    $0xa000000,%eax
jne    1160 <pm_getc+0x40>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [32 x i8] c"EOF / read error reading a byte\00"
define signext i8 @pm_getc(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @pm_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = load i32, i32* %3
%14 = trunc i32 %13 to i8
store i8 %14, i8* %4
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 35
br i1 %17, label %18, label %41
18: ; preds = %12
br label %19
19: ; preds = %38, %18
%20 = load i32*, i32** %2
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @pm_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
%28 = load i32, i32* %3
%29 = trunc i32 %28 to i8
store i8 %29, i8* %4
br label %30
30: ; preds = %27
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i8, i8* %4
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 13
br label %38
38: ; preds = %34, %30
%39 = phi i1 [ false, %30 ], [ %37, %34 ]
br i1 %39, label %19, label %40
40: ; preds = %38
br label %41
41: ; preds = %40, %12
%42 = load i8, i8* %4
ret i8 %42
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [32 x i8] c"EOF / read error reading a byte\00"
define signext i8 @pm_getc(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @pm_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = and i32 %2, 255
%9 = icmp eq i32 %8, 35
br i1 %9, label %10, label %18
10: ; preds = %7, %16
%11 = tail call i32 @getc(i32* %0)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @pm_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = shl i32 %11, 24
switch i32 %17, label %10 [
i32 218103808, label %18
i32 167772160, label %18
]
18: ; preds = %16, %16, %7
%19 = phi i32 [ %2, %7 ], [ %11, %16 ], [ %11, %16 ]
%20 = trunc i32 %19 to i8
ret i8 %20
}