#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char pbm_getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int pbm_getint(FILE *file) {
  register char ch;
  register int i;
  do {
    ch = pbm_getc(file);
  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
  if (ch < '0' || ch > '9')
    fprintf(stderr, "junk in file where an integer should be\n");
  i = 0;
  do {
    i = i * 10 + ch - '0';
    ch = pbm_getc(file);
  } while (ch >= '0' && ch <= '9');
  return i;
}


x86 assembly (clang, -O0):
<pbm_getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pbm_getc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
je     117b <pbm_getint+0x5b>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x11(%rbp)
je     117b <pbm_getint+0x5b>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     117b <pbm_getint+0x5b>
movsbl -0x9(%rbp),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    112c <pbm_getint+0xc>
movsbl -0x9(%rbp),%eax
cmp    $0x30,%eax
jl     11a0 <pbm_getint+0x80>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
jle    11b5 <pbm_getint+0x95>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
imul   $0xa,-0x10(%rbp),%eax
movsbl -0x9(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pbm_getc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x12(%rbp)
jl     11f7 <pbm_getint+0xd7>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11bc <pbm_getint+0x9c>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbm_getint>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
movabs $0x100002600,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <pbm_getc@plt>
mov    %eax,%ebx
cmp    $0x20,%al
ja     1157 <pbm_getint+0x37>
movzbl %bl,%eax
bt     %rax,%r15
jb     1140 <pbm_getint+0x20>
lea    -0x3a(%rbx),%eax
cmp    $0xf5,%al
ja     1173 <pbm_getint+0x53>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
lea    (%r15,%r15,4),%eax
movsbl %bl,%ecx
lea    (%rcx,%rax,2),%r15d
add    $0xffffffd0,%r15d
mov    %r14,%rdi
call   1030 <pbm_getc@plt>
mov    %eax,%ebx
add    $0xd0,%al
cmp    $0xa,%al
jb     1180 <pbm_getint+0x60>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"junk in file where an integer should be\0A\00"
define i32 @pbm_getint(i32* %0) {
br label %2
2: ; preds = %4, %1
%3 = tail call signext i8 @pbm_getc(i32* %0)
switch i8 %3, label %5 [
i8 32, label %4
i8 13, label %4
i8 10, label %4
i8 9, label %4
]
4: ; preds = %2, %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 %11
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %5, %8
br label %12
12: ; preds = %11, %12
%13 = phi i8 [ %19, %12 ], [ %3, %11 ]
%14 = phi i32 [ %18, %12 ], [ 0, %11 ]
%15 = mul nsw i32 %14, 10
%16 = sext i8 %13 to i32
%17 = add nsw i32 %16, -48
%18 = add i32 %17, %15
%19 = tail call signext i8 @pbm_getc(i32* %0)
%20 = add i8 %19, -48
%21 = icmp ult i8 %20, 10
br i1 %21, label %12, label %22
22: ; preds = %12
ret i32 %18
}