#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ stderr;
char *readrec(FILE *fp, int *len) {
  int c, i;
  int chksum;
  char *buf;
  chksum = 0;
  while (c = fgetc(fp), c != EOF && c == 0)
    ;
  if (c == EOF)
    return NULL;
  if (c != 1) {
    fprintf(stderr, "Improperly formatted OBJ file (1)\n");
    return NULL;
  }
  chksum -= c;
  c = fgetc(fp);
  if (c != 0) {
    fprintf(stderr, "Improperly formatted OBJ file (2)\n");
    return NULL;
  }
  chksum -= c;
  c = fgetc(fp);
  if (c == EOF) {
    fprintf(stderr, "Improperly formatted OBJ file (3)\n");
    return NULL;
  }
  *len = c;
  chksum -= c;
  c = fgetc(fp);
  if (c == EOF) {
    fprintf(stderr, "Improperly formatted OBJ file (4)\n");
    return NULL;
  }
  *len += (c << 8);
  chksum -= c;
  *len -= 4;
  if (*len < 0) {
    fprintf(stderr, "Improperly formatted OBJ file (5)\n");
    return NULL;
  }
  buf = malloc(*len);
  if (buf == NULL) {
    fprintf(stderr, "Out of memory allocating %d bytes\n", *len);
    return NULL;
  }
  i = fread(buf, 1, *len, fp);
  if (i < *len) {
    free(buf);
    fprintf(stderr, "Improperly formatted OBJ file (6)\n");
    return NULL;
  }
  for (i = 0; i < *len; i++)
    chksum -= (buf[i] & 0xff);
  c = fgetc(fp);
  c &= 0xff;
  chksum &= 0xff;
  if (c != chksum) {
    free(buf);
    fprintf(stderr,
            "Bad record checksum, "
            "calculated=%d, recorded=%d\n",
            chksum, c);
    return NULL;
  }
  return buf;
}


x86 assembly (clang, -O0):
<readrec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
mov    0x2e69(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x31(%rbp)
je     1194 <readrec+0x44>
cmpl   $0x0,-0x1c(%rbp)
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11a4 <readrec+0x54>
jmp    11a9 <readrec+0x59>
jmp    1167 <readrec+0x17>
mov    -0x1c(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
jne    11c8 <readrec+0x78>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
cmpl   $0x1,-0x1c(%rbp)
je     11f6 <readrec+0xa6>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x1c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     123b <readrec+0xeb>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x1c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d8c(%rip),%rcx
cmp    (%rcx),%eax
jne    1288 <readrec+0x138>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d36(%rip),%rcx
cmp    (%rcx),%eax
jne    12de <readrec+0x18e>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x4,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1333 <readrec+0x1e3>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1377 <readrec+0x227>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    13ce <readrec+0x27e>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    140c <readrec+0x2bc>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13d5 <readrec+0x285>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     146d <readrec+0x31d>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xc9c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1475 <readrec+0x325>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readrec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%rbx
mov    0x2e80(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    0x0(%rbp),%ecx
test   %eax,%eax
jne    1183 <readrec+0x33>
test   %ecx,%ecx
jne    1170 <readrec+0x20>
cmp    %ecx,%eax
jne    118c <readrec+0x3c>
xor    %r14d,%r14d
jmp    11c9 <readrec+0x79>
cmp    $0x1,%eax
jne    11af <readrec+0x5f>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
test   %eax,%eax
je     11db <readrec+0x8b>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
jmp    11bf <readrec+0x6f>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
jne    11fa <readrec+0xaa>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
jmp    11bf <readrec+0x6f>
mov    %eax,%r15d
mov    %eax,0x0(%r13)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
jne    1220 <readrec+0xd0>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
jmp    11bf <readrec+0x6f>
mov    %eax,%r12d
shl    $0x8,%eax
mov    0x0(%r13),%ecx
lea    (%rcx,%rax,1),%edx
lea    (%rcx,%rax,1),%ebp
add    $0xfffffffc,%ebp
mov    %ebp,0x0(%r13)
cmp    $0x3,%edx
jg     1251 <readrec+0x101>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
jmp    11bf <readrec+0x6f>
mov    %ebp,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1297 <readrec+0x147>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    0x0(%r13),%ecx
cmp    %ecx,%eax
jge    12b8 <readrec+0x168>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
jmp    11bf <readrec+0x6f>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
xor    %r14d,%r14d
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11c9 <readrec+0x79>
not    %r15d
sub    %r12d,%r15d
test   %ecx,%ecx
jle    13bd <readrec+0x26d>
cmp    $0x8,%ecx
jae    12d2 <readrec+0x182>
xor    %eax,%eax
jmp    13ac <readrec+0x25c>
mov    %ecx,%eax
and    $0xfffffff8,%eax
movd   %r15d,%xmm0
lea    -0x8(%rax),%rsi
mov    %rsi,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     1358 <readrec+0x208>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
pxor   %xmm2,%xmm2
xor    %esi,%esi
pxor   %xmm1,%xmm1
movd   (%r14,%rsi,1),%xmm3
movd   0x4(%r14,%rsi,1),%xmm4
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
movd   0x8(%r14,%rsi,1),%xmm5
movd   0xc(%r14,%rsi,1),%xmm6
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm3,%xmm5
psubd  %xmm5,%xmm0
punpcklbw %xmm2,%xmm6
punpcklwd %xmm2,%xmm6
paddd  %xmm4,%xmm6
psubd  %xmm6,%xmm1
add    $0x10,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1301 <readrec+0x1b1>
jmp    135e <readrec+0x20e>
pxor   %xmm1,%xmm1
xor    %esi,%esi
test   $0x1,%dl
je     138c <readrec+0x23c>
movd   (%r14,%rsi,1),%xmm2
movd   0x4(%r14,%rsi,1),%xmm3
pxor   %xmm4,%xmm4
punpcklbw %xmm4,%xmm2
punpcklwd %xmm4,%xmm2
psubd  %xmm2,%xmm0
punpcklbw %xmm4,%xmm3
punpcklwd %xmm4,%xmm3
psubd  %xmm3,%xmm1
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%r15d
cmp    %rcx,%rax
je     13bd <readrec+0x26d>
movzbl (%r14,%rax,1),%edx
sub    %edx,%r15d
add    $0x1,%rax
cmp    %rax,%rcx
jne    13ac <readrec+0x25c>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
movzbl %al,%ebx
movzbl %r15b,%ebp
cmp    %ebp,%ebx
je     11c9 <readrec+0x79>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
lea    0xd09(%rip),%rsi
xor    %r14d,%r14d
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11c9 <readrec+0x79>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"Improperly formatted OBJ file (1)\0A\00"
@.str.1 = [35 x i8] c"Improperly formatted OBJ file (2)\0A\00"
@.str.2 = [35 x i8] c"Improperly formatted OBJ file (3)\0A\00"
@.str.3 = [35 x i8] c"Improperly formatted OBJ file (4)\0A\00"
@.str.4 = [35 x i8] c"Improperly formatted OBJ file (5)\0A\00"
@.str.5 = [35 x i8] c"Out of memory allocating %d bytes\0A\00"
@.str.6 = [35 x i8] c"Improperly formatted OBJ file (6)\0A\00"
@.str.7 = [49 x i8] c"Bad record checksum, calculated=%d, recorded=%d\0A\00"
define i8* @readrec(i32* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 0, i32* %8
br label %10
10: ; preds = %21, %2
%11 = load i32*, i32** %4
%12 = call i32 @fgetc(i32* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 0
br label %19
19: ; preds = %16, %10
%20 = phi i1 [ false, %10 ], [ %18, %16 ]
br i1 %20, label %21, label %22
21: ; preds = %19
br label %10
22: ; preds = %19
%23 = load i32, i32* %6
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i8* null, i8** %3
br label %152
27: ; preds = %22
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %152
33: ; preds = %27
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = sub nsw i32 %35, %34
store i32 %36, i32* %8
%37 = load i32*, i32** %4
%38 = call i32 @fgetc(i32* %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %3
br label %152
44: ; preds = %33
%45 = load i32, i32* %6
%46 = load i32, i32* %8
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %8
%48 = load i32*, i32** %4
%49 = call i32 @fgetc(i32* %48)
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = load i32, i32* @EOF
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %44
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %152
56: ; preds = %44
%57 = load i32, i32* %6
%58 = load i32*, i32** %5
store i32 %57, i32* %58
%59 = load i32, i32* %6
%60 = load i32, i32* %8
%61 = sub nsw i32 %60, %59
store i32 %61, i32* %8
%62 = load i32*, i32** %4
%63 = call i32 @fgetc(i32* %62)
store i32 %63, i32* %6
%64 = load i32, i32* %6
%65 = load i32, i32* @EOF
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %56
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
store i8* null, i8** %3
br label %152
70: ; preds = %56
%71 = load i32, i32* %6
%72 = shl i32 %71, 8
%73 = load i32*, i32** %5
%74 = load i32, i32* %73
%75 = add nsw i32 %74, %72
store i32 %75, i32* %73
%76 = load i32, i32* %6
%77 = load i32, i32* %8
%78 = sub nsw i32 %77, %76
store i32 %78, i32* %8
%79 = load i32*, i32** %5
%80 = load i32, i32* %79
%81 = sub nsw i32 %80, 4
store i32 %81, i32* %79
%82 = load i32*, i32** %5
%83 = load i32, i32* %82
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %70
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
store i8* null, i8** %3
br label %152
88: ; preds = %70
%89 = load i32*, i32** %5
%90 = load i32, i32* %89
%91 = call i8* @malloc(i32 %90)
store i8* %91, i8** %9
%92 = load i8*, i8** %9
%93 = icmp eq i8* %92, null
br i1 %93, label %94, label %99
94: ; preds = %88
%95 = load i32, i32* @stderr
%96 = load i32*, i32** %5
%97 = load i32, i32* %96
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %97)
store i8* null, i8** %3
br label %152
99: ; preds = %88
%100 = load i8*, i8** %9
%101 = load i32*, i32** %5
%102 = load i32, i32* %101
%103 = load i32*, i32** %4
%104 = call i32 @fread(i8* %100, i32 1, i32 %102, i32* %103)
store i32 %104, i32* %7
%105 = load i32, i32* %7
%106 = load i32*, i32** %5
%107 = load i32, i32* %106
%108 = icmp slt i32 %105, %107
br i1 %108, label %109, label %114
109: ; preds = %99
%110 = load i8*, i8** %9
%111 = call i32 @free(i8* %110)
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
store i8* null, i8** %3
br label %152
114: ; preds = %99
store i32 0, i32* %7
br label %115
115: ; preds = %130, %114
%116 = load i32, i32* %7
%117 = load i32*, i32** %5
%118 = load i32, i32* %117
%119 = icmp slt i32 %116, %118
br i1 %119, label %120, label %133
120: ; preds = %115
%121 = load i8*, i8** %9
%122 = load i32, i32* %7
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %121, i64 %123
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = and i32 %126, 255
%128 = load i32, i32* %8
%129 = sub nsw i32 %128, %127
store i32 %129, i32* %8
br label %130
130: ; preds = %120
%131 = load i32, i32* %7
%132 = add nsw i32 %131, 1
store i32 %132, i32* %7
br label %115
133: ; preds = %115
%134 = load i32*, i32** %4
%135 = call i32 @fgetc(i32* %134)
store i32 %135, i32* %6
%136 = load i32, i32* %6
%137 = and i32 %136, 255
store i32 %137, i32* %6
%138 = load i32, i32* %8
%139 = and i32 %138, 255
store i32 %139, i32* %8
%140 = load i32, i32* %6
%141 = load i32, i32* %8
%142 = icmp ne i32 %140, %141
br i1 %142, label %143, label %150
143: ; preds = %133
%144 = load i8*, i8** %9
%145 = call i32 @free(i8* %144)
%146 = load i32, i32* @stderr
%147 = load i32, i32* %8
%148 = load i32, i32* %6
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 %147, i32 %148)
store i8* null, i8** %3
br label %152
150: ; preds = %133
%151 = load i8*, i8** %9
store i8* %151, i8** %3
br label %152
152: ; preds = %150, %143, %109, %94, %85, %67, %53, %41, %30, %26
%153 = load i8*, i8** %3
ret i8* %153
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"Improperly formatted OBJ file (1)\0A\00"
@.str.1 = [35 x i8] c"Improperly formatted OBJ file (2)\0A\00"
@.str.2 = [35 x i8] c"Improperly formatted OBJ file (3)\0A\00"
@.str.3 = [35 x i8] c"Improperly formatted OBJ file (4)\0A\00"
@.str.4 = [35 x i8] c"Improperly formatted OBJ file (5)\0A\00"
@.str.5 = [35 x i8] c"Out of memory allocating %d bytes\0A\00"
@.str.6 = [35 x i8] c"Improperly formatted OBJ file (6)\0A\00"
@.str.7 = [49 x i8] c"Bad record checksum, calculated=%d, recorded=%d\0A\00"
define noalias i8* @readrec(i32* nocapture %0, i32* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @fgetc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, 0
%7 = icmp ne i32 %5, 0
%8 = and i1 %6, %7
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = icmp eq i32 %4, %5
br i1 %10, label %151, label %11
11: ; preds = %9
%12 = icmp eq i32 %4, 1
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %151
16: ; preds = %11
%17 = tail call i32 @fgetc(i32* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %151
22: ; preds = %16
%23 = tail call i32 @fgetc(i32* %0)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %151
29: ; preds = %22
store i32 %23, i32* %1
%30 = tail call i32 @fgetc(i32* %0)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %151
36: ; preds = %29
%37 = xor i32 %23, -1
%38 = shl i32 %30, 8
%39 = load i32, i32* %1
%40 = add nsw i32 %39, %38
%41 = sub nsw i32 %37, %30
%42 = add nsw i32 %40, -4
store i32 %42, i32* %1
%43 = icmp slt i32 %40, 4
br i1 %43, label %44, label %47
44: ; preds = %36
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %151
47: ; preds = %36
%48 = tail call i8* @malloc(i32 %42)
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %151
53: ; preds = %47
%54 = tail call i32 @fread(i8* %48, i32 1, i32 %42, i32* %0)
%55 = load i32, i32* %1
%56 = icmp slt i32 %54, %55
br i1 %56, label %128, label %57
57: ; preds = %53
%58 = icmp sgt i32 %55, 0
br i1 %58, label %59, label %141
59: ; preds = %57
%60 = zext i32 %55 to i64
%61 = icmp ult i32 %55, 8
br i1 %61, label %125, label %62
62: ; preds = %59
%63 = and i64 %60, 4294967288
%64 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %41, i64 0
%65 = add nsw i64 %63, -8
%66 = lshr exact i64 %65, 3
%67 = add nuw nsw i64 %66, 1
%68 = and i64 %67, 1
%69 = icmp eq i64 %65, 0
br i1 %69, label %101, label %70
70: ; preds = %62
%71 = and i64 %67, 4611686018427387902
br label %72
72: ; preds = %72, %70
%73 = phi i64 [ 0, %70 ], [ %98, %72 ]
%74 = phi <4 x i32> [ %64, %70 ], [ %95, %72 ]
%75 = phi <4 x i32> [ zeroinitializer, %70 ], [ %97, %72 ]
%76 = phi i64 [ 0, %70 ], [ %99, %72 ]
%77 = getelementptr inbounds i8, i8* %48, i64 %73
%78 = bitcast i8* %77 to <4 x i8>*
%79 = load <4 x i8>, <4 x i8>* %78
%80 = getelementptr inbounds i8, i8* %77, i64 4
%81 = bitcast i8* %80 to <4 x i8>*
%82 = load <4 x i8>, <4 x i8>* %81
%83 = zext <4 x i8> %79 to <4 x i32>
%84 = zext <4 x i8> %82 to <4 x i32>
%85 = or i64 %73, 8
%86 = getelementptr inbounds i8, i8* %48, i64 %85
%87 = bitcast i8* %86 to <4 x i8>*
%88 = load <4 x i8>, <4 x i8>* %87
%89 = getelementptr inbounds i8, i8* %86, i64 4
%90 = bitcast i8* %89 to <4 x i8>*
%91 = load <4 x i8>, <4 x i8>* %90
%92 = zext <4 x i8> %88 to <4 x i32>
%93 = zext <4 x i8> %91 to <4 x i32>
%94 = add nuw nsw <4 x i32> %83, %92
%95 = sub <4 x i32> %74, %94
%96 = add nuw nsw <4 x i32> %84, %93
%97 = sub <4 x i32> %75, %96
%98 = add nuw i64 %73, 16
%99 = add i64 %76, 2
%100 = icmp eq i64 %99, %71
br i1 %100, label %101, label %72
101: ; preds = %72, %62
%102 = phi <4 x i32> [ undef, %62 ], [ %95, %72 ]
%103 = phi <4 x i32> [ undef, %62 ], [ %97, %72 ]
%104 = phi i64 [ 0, %62 ], [ %98, %72 ]
%105 = phi <4 x i32> [ %64, %62 ], [ %95, %72 ]
%106 = phi <4 x i32> [ zeroinitializer, %62 ], [ %97, %72 ]
%107 = icmp eq i64 %68, 0
br i1 %107, label %119, label %108
108: ; preds = %101
%109 = getelementptr inbounds i8, i8* %48, i64 %104
%110 = bitcast i8* %109 to <4 x i8>*
%111 = load <4 x i8>, <4 x i8>* %110
%112 = getelementptr inbounds i8, i8* %109, i64 4
%113 = bitcast i8* %112 to <4 x i8>*
%114 = load <4 x i8>, <4 x i8>* %113
%115 = zext <4 x i8> %111 to <4 x i32>
%116 = zext <4 x i8> %114 to <4 x i32>
%117 = sub <4 x i32> %105, %115
%118 = sub <4 x i32> %106, %116
br label %119
119: ; preds = %101, %108
%120 = phi <4 x i32> [ %102, %101 ], [ %117, %108 ]
%121 = phi <4 x i32> [ %103, %101 ], [ %118, %108 ]
%122 = add <4 x i32> %121, %120
%123 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %122)
%124 = icmp eq i64 %63, %60
br i1 %124, label %141, label %125
125: ; preds = %59, %119
%126 = phi i64 [ 0, %59 ], [ %63, %119 ]
%127 = phi i32 [ %41, %59 ], [ %123, %119 ]
br label %132
128: ; preds = %53
%129 = tail call i32 @free(i8* %48)
%130 = load i32, i32* @stderr
%131 = tail call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %151
132: ; preds = %125, %132
%133 = phi i64 [ %139, %132 ], [ %126, %125 ]
%134 = phi i32 [ %138, %132 ], [ %127, %125 ]
%135 = getelementptr inbounds i8, i8* %48, i64 %133
%136 = load i8, i8* %135
%137 = zext i8 %136 to i32
%138 = sub nsw i32 %134, %137
%139 = add nuw nsw i64 %133, 1
%140 = icmp eq i64 %139, %60
br i1 %140, label %141, label %132
141: ; preds = %132, %119, %57
%142 = phi i32 [ %41, %57 ], [ %123, %119 ], [ %138, %132 ]
%143 = tail call i32 @fgetc(i32* %0)
%144 = and i32 %143, 255
%145 = and i32 %142, 255
%146 = icmp eq i32 %144, %145
br i1 %146, label %151, label %147
147: ; preds = %141
%148 = tail call i32 @free(i8* %48)
%149 = load i32, i32* @stderr
%150 = tail call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 %145, i32 %144)
br label %151
151: ; preds = %141, %9, %147, %128, %50, %44, %33, %26, %19, %13
%152 = phi i8* [ null, %13 ], [ null, %19 ], [ null, %26 ], [ null, %33 ], [ null, %44 ], [ null, %50 ], [ null, %128 ], [ null, %147 ], [ null, %9 ], [ %48, %141 ]
ret i8* %152
}