#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 getc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
int sscanf(char *, char *, int *, ...);
scalar_t__ strncmp(char *, char *, int);
int ReadPNMImageFileHeader(FILE *fp, int *nRows, int *nCols,
                           int *maxIntensity) {
  char buffer[128];
  int i, numFields, c;
  int type = 0;
  c = getc(fp);
  i = 0;
  for (numFields = 0; numFields < 3; numFields++) {
    while (1) {
      while (isspace(c))
        c = getc(fp);
      if (c != '#')
        break;
      do {
        c = getc(fp);
      } while ((c != EOF) && (c != '\n'));
    }
    while ((c != EOF) && !isspace(c)) {
      if (i < (128 - 2))
        buffer[i++] = c;
      c = getc(fp);
    }
    if (i < (128 - 1))
      buffer[i++] = ' ';
  }
  buffer[i] = 0;
  if (strncmp(buffer, "P1 ", 3) == 0)
    type = 1;
  if (strncmp(buffer, "P4 ", 3) == 0)
    type = 2;
  if (strncmp(buffer, "P2 ", 3) == 0)
    type = 3;
  if (strncmp(buffer, "P5 ", 3) == 0)
    type = 4;
  if (strncmp(buffer, "P3 ", 3) == 0)
    type = 5;
  if (strncmp(buffer, "P6 ", 3) == 0)
    type = 6;
  if (type == 0)
    return 0;
  if (sscanf(buffer + 3, "%d %d", nCols, nRows) != 2)
    return 0;
  if (type != 1 && type != 2) {
    c = getc(fp);
    i = 0;
    while (1) {
      while (isspace(c))
        c = getc(fp);
      if (c != '#')
        break;
      do {
        c = getc(fp);
      } while ((c != EOF) && (c != '\n'));
    }
    while ((c != EOF) && !isspace(c)) {
      if (i < (128 - 2))
        buffer[i++] = c;
      c = getc(fp);
    }
    if (i < (128 - 1))
      buffer[i++] = ' ';
    buffer[i] = 0;
    if (sscanf(buffer, "%d", maxIntensity) != 1)
      return 0;
  } else
    *maxIntensity = 1;
  return type;
}


x86 assembly (clang, -O0):
<ReadPNMImageFileHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0xc0(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
cmpl   $0x3,-0xb8(%rbp)
jge    1301 <ReadPNMImageFileHeader+0x1c1>
jmp    119a <ReadPNMImageFileHeader+0x5a>
jmp    119f <ReadPNMImageFileHeader+0x5f>
mov    -0xbc(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11c8 <ReadPNMImageFileHeader+0x88>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
jmp    119f <ReadPNMImageFileHeader+0x5f>
cmpl   $0x23,-0xbc(%rbp)
je     11da <ReadPNMImageFileHeader+0x9a>
jmp    122e <ReadPNMImageFileHeader+0xee>
jmp    11df <ReadPNMImageFileHeader+0x9f>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
mov    -0xbc(%rbp),%ecx
xor    %eax,%eax
mov    0x2deb(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xc1(%rbp)
je     121b <ReadPNMImageFileHeader+0xdb>
cmpl   $0xa,-0xbc(%rbp)
setne  %al
mov    %al,-0xc1(%rbp)
mov    -0xc1(%rbp),%al
test   $0x1,%al
jne    11df <ReadPNMImageFileHeader+0x9f>
jmp    119a <ReadPNMImageFileHeader+0x5a>
jmp    1233 <ReadPNMImageFileHeader+0xf3>
mov    -0xbc(%rbp),%ecx
xor    %eax,%eax
mov    0x2da6(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xc2(%rbp)
je     126a <ReadPNMImageFileHeader+0x12a>
mov    -0xbc(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0xc2(%rbp)
mov    -0xc2(%rbp),%al
test   $0x1,%al
jne    127d <ReadPNMImageFileHeader+0x13d>
jmp    12c0 <ReadPNMImageFileHeader+0x180>
cmpl   $0x7e,-0xb4(%rbp)
jge    12ac <ReadPNMImageFileHeader+0x16c>
mov    -0xbc(%rbp),%eax
mov    %al,%cl
mov    -0xb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb4(%rbp)
cltq
mov    %cl,-0xb0(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
jmp    1233 <ReadPNMImageFileHeader+0xf3>
cmpl   $0x7f,-0xb4(%rbp)
jge    12e8 <ReadPNMImageFileHeader+0x1a8>
mov    -0xb4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xb4(%rbp)
cltq
movb   $0x20,-0xb0(%rbp,%rax,1)
20
jmp    12ed <ReadPNMImageFileHeader+0x1ad>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1188 <ReadPNMImageFileHeader+0x48>
movslq -0xb4(%rbp),%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    -0xb0(%rbp),%rdi
lea    0xce2(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    133c <ReadPNMImageFileHeader+0x1fc>
movl   $0x1,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xcba(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1368 <ReadPNMImageFileHeader+0x228>
movl   $0x2,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xc92(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1394 <ReadPNMImageFileHeader+0x254>
movl   $0x3,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xc6a(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13c0 <ReadPNMImageFileHeader+0x280>
movl   $0x4,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xc42(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13ec <ReadPNMImageFileHeader+0x2ac>
movl   $0x5,-0xc0(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xc1a(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1418 <ReadPNMImageFileHeader+0x2d8>
movl   $0x6,-0xc0(%rbp)
cmpl   $0x0,-0xc0(%rbp)
jne    1431 <ReadPNMImageFileHeader+0x2f1>
movl   $0x0,-0x4(%rbp)
jmp    163d <ReadPNMImageFileHeader+0x4fd>
lea    -0xb0(%rbp),%rdi
add    $0x3,%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xbcd(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1467 <ReadPNMImageFileHeader+0x327>
movl   $0x0,-0x4(%rbp)
jmp    163d <ReadPNMImageFileHeader+0x4fd>
cmpl   $0x1,-0xc0(%rbp)
je     162a <ReadPNMImageFileHeader+0x4ea>
cmpl   $0x2,-0xc0(%rbp)
je     162a <ReadPNMImageFileHeader+0x4ea>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
movl   $0x0,-0xb4(%rbp)
jmp    149f <ReadPNMImageFileHeader+0x35f>
mov    -0xbc(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     14c8 <ReadPNMImageFileHeader+0x388>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
jmp    149f <ReadPNMImageFileHeader+0x35f>
cmpl   $0x23,-0xbc(%rbp)
je     14da <ReadPNMImageFileHeader+0x39a>
jmp    152e <ReadPNMImageFileHeader+0x3ee>
jmp    14df <ReadPNMImageFileHeader+0x39f>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
mov    -0xbc(%rbp),%ecx
xor    %eax,%eax
mov    0x2aeb(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xc3(%rbp)
je     151b <ReadPNMImageFileHeader+0x3db>
cmpl   $0xa,-0xbc(%rbp)
setne  %al
mov    %al,-0xc3(%rbp)
mov    -0xc3(%rbp),%al
test   $0x1,%al
jne    14df <ReadPNMImageFileHeader+0x39f>
jmp    149a <ReadPNMImageFileHeader+0x35a>
jmp    1533 <ReadPNMImageFileHeader+0x3f3>
mov    -0xbc(%rbp),%ecx
xor    %eax,%eax
mov    0x2aa6(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xc4(%rbp)
je     156a <ReadPNMImageFileHeader+0x42a>
mov    -0xbc(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0xc4(%rbp)
mov    -0xc4(%rbp),%al
test   $0x1,%al
jne    157d <ReadPNMImageFileHeader+0x43d>
jmp    15c0 <ReadPNMImageFileHeader+0x480>
cmpl   $0x7e,-0xb4(%rbp)
jge    15ac <ReadPNMImageFileHeader+0x46c>
mov    -0xbc(%rbp),%eax
mov    %al,%cl
mov    -0xb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb4(%rbp)
cltq
mov    %cl,-0xb0(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xbc(%rbp)
jmp    1533 <ReadPNMImageFileHeader+0x3f3>
cmpl   $0x7f,-0xb4(%rbp)
jge    15e8 <ReadPNMImageFileHeader+0x4a8>
mov    -0xb4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xb4(%rbp)
cltq
movb   $0x20,-0xb0(%rbp,%rax,1)
20
movslq -0xb4(%rbp),%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
lea    -0xb0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xa12(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1625 <ReadPNMImageFileHeader+0x4e5>
movl   $0x0,-0x4(%rbp)
jmp    163d <ReadPNMImageFileHeader+0x4fd>
jmp    1634 <ReadPNMImageFileHeader+0x4f4>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0xc0(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadPNMImageFileHeader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbx
call   1060 <getc@plt>
mov    %eax,%ebp
xor    %r14d,%r14d
mov    0x2e74(%rip),%r13
xor    %r15d,%r15d
jmp    1190 <ReadPNMImageFileHeader+0x50>
add    $0x1,%r14d
cmp    $0x3,%r14d
je     1240 <ReadPNMImageFileHeader+0x100>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1040 <isspace@plt>
test   %rax,%rax
je     11c0 <ReadPNMImageFileHeader+0x80>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
jmp    11a0 <ReadPNMImageFileHeader+0x60>
nopl   0x0(%rax,%rax,1)
cmp    $0x23,%ebp
jne    11e9 <ReadPNMImageFileHeader+0xa9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    0x0(%r13),%eax
cmp    $0xa,%ebp
je     1190 <ReadPNMImageFileHeader+0x50>
cmp    %eax,%ebp
jne    11d0 <ReadPNMImageFileHeader+0x90>
jmp    1190 <ReadPNMImageFileHeader+0x50>
cmp    0x0(%r13),%ebp
jne    1220 <ReadPNMImageFileHeader+0xe0>
cmp    $0x7e,%r15d
jg     1179 <ReadPNMImageFileHeader+0x39>
movslq %r15d,%rax
add    $0x1,%r15d
movb   $0x20,0x20(%rsp,%rax,1)
jmp    1179 <ReadPNMImageFileHeader+0x39>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     11ef <ReadPNMImageFileHeader+0xaf>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    11ef <ReadPNMImageFileHeader+0xaf>
cmp    $0x7d,%r15d
jg     1210 <ReadPNMImageFileHeader+0xd0>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %bpl,0x20(%rsp,%rax,1)
jmp    1210 <ReadPNMImageFileHeader+0xd0>
movslq %r15d,%rax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xdb1(%rip),%rsi
lea    0x20(%rsp),%r15
mov    $0x3,%r14d
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
lea    0xd8d(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    $0x2,%r12d
cmovne %ebp,%r12d
lea    0xd70(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
cmove  %r14d,%r12d
lea    0xd59(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    $0x4,%ebp
cmovne %r12d,%ebp
lea    0xd3d(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    $0x5,%r12d
cmovne %ebp,%r12d
lea    0xd20(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    $0x6,%r14d
cmovne %r12d,%r14d
test   %r14d,%r14d
je     13b9 <ReadPNMImageFileHeader+0x279>
lea    0x23(%rsp),%rdi
lea    0xcf5(%rip),%rsi
xor    %ebp,%ebp
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    144c <ReadPNMImageFileHeader+0x30c>
lea    -0x3(%r14),%eax
cmp    $0xfffffffd,%eax
ja     13c0 <ReadPNMImageFileHeader+0x280>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1040 <isspace@plt>
test   %rax,%rax
je     1390 <ReadPNMImageFileHeader+0x250>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
jmp    1370 <ReadPNMImageFileHeader+0x230>
nopl   0x0(%rax,%rax,1)
cmp    $0x23,%ebp
jne    13cd <ReadPNMImageFileHeader+0x28d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    0x0(%r13),%eax
cmp    $0xa,%ebp
je     1360 <ReadPNMImageFileHeader+0x220>
cmp    %eax,%ebp
jne    13a0 <ReadPNMImageFileHeader+0x260>
jmp    1360 <ReadPNMImageFileHeader+0x220>
xor    %ebp,%ebp
jmp    144c <ReadPNMImageFileHeader+0x30c>
mov    0x8(%rsp),%rax
movl   $0x1,(%rax)
jmp    1449 <ReadPNMImageFileHeader+0x309>
xor    %r15d,%r15d
cmp    0x0(%r13),%ebp
je     1416 <ReadPNMImageFileHeader+0x2d6>
xor    %r15d,%r15d
jmp    13f0 <ReadPNMImageFileHeader+0x2b0>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     1410 <ReadPNMImageFileHeader+0x2d0>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1410 <ReadPNMImageFileHeader+0x2d0>
cmp    $0x7d,%r15d
jg     13e0 <ReadPNMImageFileHeader+0x2a0>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %bpl,0x20(%rsp,%rax,1)
jmp    13e0 <ReadPNMImageFileHeader+0x2a0>
cmp    $0x7e,%r15d
jg     1422 <ReadPNMImageFileHeader+0x2e2>
movslq %r15d,%rax
add    $0x1,%r15d
movb   $0x20,0x20(%rsp,%rax,1)
movslq %r15d,%rax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xbea(%rip),%rsi
xor    %ebp,%ebp
lea    0x20(%rsp),%rdi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    144c <ReadPNMImageFileHeader+0x30c>
mov    %r14d,%ebp
mov    %ebp,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"P1 \00"
@.str.1 = [4 x i8] c"P4 \00"
@.str.2 = [4 x i8] c"P2 \00"
@.str.3 = [4 x i8] c"P5 \00"
@.str.4 = [4 x i8] c"P3 \00"
@.str.5 = [4 x i8] c"P6 \00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @ReadPNMImageFileHeader(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [128 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 0, i32* %14
%15 = load i32*, i32** %6
%16 = call i32 @getc(i32* %15)
store i32 %16, i32* %13
store i32 0, i32* %11
store i32 0, i32* %12
br label %17
17: ; preds = %81, %4
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %84
20: ; preds = %17
br label %21
21: ; preds = %20, %46
br label %22
22: ; preds = %26, %21
%23 = load i32, i32* %13
%24 = call i64 @isspace(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32*, i32** %6
%28 = call i32 @getc(i32* %27)
store i32 %28, i32* %13
br label %22
29: ; preds = %22
%30 = load i32, i32* %13
%31 = icmp ne i32 %30, 35
br i1 %31, label %32, label %33
32: ; preds = %29
br label %47
33: ; preds = %29
br label %34
34: ; preds = %44, %33
%35 = load i32*, i32** %6
%36 = call i32 @getc(i32* %35)
store i32 %36, i32* %13
br label %37
37: ; preds = %34
%38 = load i32, i32* %13
%39 = load i32, i32* @EOF
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %13
%43 = icmp ne i32 %42, 10
br label %44
44: ; preds = %41, %37
%45 = phi i1 [ false, %37 ], [ %43, %41 ]
br i1 %45, label %34, label %46
46: ; preds = %44
br label %21
47: ; preds = %32
br label %48
48: ; preds = %69, %47
%49 = load i32, i32* %13
%50 = load i32, i32* @EOF
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load i32, i32* %13
%54 = call i64 @isspace(i32 %53)
%55 = icmp ne i64 %54, 0
%56 = xor i1 %55, true
br label %57
57: ; preds = %52, %48
%58 = phi i1 [ false, %48 ], [ %56, %52 ]
br i1 %58, label %59, label %72
59: ; preds = %57
%60 = load i32, i32* %11
%61 = icmp slt i32 %60, 126
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* %13
%64 = trunc i32 %63 to i8
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %67
store i8 %64, i8* %68
br label %69
69: ; preds = %62, %59
%70 = load i32*, i32** %6
%71 = call i32 @getc(i32* %70)
store i32 %71, i32* %13
br label %48
72: ; preds = %57
%73 = load i32, i32* %11
%74 = icmp slt i32 %73, 127
br i1 %74, label %75, label %80
75: ; preds = %72
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %78
store i8 32, i8* %79
br label %80
80: ; preds = %75, %72
br label %81
81: ; preds = %80
%82 = load i32, i32* %12
%83 = add nsw i32 %82, 1
store i32 %83, i32* %12
br label %17
84: ; preds = %17
%85 = load i32, i32* %11
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %86
store i8 0, i8* %87
%88 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%89 = call i64 @strncmp(i8* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %84
store i32 1, i32* %14
br label %92
92: ; preds = %91, %84
%93 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%94 = call i64 @strncmp(i8* %93, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %92
store i32 2, i32* %14
br label %97
97: ; preds = %96, %92
%98 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%99 = call i64 @strncmp(i8* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %102
101: ; preds = %97
store i32 3, i32* %14
br label %102
102: ; preds = %101, %97
%103 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%104 = call i64 @strncmp(i8* %103, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %102
store i32 4, i32* %14
br label %107
107: ; preds = %106, %102
%108 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%109 = call i64 @strncmp(i8* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %107
store i32 5, i32* %14
br label %112
112: ; preds = %111, %107
%113 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%114 = call i64 @strncmp(i8* %113, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %112
store i32 6, i32* %14
br label %117
117: ; preds = %116, %112
%118 = load i32, i32* %14
%119 = icmp eq i32 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %117
store i32 0, i32* %5
br label %211
121: ; preds = %117
%122 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%123 = getelementptr inbounds i8, i8* %122, i64 3
%124 = load i32*, i32** %8
%125 = load i32*, i32** %7
%126 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %123, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %124, i32* %125)
%127 = icmp ne i32 %126, 2
br i1 %127, label %128, label %129
128: ; preds = %121
store i32 0, i32* %5
br label %211
129: ; preds = %121
%130 = load i32, i32* %14
%131 = icmp ne i32 %130, 1
br i1 %131, label %132, label %207
132: ; preds = %129
%133 = load i32, i32* %14
%134 = icmp ne i32 %133, 2
br i1 %134, label %135, label %207
135: ; preds = %132
%136 = load i32*, i32** %6
%137 = call i32 @getc(i32* %136)
store i32 %137, i32* %13
store i32 0, i32* %11
br label %138
138: ; preds = %135, %163
br label %139
139: ; preds = %143, %138
%140 = load i32, i32* %13
%141 = call i64 @isspace(i32 %140)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %139
%144 = load i32*, i32** %6
%145 = call i32 @getc(i32* %144)
store i32 %145, i32* %13
br label %139
146: ; preds = %139
%147 = load i32, i32* %13
%148 = icmp ne i32 %147, 35
br i1 %148, label %149, label %150
149: ; preds = %146
br label %164
150: ; preds = %146
br label %151
151: ; preds = %161, %150
%152 = load i32*, i32** %6
%153 = call i32 @getc(i32* %152)
store i32 %153, i32* %13
br label %154
154: ; preds = %151
%155 = load i32, i32* %13
%156 = load i32, i32* @EOF
%157 = icmp ne i32 %155, %156
br i1 %157, label %158, label %161
158: ; preds = %154
%159 = load i32, i32* %13
%160 = icmp ne i32 %159, 10
br label %161
161: ; preds = %158, %154
%162 = phi i1 [ false, %154 ], [ %160, %158 ]
br i1 %162, label %151, label %163
163: ; preds = %161
br label %138
164: ; preds = %149
br label %165
165: ; preds = %186, %164
%166 = load i32, i32* %13
%167 = load i32, i32* @EOF
%168 = icmp ne i32 %166, %167
br i1 %168, label %169, label %174
169: ; preds = %165
%170 = load i32, i32* %13
%171 = call i64 @isspace(i32 %170)
%172 = icmp ne i64 %171, 0
%173 = xor i1 %172, true
br label %174
174: ; preds = %169, %165
%175 = phi i1 [ false, %165 ], [ %173, %169 ]
br i1 %175, label %176, label %189
176: ; preds = %174
%177 = load i32, i32* %11
%178 = icmp slt i32 %177, 126
br i1 %178, label %179, label %186
179: ; preds = %176
%180 = load i32, i32* %13
%181 = trunc i32 %180 to i8
%182 = load i32, i32* %11
%183 = add nsw i32 %182, 1
store i32 %183, i32* %11
%184 = sext i32 %182 to i64
%185 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %184
store i8 %181, i8* %185
br label %186
186: ; preds = %179, %176
%187 = load i32*, i32** %6
%188 = call i32 @getc(i32* %187)
store i32 %188, i32* %13
br label %165
189: ; preds = %174
%190 = load i32, i32* %11
%191 = icmp slt i32 %190, 127
br i1 %191, label %192, label %197
192: ; preds = %189
%193 = load i32, i32* %11
%194 = add nsw i32 %193, 1
store i32 %194, i32* %11
%195 = sext i32 %193 to i64
%196 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %195
store i8 32, i8* %196
br label %197
197: ; preds = %192, %189
%198 = load i32, i32* %11
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %199
store i8 0, i8* %200
%201 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%202 = load i32*, i32** %9
%203 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %201, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %202)
%204 = icmp ne i32 %203, 1
br i1 %204, label %205, label %206
205: ; preds = %197
store i32 0, i32* %5
br label %211
206: ; preds = %197
br label %209
207: ; preds = %132, %129
%208 = load i32*, i32** %9
store i32 1, i32* %208
br label %209
209: ; preds = %207, %206
%210 = load i32, i32* %14
store i32 %210, i32* %5
br label %211
211: ; preds = %209, %205, %128, %120
%212 = load i32, i32* %5
ret i32 %212
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"P1 \00"
@.str.1 = [4 x i8] c"P4 \00"
@.str.2 = [4 x i8] c"P2 \00"
@.str.3 = [4 x i8] c"P5 \00"
@.str.4 = [4 x i8] c"P3 \00"
@.str.5 = [4 x i8] c"P6 \00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [3 x i8] c"%d\00"
define i32 @ReadPNMImageFileHeader(i32* nocapture %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @getc(i32* %0)
br label %8
8: ; preds = %4, %57
%9 = phi i32 [ %7, %4 ], [ %51, %57 ]
%10 = phi i32 [ 0, %4 ], [ %59, %57 ]
%11 = phi i32 [ 0, %4 ], [ %58, %57 ]
br label %12
12: ; preds = %26, %8
%13 = phi i32 [ %9, %8 ], [ %27, %26 ]
%14 = tail call i64 @isspace(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12, %16
%17 = tail call i32 @getc(i32* %0)
%18 = tail call i64 @isspace(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16, %12
%21 = phi i32 [ %13, %12 ], [ %17, %16 ]
%22 = icmp eq i32 %21, 35
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %21, %24
br i1 %25, label %49, label %32
26: ; preds = %20, %26
%27 = tail call i32 @getc(i32* %0)
%28 = load i32, i32* @EOF
%29 = icmp ne i32 %27, %28
%30 = icmp ne i32 %27, 10
%31 = and i1 %30, %29
br i1 %31, label %26, label %12
32: ; preds = %23, %44
%33 = phi i32 [ %46, %44 ], [ %21, %23 ]
%34 = phi i32 [ %45, %44 ], [ %11, %23 ]
%35 = tail call i64 @isspace(i32 %33)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %32
%38 = icmp slt i32 %34, 126
br i1 %38, label %39, label %44
39: ; preds = %37
%40 = trunc i32 %33 to i8
%41 = add nsw i32 %34, 1
%42 = sext i32 %34 to i64
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %39, %37
%45 = phi i32 [ %41, %39 ], [ %34, %37 ]
%46 = tail call i32 @getc(i32* %0)
%47 = load i32, i32* @EOF
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %32
49: ; preds = %32, %44, %23
%50 = phi i32 [ %11, %23 ], [ %45, %44 ], [ %34, %32 ]
%51 = phi i32 [ %21, %23 ], [ %46, %44 ], [ %33, %32 ]
%52 = icmp slt i32 %50, 127
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = add nsw i32 %50, 1
%55 = sext i32 %50 to i64
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %55
store i8 32, i8* %56
br label %57
57: ; preds = %49, %53
%58 = phi i32 [ %54, %53 ], [ %50, %49 ]
%59 = add nuw nsw i32 %10, 1
%60 = icmp eq i32 %59, 3
br i1 %60, label %61, label %8
61: ; preds = %57
%62 = sext i32 %58 to i64
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %62
store i8 0, i8* %63
%64 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%65 = icmp eq i64 %64, 0
%66 = zext i1 %65 to i32
%67 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%68 = icmp eq i64 %67, 0
%69 = select i1 %68, i32 2, i32 %66
%70 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%71 = icmp eq i64 %70, 0
%72 = select i1 %71, i32 3, i32 %69
%73 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%74 = icmp eq i64 %73, 0
%75 = select i1 %74, i32 4, i32 %72
%76 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%77 = icmp eq i64 %76, 0
%78 = select i1 %77, i32 5, i32 %75
%79 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%80 = icmp eq i64 %79, 0
%81 = select i1 %80, i32 6, i32 %78
%82 = icmp eq i32 %81, 0
br i1 %82, label %145, label %83
83: ; preds = %61
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 3
%85 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %84, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %2, i32* %1)
%86 = icmp eq i32 %85, 2
br i1 %86, label %87, label %145
87: ; preds = %83
%88 = add nsw i32 %81, -3
%89 = icmp ult i32 %88, -2
br i1 %89, label %90, label %143
90: ; preds = %87
%91 = call i32 @getc(i32* %0)
br label %92
92: ; preds = %106, %90
%93 = phi i32 [ %91, %90 ], [ %107, %106 ]
%94 = call i64 @isspace(i32 %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %100, label %96
96: ; preds = %92, %96
%97 = call i32 @getc(i32* %0)
%98 = call i64 @isspace(i32 %97)
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %96
100: ; preds = %96, %92
%101 = phi i32 [ %93, %92 ], [ %97, %96 ]
%102 = icmp eq i32 %101, 35
br i1 %102, label %106, label %103
103: ; preds = %100
%104 = load i32, i32* @EOF
%105 = icmp eq i32 %101, %104
br i1 %105, label %132, label %112
106: ; preds = %100, %106
%107 = call i32 @getc(i32* %0)
%108 = load i32, i32* @EOF
%109 = icmp ne i32 %107, %108
%110 = icmp ne i32 %107, 10
%111 = and i1 %110, %109
br i1 %111, label %106, label %92
112: ; preds = %103, %124
%113 = phi i32 [ %126, %124 ], [ %101, %103 ]
%114 = phi i32 [ %125, %124 ], [ 0, %103 ]
%115 = call i64 @isspace(i32 %113)
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %129
117: ; preds = %112
%118 = icmp slt i32 %114, 126
br i1 %118, label %119, label %124
119: ; preds = %117
%120 = trunc i32 %113 to i8
%121 = add nsw i32 %114, 1
%122 = sext i32 %114 to i64
%123 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %122
store i8 %120, i8* %123
br label %124
124: ; preds = %119, %117
%125 = phi i32 [ %121, %119 ], [ %114, %117 ]
%126 = call i32 @getc(i32* %0)
%127 = load i32, i32* @EOF
%128 = icmp eq i32 %126, %127
br i1 %128, label %129, label %112
129: ; preds = %112, %124
%130 = phi i32 [ %114, %112 ], [ %125, %124 ]
%131 = icmp slt i32 %130, 127
br i1 %131, label %132, label %137
132: ; preds = %103, %129
%133 = phi i32 [ %130, %129 ], [ 0, %103 ]
%134 = add nsw i32 %133, 1
%135 = sext i32 %133 to i64
%136 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %135
store i8 32, i8* %136
br label %137
137: ; preds = %132, %129
%138 = phi i32 [ %134, %132 ], [ %130, %129 ]
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %139
store i8 0, i8* %140
%141 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%142 = icmp eq i32 %141, 1
br i1 %142, label %144, label %145
143: ; preds = %87
store i32 1, i32* %3
br label %144
144: ; preds = %137, %143
br label %145
145: ; preds = %137, %83, %61, %144
%146 = phi i32 [ %81, %144 ], [ 0, %61 ], [ 0, %83 ], [ 0, %137 ]
ret i32 %146
}