int read_ppm_header(int fd, int *width, int *height) {
  char s[6];
  int incomment;
  int n;
  int maxval = 0;
  *width = 0;
  *height = 0;
  n = y4m_read(fd, s, 3);
  if (n > 0)
    return 1;
  if ((n < 0) || (strncmp(s, "P6", 2)))
    mjpeg_error_exit1("Bad Raw PPM magic!");
  incomment = 0;
  incomment = 0;
  while (((n = read(fd, s, 1)) == 1) &&
         ((isspace(s[0])) || (s[0] == '#') || (incomment))) {
    if (s[0] == '#')
      incomment = 1;
    if (s[0] == '\n')
      incomment = 0;
  }
  if (n <= 0)
    return -1;
  ;
  do {
    if (!isdigit(s[0]))
      mjpeg_error_exit1("PPM read error:  bad char");
    (*width) = ((*width) * 10) + (s[0] - '0');
  } while (((n = read(fd, s, 1)) == 1) && (!isspace(s[0])));
  if (n <= 0)
    return -1;
  ;
  incomment = 0;
  while (((n = read(fd, s, 1)) == 1) &&
         ((isspace(s[0])) || (s[0] == '#') || (incomment))) {
    if (s[0] == '#')
      incomment = 1;
    if (s[0] == '\n')
      incomment = 0;
  }
  if (n <= 0)
    return -1;
  ;
  do {
    if (!isdigit(s[0]))
      mjpeg_error_exit1("PPM read error:  bad char");
    (*height) = ((*height) * 10) + (s[0] - '0');
  } while (((n = read(fd, s, 1)) == 1) && (!isspace(s[0])));
  if (n <= 0)
    return -1;
  ;
  incomment = 0;
  while (((n = read(fd, s, 1)) == 1) &&
         ((isspace(s[0])) || (s[0] == '#') || (incomment))) {
    if (s[0] == '#')
      incomment = 1;
    if (s[0] == '\n')
      incomment = 0;
  }
  if (n <= 0)
    return -1;
  ;
  do {
    if (!isdigit(s[0]))
      mjpeg_error_exit1("PPM read error:  bad char");
    (maxval) = ((maxval)*10) + (s[0] - '0');
  } while (((n = read(fd, s, 1)) == 1) && (!isspace(s[0])));
  if (n <= 0)
    return -1;
  ;
  if (maxval != 255)
    mjpeg_error_exit1("Expecting maxval == 255, not %d!", maxval);
  return 0;
}


x86 assembly (clang, -O0):
<read_ppm_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1050 <y4m_read@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    11ba <read_ppm_header+0x5a>
movl   $0x1,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
cmpl   $0x0,-0x28(%rbp)
jl     11e2 <read_ppm_header+0x82>
lea    -0x1e(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11f0 <read_ppm_header+0x90>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1080 <mjpeg_error_exit1@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x2d(%rbp)
jne    125f <read_ppm_header+0xff>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x2e(%rbp)
jne    1259 <read_ppm_header+0xf9>
movsbl -0x1e(%rbp),%ecx
mov    $0x1,%al
cmp    $0x23,%ecx
mov    %al,-0x2e(%rbp)
je     1259 <read_ppm_header+0xf9>
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    126f <read_ppm_header+0x10f>
jmp    129c <read_ppm_header+0x13c>
movsbl -0x1e(%rbp),%eax
cmp    $0x23,%eax
jne    1283 <read_ppm_header+0x123>
movl   $0x1,-0x24(%rbp)
movsbl -0x1e(%rbp),%eax
cmp    $0xa,%eax
jne    1297 <read_ppm_header+0x137>
movl   $0x0,-0x24(%rbp)
jmp    11fe <read_ppm_header+0x9e>
cmpl   $0x0,-0x28(%rbp)
jg     12b2 <read_ppm_header+0x152>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
jmp    12b7 <read_ppm_header+0x157>
movsbl -0x1e(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    12d7 <read_ppm_header+0x177>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1080 <mjpeg_error_exit1@plt>
mov    -0x10(%rbp),%rax
imul   $0xa,(%rax),%ecx
movsbl -0x1e(%rbp),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x2f(%rbp)
jne    1327 <read_ppm_header+0x1c7>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x2f(%rbp)
mov    -0x2f(%rbp),%al
test   $0x1,%al
jne    12b7 <read_ppm_header+0x157>
cmpl   $0x0,-0x28(%rbp)
jg     1348 <read_ppm_header+0x1e8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x30(%rbp)
jne    13b0 <read_ppm_header+0x250>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    13aa <read_ppm_header+0x24a>
movsbl -0x1e(%rbp),%ecx
mov    $0x1,%al
cmp    $0x23,%ecx
mov    %al,-0x31(%rbp)
je     13aa <read_ppm_header+0x24a>
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
mov    %al,-0x30(%rbp)
mov    -0x30(%rbp),%al
test   $0x1,%al
jne    13c0 <read_ppm_header+0x260>
jmp    13ed <read_ppm_header+0x28d>
movsbl -0x1e(%rbp),%eax
cmp    $0x23,%eax
jne    13d4 <read_ppm_header+0x274>
movl   $0x1,-0x24(%rbp)
movsbl -0x1e(%rbp),%eax
cmp    $0xa,%eax
jne    13e8 <read_ppm_header+0x288>
movl   $0x0,-0x24(%rbp)
jmp    134f <read_ppm_header+0x1ef>
cmpl   $0x0,-0x28(%rbp)
jg     1403 <read_ppm_header+0x2a3>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
jmp    1408 <read_ppm_header+0x2a8>
movsbl -0x1e(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    1428 <read_ppm_header+0x2c8>
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1080 <mjpeg_error_exit1@plt>
mov    -0x18(%rbp),%rax
imul   $0xa,(%rax),%ecx
movsbl -0x1e(%rbp),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x32(%rbp)
jne    1478 <read_ppm_header+0x318>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    1408 <read_ppm_header+0x2a8>
cmpl   $0x0,-0x28(%rbp)
jg     1499 <read_ppm_header+0x339>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x33(%rbp)
jne    1501 <read_ppm_header+0x3a1>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x34(%rbp)
jne    14fb <read_ppm_header+0x39b>
movsbl -0x1e(%rbp),%ecx
mov    $0x1,%al
cmp    $0x23,%ecx
mov    %al,-0x34(%rbp)
je     14fb <read_ppm_header+0x39b>
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x34(%rbp)
mov    -0x34(%rbp),%al
mov    %al,-0x33(%rbp)
mov    -0x33(%rbp),%al
test   $0x1,%al
jne    1511 <read_ppm_header+0x3b1>
jmp    153e <read_ppm_header+0x3de>
movsbl -0x1e(%rbp),%eax
cmp    $0x23,%eax
jne    1525 <read_ppm_header+0x3c5>
movl   $0x1,-0x24(%rbp)
movsbl -0x1e(%rbp),%eax
cmp    $0xa,%eax
jne    1539 <read_ppm_header+0x3d9>
movl   $0x0,-0x24(%rbp)
jmp    14a0 <read_ppm_header+0x340>
cmpl   $0x0,-0x28(%rbp)
jg     1554 <read_ppm_header+0x3f4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
jmp    1559 <read_ppm_header+0x3f9>
movsbl -0x1e(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    1579 <read_ppm_header+0x419>
lea    0xaa4(%rip),%rdi
mov    $0x0,%al
call   1080 <mjpeg_error_exit1@plt>
imul   $0xa,-0x2c(%rbp),%eax
movsbl -0x1e(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x35(%rbp)
jne    15c3 <read_ppm_header+0x463>
movsbl -0x1e(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1559 <read_ppm_header+0x3f9>
cmpl   $0x0,-0x28(%rbp)
jg     15e4 <read_ppm_header+0x484>
movl   $0xffffffff,-0x4(%rbp)
jmp    1609 <read_ppm_header+0x4a9>
cmpl   $0xff,-0x2c(%rbp)
je     1602 <read_ppm_header+0x4a2>
mov    -0x2c(%rbp),%esi
lea    0xa35(%rip),%rdi
mov    $0x0,%al
call   1080 <mjpeg_error_exit1@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ppm_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r13d
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
lea    0xa(%rsp),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <y4m_read@plt>
mov    $0x1,%r15d
test   %eax,%eax
jg     14a6 <read_ppm_header+0x366>
mov    %rbx,0x10(%rsp)
js     1195 <read_ppm_header+0x55>
movzwl 0xa(%rsp),%eax
cmp    $0x3650,%eax
je     11a3 <read_ppm_header+0x63>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1060 <mjpeg_error_exit1@plt>
lea    0xa(%rsp),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    121b <read_ppm_header+0xdb>
mov    $0x1,%ebx
lea    0xa(%rsp),%r15
xor    %r12d,%r12d
jmp    11fc <read_ppm_header+0xbc>
nopl   0x0(%rax,%rax,1)
cmp    $0x23,%bpl
cmove  %ebx,%r12d
cmp    $0xa,%bpl
mov    $0x0,%eax
cmove  %eax,%r12d
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    121b <read_ppm_header+0xdb>
movzbl 0xa(%rsp),%ebp
movsbl %bpl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    11d0 <read_ppm_header+0x90>
cmp    $0x23,%bpl
je     11d0 <read_ppm_header+0x90>
test   %r12d,%r12d
jne    11d0 <read_ppm_header+0x90>
jmp    1223 <read_ppm_header+0xe3>
test   %eax,%eax
jle    14a0 <read_ppm_header+0x360>
mov    0xa(%rsp),%bl
lea    0xa(%rsp),%r15
lea    0xde3(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %bl,%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%ecx
jb     125a <read_ppm_header+0x11a>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <mjpeg_error_exit1@plt>
movsbl 0xa(%rsp),%eax
mov    (%r14),%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rax,%rcx,2),%eax
add    $0xffffffd0,%eax
mov    %eax,(%r14)
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1293 <read_ppm_header+0x153>
movzbl 0xa(%rsp),%ebx
movsbl %bl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     1240 <read_ppm_header+0x100>
jmp    1299 <read_ppm_header+0x159>
jl     14a0 <read_ppm_header+0x360>
xor    %r14d,%r14d
lea    0xa(%rsp),%rsi
mov    $0x1,%r12d
mov    %r13d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1316 <read_ppm_header+0x1d6>
lea    0xa(%rsp),%rbx
xor    %ebp,%ebp
jmp    12f7 <read_ppm_header+0x1b7>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x23,%r15b
cmove  %r12d,%ebp
cmp    $0xa,%r15b
cmove  %r14d,%ebp
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1316 <read_ppm_header+0x1d6>
movzbl 0xa(%rsp),%r15d
movsbl %r15b,%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    12d0 <read_ppm_header+0x190>
cmp    $0x23,%r15b
je     12d0 <read_ppm_header+0x190>
test   %ebp,%ebp
jne    12d0 <read_ppm_header+0x190>
jmp    131e <read_ppm_header+0x1de>
test   %eax,%eax
jle    14a0 <read_ppm_header+0x360>
mov    0xa(%rsp),%bl
lea    0xa(%rsp),%r14
lea    0xce8(%rip),%r15
mov    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %bl,%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%ecx
jb     135a <read_ppm_header+0x21a>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <mjpeg_error_exit1@plt>
movsbl 0xa(%rsp),%eax
mov    0x0(%rbp),%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rax,%rcx,2),%eax
add    $0xffffffd0,%eax
mov    %eax,0x0(%rbp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1393 <read_ppm_header+0x253>
movzbl 0xa(%rsp),%ebx
movsbl %bl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     1340 <read_ppm_header+0x200>
jmp    1399 <read_ppm_header+0x259>
jl     14a0 <read_ppm_header+0x360>
xor    %r14d,%r14d
lea    0xa(%rsp),%rsi
mov    $0x1,%r15d
mov    %r13d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1411 <read_ppm_header+0x2d1>
lea    0xa(%rsp),%r12
xor    %ebp,%ebp
jmp    13f5 <read_ppm_header+0x2b5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x23,%bl
cmove  %r15d,%ebp
cmp    $0xa,%bl
cmove  %r14d,%ebp
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    1411 <read_ppm_header+0x2d1>
movzbl 0xa(%rsp),%ebx
movsbl %bl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    13d0 <read_ppm_header+0x290>
cmp    $0x23,%bl
je     13d0 <read_ppm_header+0x290>
test   %ebp,%ebp
jne    13d0 <read_ppm_header+0x290>
jmp    1419 <read_ppm_header+0x2d9>
test   %eax,%eax
jle    14a0 <read_ppm_header+0x360>
mov    0xa(%rsp),%bl
lea    0xa(%rsp),%r14
lea    0xbed(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl %bl,%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%ecx
jb     144a <read_ppm_header+0x30a>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <mjpeg_error_exit1@plt>
movsbl 0xa(%rsp),%eax
lea    0x0(%rbp,%rbp,4),%ecx
lea    (%rax,%rcx,2),%ebp
add    $0xffffffd0,%ebp
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <read@plt>
cmp    $0x1,%eax
jne    147e <read_ppm_header+0x33e>
movzbl 0xa(%rsp),%ebx
movsbl %bl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     1430 <read_ppm_header+0x2f0>
jmp    1480 <read_ppm_header+0x340>
jl     14a0 <read_ppm_header+0x360>
xor    %r15d,%r15d
cmp    $0xff,%ebp
je     14a6 <read_ppm_header+0x366>
lea    0xb9e(%rip),%rdi
xor    %r15d,%r15d
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <mjpeg_error_exit1@plt>
jmp    14a6 <read_ppm_header+0x366>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"P6\00"
@.str.1 = [19 x i8] c"Bad Raw PPM magic!\00"
@.str.2 = [26 x i8] c"PPM read error: bad char\00"
@.str.3 = [33 x i8] c"Expecting maxval == 255, not %d!\00"
define i32 @read_ppm_header(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [6 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 0, i32* %11
%12 = load i32*, i32** %6
store i32 0, i32* %12
%13 = load i32*, i32** %7
store i32 0, i32* %13
%14 = load i32, i32* %5
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%16 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @y4m_read to i32 (i32, i8*, i32, ...)*)(i32 %14, i8* %15, i32 3)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 1, i32* %4
br label %268
20: ; preds = %3
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%25 = call i32 @strncmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23, %20
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
store i32 0, i32* %9
store i32 0, i32* %9
br label %30
30: ; preds = %65, %29
%31 = load i32, i32* %5
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%33 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %31, i8* %32, i32 1)
store i32 %33, i32* %10
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %51
35: ; preds = %30
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 @isspace(i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %35
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 35
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br label %49
49: ; preds = %46, %41, %35
%50 = phi i1 [ true, %41 ], [ true, %35 ], [ %48, %46 ]
br label %51
51: ; preds = %49, %30
%52 = phi i1 [ false, %30 ], [ %50, %49 ]
br i1 %52, label %53, label %66
53: ; preds = %51
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 35
br i1 %57, label %58, label %59
58: ; preds = %53
store i32 1, i32* %9
br label %59
59: ; preds = %58, %53
%60 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 10
br i1 %63, label %64, label %65
64: ; preds = %59
store i32 0, i32* %9
br label %65
65: ; preds = %64, %59
br label %30
66: ; preds = %51
%67 = load i32, i32* %10
%68 = icmp sle i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %66
store i32 -1, i32* %4
br label %268
70: ; preds = %66
br label %71
71: ; preds = %101, %70
%72 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = call i32 @isdigit(i32 %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %71
%78 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %79
79: ; preds = %77, %71
%80 = load i32*, i32** %6
%81 = load i32, i32* %80
%82 = mul nsw i32 %81, 10
%83 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = sub nsw i32 %85, 48
%87 = add nsw i32 %82, %86
%88 = load i32*, i32** %6
store i32 %87, i32* %88
br label %89
89: ; preds = %79
%90 = load i32, i32* %5
%91 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%92 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %90, i8* %91, i32 1)
store i32 %92, i32* %10
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %101
94: ; preds = %89
%95 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = call i32 @isspace(i32 %97)
%99 = icmp ne i32 %98, 0
%100 = xor i1 %99, true
br label %101
101: ; preds = %94, %89
%102 = phi i1 [ false, %89 ], [ %100, %94 ]
br i1 %102, label %71, label %103
103: ; preds = %101
%104 = load i32, i32* %10
%105 = icmp sle i32 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %103
store i32 -1, i32* %4
br label %268
107: ; preds = %103
store i32 0, i32* %9
br label %108
108: ; preds = %143, %107
%109 = load i32, i32* %5
%110 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%111 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %109, i8* %110, i32 1)
store i32 %111, i32* %10
%112 = icmp eq i32 %111, 1
br i1 %112, label %113, label %129
113: ; preds = %108
%114 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = call i32 @isspace(i32 %116)
%118 = icmp ne i32 %117, 0
br i1 %118, label %127, label %119
119: ; preds = %113
%120 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 35
br i1 %123, label %127, label %124
124: ; preds = %119
%125 = load i32, i32* %9
%126 = icmp ne i32 %125, 0
br label %127
127: ; preds = %124, %119, %113
%128 = phi i1 [ true, %119 ], [ true, %113 ], [ %126, %124 ]
br label %129
129: ; preds = %127, %108
%130 = phi i1 [ false, %108 ], [ %128, %127 ]
br i1 %130, label %131, label %144
131: ; preds = %129
%132 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 35
br i1 %135, label %136, label %137
136: ; preds = %131
store i32 1, i32* %9
br label %137
137: ; preds = %136, %131
%138 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%139 = load i8, i8* %138
%140 = sext i8 %139 to i32
%141 = icmp eq i32 %140, 10
br i1 %141, label %142, label %143
142: ; preds = %137
store i32 0, i32* %9
br label %143
143: ; preds = %142, %137
br label %108
144: ; preds = %129
%145 = load i32, i32* %10
%146 = icmp sle i32 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %144
store i32 -1, i32* %4
br label %268
148: ; preds = %144
br label %149
149: ; preds = %179, %148
%150 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = call i32 @isdigit(i32 %152)
%154 = icmp ne i32 %153, 0
br i1 %154, label %157, label %155
155: ; preds = %149
%156 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %157
157: ; preds = %155, %149
%158 = load i32*, i32** %7
%159 = load i32, i32* %158
%160 = mul nsw i32 %159, 10
%161 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%162 = load i8, i8* %161
%163 = sext i8 %162 to i32
%164 = sub nsw i32 %163, 48
%165 = add nsw i32 %160, %164
%166 = load i32*, i32** %7
store i32 %165, i32* %166
br label %167
167: ; preds = %157
%168 = load i32, i32* %5
%169 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%170 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %168, i8* %169, i32 1)
store i32 %170, i32* %10
%171 = icmp eq i32 %170, 1
br i1 %171, label %172, label %179
172: ; preds = %167
%173 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = call i32 @isspace(i32 %175)
%177 = icmp ne i32 %176, 0
%178 = xor i1 %177, true
br label %179
179: ; preds = %172, %167
%180 = phi i1 [ false, %167 ], [ %178, %172 ]
br i1 %180, label %149, label %181
181: ; preds = %179
%182 = load i32, i32* %10
%183 = icmp sle i32 %182, 0
br i1 %183, label %184, label %185
184: ; preds = %181
store i32 -1, i32* %4
br label %268
185: ; preds = %181
store i32 0, i32* %9
br label %186
186: ; preds = %221, %185
%187 = load i32, i32* %5
%188 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%189 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %187, i8* %188, i32 1)
store i32 %189, i32* %10
%190 = icmp eq i32 %189, 1
br i1 %190, label %191, label %207
191: ; preds = %186
%192 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%193 = load i8, i8* %192
%194 = sext i8 %193 to i32
%195 = call i32 @isspace(i32 %194)
%196 = icmp ne i32 %195, 0
br i1 %196, label %205, label %197
197: ; preds = %191
%198 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%199 = load i8, i8* %198
%200 = sext i8 %199 to i32
%201 = icmp eq i32 %200, 35
br i1 %201, label %205, label %202
202: ; preds = %197
%203 = load i32, i32* %9
%204 = icmp ne i32 %203, 0
br label %205
205: ; preds = %202, %197, %191
%206 = phi i1 [ true, %197 ], [ true, %191 ], [ %204, %202 ]
br label %207
207: ; preds = %205, %186
%208 = phi i1 [ false, %186 ], [ %206, %205 ]
br i1 %208, label %209, label %222
209: ; preds = %207
%210 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%211 = load i8, i8* %210
%212 = sext i8 %211 to i32
%213 = icmp eq i32 %212, 35
br i1 %213, label %214, label %215
214: ; preds = %209
store i32 1, i32* %9
br label %215
215: ; preds = %214, %209
%216 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%217 = load i8, i8* %216
%218 = sext i8 %217 to i32
%219 = icmp eq i32 %218, 10
br i1 %219, label %220, label %221
220: ; preds = %215
store i32 0, i32* %9
br label %221
221: ; preds = %220, %215
br label %186
222: ; preds = %207
%223 = load i32, i32* %10
%224 = icmp sle i32 %223, 0
br i1 %224, label %225, label %226
225: ; preds = %222
store i32 -1, i32* %4
br label %268
226: ; preds = %222
br label %227
227: ; preds = %255, %226
%228 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%229 = load i8, i8* %228
%230 = sext i8 %229 to i32
%231 = call i32 @isdigit(i32 %230)
%232 = icmp ne i32 %231, 0
br i1 %232, label %235, label %233
233: ; preds = %227
%234 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %235
235: ; preds = %233, %227
%236 = load i32, i32* %11
%237 = mul nsw i32 %236, 10
%238 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%239 = load i8, i8* %238
%240 = sext i8 %239 to i32
%241 = sub nsw i32 %240, 48
%242 = add nsw i32 %237, %241
store i32 %242, i32* %11
br label %243
243: ; preds = %235
%244 = load i32, i32* %5
%245 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%246 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %244, i8* %245, i32 1)
store i32 %246, i32* %10
%247 = icmp eq i32 %246, 1
br i1 %247, label %248, label %255
248: ; preds = %243
%249 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%250 = load i8, i8* %249
%251 = sext i8 %250 to i32
%252 = call i32 @isspace(i32 %251)
%253 = icmp ne i32 %252, 0
%254 = xor i1 %253, true
br label %255
255: ; preds = %248, %243
%256 = phi i1 [ false, %243 ], [ %254, %248 ]
br i1 %256, label %227, label %257
257: ; preds = %255
%258 = load i32, i32* %10
%259 = icmp sle i32 %258, 0
br i1 %259, label %260, label %261
260: ; preds = %257
store i32 -1, i32* %4
br label %268
261: ; preds = %257
%262 = load i32, i32* %11
%263 = icmp ne i32 %262, 255
br i1 %263, label %264, label %267
264: ; preds = %261
%265 = load i32, i32* %11
%266 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %265)
br label %267
267: ; preds = %264, %261
store i32 0, i32* %4
br label %268
268: ; preds = %267, %260, %225, %184, %147, %106, %69, %19
%269 = load i32, i32* %4
ret i32 %269
}

LLVM IR (-O2):
@.str = [3 x i8] c"P6\00"
@.str.1 = [19 x i8] c"Bad Raw PPM magic!\00"
@.str.2 = [26 x i8] c"PPM read error: bad char\00"
@.str.3 = [33 x i8] c"Expecting maxval == 255, not %d!\00"
define i32 @read_ppm_header(i32 %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @y4m_read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %163, label %8
8: ; preds = %3
%9 = icmp slt i32 %6, 0
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = call i32 @bcmp(i8* dereferenceable(2) %5, i8* dereferenceable(2) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10, %8
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %34
18: ; preds = %15, %28
%19 = phi i32 [ %31, %28 ], [ 0, %15 ]
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = call i32 @isspace(i32 %21)
%23 = icmp ne i32 %22, 0
%24 = icmp eq i8 %20, 35
%25 = select i1 %23, i1 true, i1 %24
%26 = icmp ne i32 %19, 0
%27 = select i1 %25, i1 true, i1 %26
br i1 %27, label %28, label %37
28: ; preds = %18
%29 = select i1 %24, i32 1, i32 %19
%30 = icmp eq i8 %20, 10
%31 = select i1 %30, i32 0, i32 %29
%32 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%33 = icmp eq i32 %32, 1
br i1 %33, label %18, label %34
34: ; preds = %28, %15
%35 = phi i32 [ %16, %15 ], [ %32, %28 ]
%36 = icmp slt i32 %35, 1
br i1 %36, label %163, label %37
37: ; preds = %18, %34
%38 = load i8, i8* %5
br label %39
39: ; preds = %37, %56
%40 = phi i8 [ %38, %37 ], [ %57, %56 ]
%41 = sext i8 %40 to i32
%42 = add nsw i32 %41, -48
%43 = icmp ult i32 %42, 10
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8, i8* %5
%47 = sext i8 %46 to i32
br label %48
48: ; preds = %44, %39
%49 = phi i32 [ %47, %44 ], [ %41, %39 ]
%50 = load i32, i32* %1
%51 = mul nsw i32 %50, 10
%52 = add i32 %51, -48
%53 = add i32 %52, %49
store i32 %53, i32* %1
%54 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %61
56: ; preds = %48
%57 = load i8, i8* %5
%58 = sext i8 %57 to i32
%59 = call i32 @isspace(i32 %58)
%60 = icmp eq i32 %59, 0
br i1 %60, label %39, label %63
61: ; preds = %48
%62 = icmp slt i32 %54, 1
br i1 %62, label %163, label %63
63: ; preds = %56, %61
%64 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %82
66: ; preds = %63, %76
%67 = phi i32 [ %79, %76 ], [ 0, %63 ]
%68 = load i8, i8* %5
%69 = sext i8 %68 to i32
%70 = call i32 @isspace(i32 %69)
%71 = icmp ne i32 %70, 0
%72 = icmp eq i8 %68, 35
%73 = select i1 %71, i1 true, i1 %72
%74 = icmp ne i32 %67, 0
%75 = select i1 %73, i1 true, i1 %74
br i1 %75, label %76, label %85
76: ; preds = %66
%77 = select i1 %72, i32 1, i32 %67
%78 = icmp eq i8 %68, 10
%79 = select i1 %78, i32 0, i32 %77
%80 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%81 = icmp eq i32 %80, 1
br i1 %81, label %66, label %82
82: ; preds = %76, %63
%83 = phi i32 [ %64, %63 ], [ %80, %76 ]
%84 = icmp slt i32 %83, 1
br i1 %84, label %163, label %85
85: ; preds = %66, %82
%86 = load i8, i8* %5
br label %87
87: ; preds = %85, %104
%88 = phi i8 [ %86, %85 ], [ %105, %104 ]
%89 = sext i8 %88 to i32
%90 = add nsw i32 %89, -48
%91 = icmp ult i32 %90, 10
br i1 %91, label %96, label %92
92: ; preds = %87
%93 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%94 = load i8, i8* %5
%95 = sext i8 %94 to i32
br label %96
96: ; preds = %92, %87
%97 = phi i32 [ %95, %92 ], [ %89, %87 ]
%98 = load i32, i32* %2
%99 = mul nsw i32 %98, 10
%100 = add i32 %99, -48
%101 = add i32 %100, %97
store i32 %101, i32* %2
%102 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %109
104: ; preds = %96
%105 = load i8, i8* %5
%106 = sext i8 %105 to i32
%107 = call i32 @isspace(i32 %106)
%108 = icmp eq i32 %107, 0
br i1 %108, label %87, label %111
109: ; preds = %96
%110 = icmp slt i32 %102, 1
br i1 %110, label %163, label %111
111: ; preds = %104, %109
%112 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%113 = icmp eq i32 %112, 1
br i1 %113, label %114, label %130
114: ; preds = %111, %124
%115 = phi i32 [ %127, %124 ], [ 0, %111 ]
%116 = load i8, i8* %5
%117 = sext i8 %116 to i32
%118 = call i32 @isspace(i32 %117)
%119 = icmp ne i32 %118, 0
%120 = icmp eq i8 %116, 35
%121 = select i1 %119, i1 true, i1 %120
%122 = icmp ne i32 %115, 0
%123 = select i1 %121, i1 true, i1 %122
br i1 %123, label %124, label %133
124: ; preds = %114
%125 = select i1 %120, i32 1, i32 %115
%126 = icmp eq i8 %116, 10
%127 = select i1 %126, i32 0, i32 %125
%128 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%129 = icmp eq i32 %128, 1
br i1 %129, label %114, label %130
130: ; preds = %124, %111
%131 = phi i32 [ %112, %111 ], [ %128, %124 ]
%132 = icmp slt i32 %131, 1
br i1 %132, label %163, label %133
133: ; preds = %114, %130
%134 = load i8, i8* %5
br label %135
135: ; preds = %133, %152
%136 = phi i8 [ %153, %152 ], [ %134, %133 ]
%137 = phi i32 [ %149, %152 ], [ 0, %133 ]
%138 = sext i8 %136 to i32
%139 = add nsw i32 %138, -48
%140 = icmp ult i32 %139, 10
br i1 %140, label %145, label %141
141: ; preds = %135
%142 = call i32 (i8*, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, ...)*)(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%143 = load i8, i8* %5
%144 = sext i8 %143 to i32
br label %145
145: ; preds = %141, %135
%146 = phi i32 [ %144, %141 ], [ %138, %135 ]
%147 = mul nsw i32 %137, 10
%148 = add i32 %147, -48
%149 = add i32 %148, %146
%150 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %5, i32 1)
%151 = icmp eq i32 %150, 1
br i1 %151, label %152, label %157
152: ; preds = %145
%153 = load i8, i8* %5
%154 = sext i8 %153 to i32
%155 = call i32 @isspace(i32 %154)
%156 = icmp eq i32 %155, 0
br i1 %156, label %135, label %159
157: ; preds = %145
%158 = icmp slt i32 %150, 1
br i1 %158, label %163, label %159
159: ; preds = %152, %157
%160 = icmp eq i32 %149, 255
br i1 %160, label %163, label %161
161: ; preds = %159
%162 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mjpeg_error_exit1 to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %149)
br label %163
163: ; preds = %159, %161, %157, %130, %109, %82, %61, %34, %3
%164 = phi i32 [ 1, %3 ], [ -1, %34 ], [ -1, %61 ], [ -1, %82 ], [ -1, %109 ], [ -1, %130 ], [ -1, %157 ], [ 0, %161 ], [ 0, %159 ]
ret i32 %164
}