#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 */
struct _IO_FILE {
  int dummy;
};

/* Variables and functions */
int _IO_getc(struct _IO_FILE *);
int /*<<< orphan*/ ppm_error(char *);
char ppm_readchar(struct _IO_FILE *file) {
  char ch;
  signed int tmp;
  signed int tmp___0;
  tmp = _IO_getc(file);
  ch = (char)tmp;
  if ((signed int)ch == -1)
    ppm_error((char *)"read error");
  if ((signed int)ch == 35)
    while ((_Bool)1) {
      tmp___0 = _IO_getc(file);
      ch = (char)tmp___0;
      if ((signed int)ch == -1)
        ppm_error((char *)"read error");
      if ((signed int)ch == 10)
        goto __CPROVER_DUMP_L4;
    }
__CPROVER_DUMP_L4:;
  return ch;
}


x86 assembly (clang, -O0):
<ppm_readchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <_IO_getc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xffffffff,%eax
jne    1157 <ppm_readchar+0x37>
lea    0xeae(%rip),%rdi
call   1030 <ppm_error@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
jne    11ab <ppm_readchar+0x8b>
jmp    1169 <ppm_readchar+0x49>
mov    -0x8(%rbp),%rdi
call   1040 <_IO_getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xffffffff,%eax
jne    1194 <ppm_readchar+0x74>
lea    0xe71(%rip),%rdi
call   1030 <ppm_error@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    11a6 <ppm_readchar+0x86>
jmp    11b0 <ppm_readchar+0x90>
jmp    1169 <ppm_readchar+0x49>
jmp    11b0 <ppm_readchar+0x90>
movsbl -0x9(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ppm_readchar>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <_IO_getc@plt>
mov    %eax,%ebp
shl    $0x18,%eax
cmp    $0xff000000,%eax
je     1175 <ppm_readchar+0x55>
cmp    $0x23000000,%eax
jne    1181 <ppm_readchar+0x61>
lea    0xeba(%rip),%r14
jmp    1158 <ppm_readchar+0x38>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <ppm_error@plt>
mov    %rbx,%rdi
call   1040 <_IO_getc@plt>
mov    %eax,%ebp
shl    $0x18,%eax
cmp    $0xff000000,%eax
je     1150 <ppm_readchar+0x30>
cmp    $0xa000000,%eax
jne    1158 <ppm_readchar+0x38>
jmp    1181 <ppm_readchar+0x61>
lea    0xe84(%rip),%rdi
call   1030 <ppm_error@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct._IO_FILE = type { i32 }
@.str = [11 x i8] c"read error\00"
define signext i8 @ppm_readchar(%struct._IO_FILE* %0) {
%2 = alloca %struct._IO_FILE*
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store %struct._IO_FILE* %0, %struct._IO_FILE** %2
%6 = load %struct._IO_FILE*, %struct._IO_FILE** %2
%7 = call i32 @_IO_getc(%struct._IO_FILE* %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, -1
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @ppm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %36
19: ; preds = %15
br label %20
20: ; preds = %19, %35
%21 = load %struct._IO_FILE*, %struct._IO_FILE** %2
%22 = call i32 @_IO_getc(%struct._IO_FILE* %21)
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = trunc i32 %23 to i8
store i8 %24, i8* %3
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 @ppm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %20
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %35
34: ; preds = %30
br label %37
35: ; preds = %30
br label %20
36: ; preds = %15
br label %37
37: ; preds = %36, %34
%38 = load i8, i8* %3
ret i8 %38
}

LLVM IR (-O2):
%struct._IO_FILE = type { i32 }
@.str = [11 x i8] c"read error\00"
define signext i8 @ppm_readchar(%struct._IO_FILE* nocapture %0) {
%2 = tail call i32 @_IO_getc(%struct._IO_FILE* %0)
%3 = shl i32 %2, 24
switch i32 %3, label %12 [
i32 -16777216, label %4
i32 587202560, label %6
]
4: ; preds = %1
%5 = tail call i32 @ppm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %1, %9
%7 = tail call i32 @_IO_getc(%struct._IO_FILE* %0)
%8 = shl i32 %7, 24
switch i32 %8, label %9 [
i32 -16777216, label %10
i32 167772160, label %12
]
9: ; preds = %6, %10
br label %6
10: ; preds = %6
%11 = tail call i32 @ppm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %9
12: ; preds = %6, %4, %1
%13 = phi i32 [ %2, %4 ], [ %2, %1 ], [ %7, %6 ]
%14 = trunc i32 %13 to i8
ret i8 %14
}