char pbm_getc(struct _IO_FILE$link2 *file) {
  char ch;
  signed int return_value_fgetc$1;
  return_value_fgetc$1 = fgetc(file);
  ch = (char)return_value_fgetc$1;
  if ((signed int)ch == 35)
    do {
      signed int return_value_fgetc$2;
      return_value_fgetc$2 = fgetc(file);
      ch = (char)return_value_fgetc$2;
    } while ((signed int)ch != 10 && (signed int)ch != 13);
  return ch;
}


x86 assembly (clang, -O0):
<pbm_getc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <fgetc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
jne    1185 <pbm_getc+0x75>
jmp    1142 <pbm_getc+0x32>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x15(%rbp)
je     1175 <pbm_getc+0x65>
movsbl -0x9(%rbp),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1142 <pbm_getc+0x32>
jmp    1185 <pbm_getc+0x75>
movsbl -0x9(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbm_getc>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <fgetc@plt>
cmp    $0x23,%al
jne    113f <pbm_getc+0x2f>
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <fgetc@plt>
mov    %eax,%ecx
shl    $0x18,%ecx
cmp    $0xd000000,%ecx
je     113f <pbm_getc+0x2f>
cmp    $0xa000000,%ecx
jne    1120 <pbm_getc+0x10>
pop    %rbx
ret

LLVM IR (-O0):
%"struct._IO_FILE$link2" = type opaque
define signext i8 @pbm_getc(%"struct._IO_FILE$link2"* %0) {
%2 = alloca %"struct._IO_FILE$link2"*
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store %"struct._IO_FILE$link2"* %0, %"struct._IO_FILE$link2"** %2
%6 = load %"struct._IO_FILE$link2"*, %"struct._IO_FILE$link2"** %2
%7 = call i32 (%"struct._IO_FILE$link2"*, ...) bitcast (i32 (...)* @fgetc to i32 (%"struct._IO_FILE$link2"*, ...)*)(%"struct._IO_FILE$link2"* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = trunc i32 %8 to i8
store i8 %9, i8* %3
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 35
br i1 %12, label %13, label %30
13: ; preds = %1
br label %14
14: ; preds = %27, %13
%15 = load %"struct._IO_FILE$link2"*, %"struct._IO_FILE$link2"** %2
%16 = call i32 (%"struct._IO_FILE$link2"*, ...) bitcast (i32 (...)* @fgetc to i32 (%"struct._IO_FILE$link2"*, ...)*)(%"struct._IO_FILE$link2"* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = trunc i32 %17 to i8
store i8 %18, i8* %3
br label %19
19: ; preds = %14
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 13
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ false, %19 ], [ %26, %23 ]
br i1 %28, label %14, label %29
29: ; preds = %27
br label %30
30: ; preds = %29, %1
%31 = load i8, i8* %3
ret i8 %31
}

LLVM IR (-O2):
%"struct._IO_FILE$link2" = type opaque
define signext i8 @pbm_getc(%"struct._IO_FILE$link2"* %0) {
%2 = tail call i32 (%"struct._IO_FILE$link2"*, ...) bitcast (i32 (...)* @fgetc to i32 (%"struct._IO_FILE$link2"*, ...)*)(%"struct._IO_FILE$link2"* %0)
%3 = and i32 %2, 255
%4 = icmp eq i32 %3, 35
br i1 %4, label %5, label %8
5: ; preds = %1, %5
%6 = tail call i32 (%"struct._IO_FILE$link2"*, ...) bitcast (i32 (...)* @fgetc to i32 (%"struct._IO_FILE$link2"*, ...)*)(%"struct._IO_FILE$link2"* %0)
%7 = shl i32 %6, 24
switch i32 %7, label %5 [
i32 218103808, label %8
i32 167772160, label %8
]
8: ; preds = %5, %5, %1
%9 = phi i32 [ %2, %1 ], [ %6, %5 ], [ %6, %5 ]
%10 = trunc i32 %9 to i8
ret i8 %10
}