#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char pbm_getc(FILE *file) {
  register int ich;
  register char ch;
  ich = getc(file);
  if (ich == EOF)
    fprintf(stderr, "EOF / read error\n");
  ch = (char)ich;
  if (ch == '#') {
    do {
      ich = getc(file);
      if (ich == EOF)
        fprintf(stderr, "EOF / read error\n");
      ch = (char)ich;
    } while (ch != '\n' && ch != '\r');
  }
  return ch;
}


x86 assembly (clang, -O0):
<pbm_getc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ea6(%rip),%rcx
cmp    (%rcx),%eax
jne    115f <pbm_getc+0x3f>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x23,%eax
jne    11df <pbm_getc+0xbf>
jmp    1177 <pbm_getc+0x57>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
jne    11aa <pbm_getc+0x8a>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xe(%rbp)
je     11cf <pbm_getc+0xaf>
movsbl -0xd(%rbp),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    1177 <pbm_getc+0x57>
jmp    11df <pbm_getc+0xbf>
movsbl -0xd(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbm_getc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1040 <getc@plt>
mov    %eax,%ebp
mov    0x2eaf(%rip),%r15
cmp    (%r15),%eax
jne    1153 <pbm_getc+0x33>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeb2(%rip),%rsi
call   1030 <fprintf@plt>
cmp    $0x23,%bpl
jne    119e <pbm_getc+0x7e>
mov    0x2e78(%rip),%r12
lea    0xe99(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    118b <pbm_getc+0x6b>
mov    (%r12),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
mov    %ebp,%eax
shl    $0x18,%eax
cmp    $0xd000000,%eax
je     119e <pbm_getc+0x7e>
cmp    $0xa000000,%eax
jne    1170 <pbm_getc+0x50>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"EOF / read error\0A\00"
define signext i8 @pbm_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 %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %1
%14 = load i32, i32* %3
%15 = trunc i32 %14 to i8
store i8 %15, i8* %4
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %43
19: ; preds = %13
br label %20
20: ; preds = %40, %19
%21 = load i32*, i32** %2
%22 = call i32 @getc(i32* %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %26, %20
%30 = load i32, i32* %3
%31 = trunc i32 %30 to i8
store i8 %31, i8* %4
br label %32
32: ; preds = %29
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 13
br label %40
40: ; preds = %36, %32
%41 = phi i1 [ false, %32 ], [ %39, %36 ]
br i1 %41, label %20, label %42
42: ; preds = %40
br label %43
43: ; preds = %42, %13
%44 = load i8, i8* %4
ret i8 %44
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"EOF / read error\0A\00"
define signext i8 @pbm_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 %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %1
%9 = and i32 %2, 255
%10 = icmp eq i32 %9, 35
br i1 %10, label %11, label %20
11: ; preds = %8, %18
%12 = tail call i32 @getc(i32* %0)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %11
%19 = shl i32 %12, 24
switch i32 %19, label %11 [
i32 218103808, label %20
i32 167772160, label %20
]
20: ; preds = %18, %18, %8
%21 = phi i32 [ %2, %8 ], [ %12, %18 ], [ %12, %18 ]
%22 = trunc i32 %21 to i8
ret i8 %22
}