#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 /*<<< orphan*/ ppm_error(char *);
char ppm_readchar(struct _IO_FILE *);
signed int ppm_readint(struct _IO_FILE *file) {
  char ch;
  signed int i;
  while ((_Bool)1) {
    ch = ppm_readchar(file);
    if (!((signed int)ch == 32)) {
      if (!((signed int)ch == 9)) {
        if (!((signed int)ch == 10))
          goto __CPROVER_DUMP_L3;
      }
    }
  }
__CPROVER_DUMP_L3:;
  if ((signed int)ch < 48)
    ppm_error((char *)"error in readint");
  else if ((signed int)ch > 57)
    ppm_error((char *)"error in readint");
  i = 0;
  while ((_Bool)1) {
    i = i * 10 + ((signed int)ch - 48);
    ch = ppm_readchar(file);
    if ((signed int)ch >= 48) {
      if (!((signed int)ch <= 57))
        goto __CPROVER_DUMP_L9;
    } else
      goto __CPROVER_DUMP_L9;
  }
__CPROVER_DUMP_L9:;
  return i;
}


x86 assembly (clang, -O0):
<ppm_readint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ppm_readchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
je     116e <ppm_readint+0x4e>
movsbl -0x9(%rbp),%eax
cmp    $0x9,%eax
je     1169 <ppm_readint+0x49>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     1164 <ppm_readint+0x44>
jmp    1173 <ppm_readint+0x53>
jmp    1169 <ppm_readint+0x49>
jmp    116e <ppm_readint+0x4e>
jmp    112c <ppm_readint+0xc>
movsbl -0x9(%rbp),%eax
cmp    $0x30,%eax
jge    1191 <ppm_readint+0x71>
lea    0xe79(%rip),%rdi
call   1040 <ppm_error@plt>
jmp    11af <ppm_readint+0x8f>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
jle    11aa <ppm_readint+0x8a>
lea    0xe5b(%rip),%rdi
call   1040 <ppm_error@plt>
jmp    11af <ppm_readint+0x8f>
movl   $0x0,-0x10(%rbp)
imul   $0xa,-0x10(%rbp),%eax
movsbl -0x9(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ppm_readchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x30,%eax
jl     11f6 <ppm_readint+0xd6>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
jle    11f1 <ppm_readint+0xd1>
jmp    1200 <ppm_readint+0xe0>
jmp    11fb <ppm_readint+0xdb>
jmp    1200 <ppm_readint+0xe0>
jmp    11b6 <ppm_readint+0x96>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ppm_readint>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
movabs $0x100000600,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <ppm_readchar@plt>
mov    %eax,%ebx
cmp    $0x20,%al
ja     1157 <ppm_readint+0x37>
movzbl %bl,%eax
bt     %rax,%r15
jb     1140 <ppm_readint+0x20>
lea    -0x3a(%rbx),%eax
cmp    $0xf5,%al
ja     116a <ppm_readint+0x4a>
lea    0xe9b(%rip),%rdi
call   1040 <ppm_error@plt>
xor    %r15d,%r15d
nopl   (%rax)
lea    (%r15,%r15,4),%eax
movsbl %bl,%ecx
lea    (%rcx,%rax,2),%r15d
add    $0xffffffd0,%r15d
mov    %r14,%rdi
call   1030 <ppm_readchar@plt>
mov    %eax,%ebx
add    $0xd0,%al
cmp    $0xa,%al
jb     1170 <ppm_readint+0x50>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct._IO_FILE = type { i32 }
@.str = [17 x i8] c"error in readint\00"
define i32 @ppm_readint(%struct._IO_FILE* %0) {
%2 = alloca %struct._IO_FILE*
%3 = alloca i8
%4 = alloca i32
store %struct._IO_FILE* %0, %struct._IO_FILE** %2
br label %5
5: ; preds = %1, %22
%6 = load %struct._IO_FILE*, %struct._IO_FILE** %2
%7 = call signext i8 @ppm_readchar(%struct._IO_FILE* %6)
store i8 %7, i8* %3
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 32
br i1 %10, label %22, label %11
11: ; preds = %5
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 9
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %20, label %19
19: ; preds = %15
br label %23
20: ; preds = %15
br label %21
21: ; preds = %20, %11
br label %22
22: ; preds = %21, %5
br label %5
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp slt i32 %25, 48
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @ppm_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %36
29: ; preds = %23
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp sgt i32 %31, 57
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @ppm_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
br label %36
36: ; preds = %35, %27
store i32 0, i32* %4
br label %37
37: ; preds = %36, %56
%38 = load i32, i32* %4
%39 = mul nsw i32 %38, 10
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = sub nsw i32 %41, 48
%43 = add nsw i32 %39, %42
store i32 %43, i32* %4
%44 = load %struct._IO_FILE*, %struct._IO_FILE** %2
%45 = call signext i8 @ppm_readchar(%struct._IO_FILE* %44)
store i8 %45, i8* %3
%46 = load i8, i8* %3
%47 = sext i8 %46 to i32
%48 = icmp sge i32 %47, 48
br i1 %48, label %49, label %55
49: ; preds = %37
%50 = load i8, i8* %3
%51 = sext i8 %50 to i32
%52 = icmp sle i32 %51, 57
br i1 %52, label %54, label %53
53: ; preds = %49
br label %57
54: ; preds = %49
br label %56
55: ; preds = %37
br label %57
56: ; preds = %54
br label %37
57: ; preds = %55, %53
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
%struct._IO_FILE = type { i32 }
@.str = [17 x i8] c"error in readint\00"
define i32 @ppm_readint(%struct._IO_FILE* %0) {
br label %2
2: ; preds = %4, %1
%3 = tail call signext i8 @ppm_readchar(%struct._IO_FILE* %0)
switch i8 %3, label %5 [
i8 32, label %4
i8 10, label %4
i8 9, label %4
]
4: ; preds = %2, %2, %2
br label %2
5: ; preds = %2
%6 = add i8 %3, -58
%7 = icmp ult i8 %6, -10
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @ppm_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %5, %8
br label %11
11: ; preds = %10, %11
%12 = phi i8 [ %18, %11 ], [ %3, %10 ]
%13 = phi i32 [ %17, %11 ], [ 0, %10 ]
%14 = mul nsw i32 %13, 10
%15 = sext i8 %12 to i32
%16 = add nsw i32 %15, -48
%17 = add nsw i32 %16, %14
%18 = tail call signext i8 @ppm_readchar(%struct._IO_FILE* %0)
%19 = add i8 %18, -48
%20 = icmp ult i8 %19, 10
br i1 %20, label %11, label %21
21: ; preds = %11
ret i32 %17
}