#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *f1, *f2;
  int n1, n2, i, NoSuper = 0, NoZero = 0, OnlySuper = 0;
  unsigned char d1[2], d2[2];
  if (argc < 3) {
    printf("USAGE:\n"
           "\tbdiffhead AgcCoreFilename1 AgcCoreFilename2 [OPTIONS]\n"
           "A binary-compare of two files is performed, and a list of all\n"
           "differences is printed.  The files are supposed to represent\n"
           "AGC (Apollo Guidance Computer) core-ropes, consisting of 16-bit\n"
           "words. The output messages use the AGC addressing scheme.\n"
           "The available options are:\n"
           "--no-super     This option discards differences in which one\n"
           "               word has 100 (binary) in bit-positions 5,6,7\n"
           "               (the least-significant bit being position 1)\n"
           "               and 011 in the other word.\n"
           "--only-super   The opposite of the --no-super option.  Shows\n"
           "               ONLY differences involving 100 vs. 011 in \n"
           "               bits 5,6,7.\n"
           "--no-zero      This option discards differences in which the\n"
           "               word from the 2nd file is 00000.\n");
    return (1);
  }
  f1 = fopen(argv[1], "rb");
  if (f1 == NULL) {
    printf("Could not open file \"%s\".\n", argv[1]);
    return (1);
  }
  f2 = fopen(argv[2], "rb");
  if (f2 == NULL) {
    fclose(f1);
    printf("Could not open file \"%s\".\n", argv[2]);
    return (2);
  }
  for (n1 = 3; n1 < argc; n1++) {
    if (!strcmp(argv[n1], "--no-super"))
      NoSuper = 1;
    if (!strcmp(argv[n1], "--only-super"))
      OnlySuper = 1;
    else if (!strcmp(argv[n1], "--no-zero"))
      NoZero = 1;
    else
      printf("Unrecognized option \"%s\".\n", argv[n1]);
  }
  fseek(f1, 0, SEEK_END);
  fseek(f2, 0, SEEK_END);
  n1 = ftell(f1);
  n2 = ftell(f2);
  rewind(f1);
  rewind(f2);
  if (n1 != (2 * 044 * 02000) || n2 != (2 * 044 * 02000))
    printf("Improper file(s):  size of core-rope files should be %d.\n",
           (2 * 044 * 02000));
  while (1 == fread(d1, 2, 1, f1) && 1 == fread(d2, 2, 1, f2))
    if (d1[0] != d2[0] || d1[1] != d2[1]) {
      int Bank, Offset;
      n1 = (d1[0] << 7) | (d1[1] >> 1);
      n2 = (d2[0] << 7) | (d2[1] >> 1);
      if (NoZero && n2 == 0)
        continue;
      if (0160 == (0160 & (n1 ^ n2)) &&
          (0100 == (0160 & n1) || 0060 == (0160 & n1))) {
        if (NoSuper)
          continue;
      } else {
        if (OnlySuper)
          continue;
      }
      i = (ftell(f1) - 2) / 2;
      Offset = 02000 + (i % 02000);
      Bank = i / 02000;
      if (Bank < 4)
        Bank ^= 2;
      printf("0%06o (%02o,%04o", i, Bank, Offset);
      if (i < 04000)
        printf(" or %04o): ", i + 04000);
      else
        printf("):         ");
      printf("%05o %05o\n", n1, n2);
    }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11cf <main+0x4f>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    158b <main+0x40b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x114f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1214 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0x112f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    158b <main+0x40b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x110a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1262 <main+0xe2>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0x10e1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    158b <main+0x40b>
movl   $0x3,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1329 <main+0x1a9>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0x10c3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    129d <main+0x11d>
movl   $0x1,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0x10a6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12ca <main+0x14a>
movl   $0x1,-0x38(%rbp)
jmp    1316 <main+0x196>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0x1086(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12f7 <main+0x177>
movl   $0x1,-0x34(%rbp)
jmp    1311 <main+0x191>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0x1063(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1316 <main+0x196>
jmp    131b <main+0x19b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1269 <main+0xe9>
mov    -0x18(%rbp),%rdi
mov    0x2cb4(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
mov    0x2ca0(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
cmpl   $0x12000,-0x24(%rbp)
jne    1395 <main+0x215>
cmpl   $0x12000,-0x28(%rbp)
je     13a8 <main+0x228>
lea    0xfec(%rip),%rdi
mov    $0x12000,%esi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ad <main+0x22d>
lea    -0x3a(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x45(%rbp)
jne    13fe <main+0x27e>
lea    -0x3c(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    140e <main+0x28e>
jmp    1584 <main+0x404>
movzbl -0x3a(%rbp),%eax
movzbl -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jne    142e <main+0x2ae>
movzbl -0x39(%rbp),%eax
movzbl -0x3b(%rbp),%ecx
cmp    %ecx,%eax
je     157f <main+0x3ff>
movzbl -0x3a(%rbp),%eax
shl    $0x7,%eax
movzbl -0x39(%rbp),%ecx
sar    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
movzbl -0x3c(%rbp),%eax
shl    $0x7,%eax
movzbl -0x3b(%rbp),%ecx
sar    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     146d <main+0x2ed>
cmpl   $0x0,-0x28(%rbp)
jne    146d <main+0x2ed>
jmp    13ad <main+0x22d>
mov    -0x24(%rbp),%ecx
xor    -0x28(%rbp),%ecx
and    $0x70,%ecx
mov    $0x70,%eax
cmp    %ecx,%eax
jne    14bd <main+0x33d>
mov    -0x24(%rbp),%ecx
and    $0x70,%ecx
mov    $0x40,%eax
cmp    %ecx,%eax
je     14a9 <main+0x329>
mov    -0x24(%rbp),%ecx
and    $0x70,%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jne    14bd <main+0x33d>
cmpl   $0x0,-0x30(%rbp)
je     14b8 <main+0x338>
jmp    13ad <main+0x22d>
jmp    14d1 <main+0x351>
cmpl   $0x0,-0x38(%rbp)
je     14cc <main+0x34c>
jmp    13ad <main+0x22d>
jmp    14d1 <main+0x351>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
add    $0x400,%edx
mov    %edx,-0x44(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    151d <main+0x39d>
mov    -0x40(%rbp),%eax
xor    $0x2,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x44(%rbp),%ecx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x800,-0x2c(%rbp)
jge    155d <main+0x3dd>
mov    -0x2c(%rbp),%esi
add    $0x800,%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    156b <main+0x3eb>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ad <main+0x22d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jg     11b9 <main+0x29>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ecx
jmp    151f <main+0x38f>
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
lea    0xe37(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1361 <main+0x1d1>
mov    %rax,%r14
mov    0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     137d <main+0x1ed>
mov    %r14,0x20(%rsp)
xor    %r15d,%r15d
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
cmp    $0x4,%ebx
jb     12ba <main+0x12a>
mov    %ebx,%r13d
mov    $0x3,%r12d
lea    0xe00(%rip),%r14
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
xor    %r15d,%r15d
jmp    1251 <main+0xc1>
xchg   %ax,%ax
movl   $0x1,0x14(%rsp)
add    $0x1,%r12
cmp    %r12,%r13
je     12ba <main+0x12a>
mov    0x0(%rbp,%r12,8),%rbx
mov    %rbx,%rdi
lea    0xdbe(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
mov    $0x1,%eax
cmove  %eax,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1240 <main+0xb0>
mov    %rbx,%rdi
lea    0xdad(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12b0 <main+0x120>
lea    0xda7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1248 <main+0xb8>
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x1,0x10(%rsp)
jmp    1248 <main+0xb8>
mov    0x2d27(%rip),%rbp
mov    0x0(%rbp),%edx
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    0x0(%rbp),%edx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1090 <ftell@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1070 <rewind@plt>
mov    %rbp,%rdi
call   1070 <rewind@plt>
cmp    $0x12000,%r12d
jne    131d <main+0x18d>
cmp    $0x12000,%r14d
je     1330 <main+0x1a0>
lea    0xd37(%rip),%rdi
mov    $0x12000,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
jne    151f <main+0x38f>
mov    0x18(%rsp),%rbp
mov    0x10(%rsp),%r14d
jmp    1400 <main+0x270>
mov    0x8(%rbp),%rsi
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ecx
jmp    151f <main+0x38f>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x10(%rbp),%rsi
lea    0xc73(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%ecx
jmp    151f <main+0x38f>
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd08(%rip),%rdi
mov    %r13d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%rbx
mov    0x18(%rsp),%rbp
mov    0x10(%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    151d <main+0x38d>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    151d <main+0x38d>
movzbl 0xc(%rsp),%r13d
movzbl 0xe(%rsp),%r12d
movzbl 0xd(%rsp),%eax
movzbl 0xf(%rsp),%ecx
cmp    %r12b,%r13b
jne    143f <main+0x2af>
cmp    %cl,%al
je     13e0 <main+0x250>
movzbl %cl,%ecx
shl    $0x7,%r12d
shr    %ecx
or     %ecx,%r12d
test   %r14d,%r14d
je     1455 <main+0x2c5>
test   %r12d,%r12d
je     13e0 <main+0x250>
movzbl %al,%eax
shr    %eax
xor    %al,%cl
not    %cl
test   $0x70,%cl
jne    147d <main+0x2ed>
mov    %eax,%ecx
and    $0xfffffff0,%ecx
cmp    $0x40,%ecx
je     1472 <main+0x2e2>
cmp    $0x30,%ecx
jne    147d <main+0x2ed>
test   %r15d,%r15d
jne    13e0 <main+0x250>
jmp    1488 <main+0x2f8>
cmpl   $0x0,0x14(%rsp)
jne    13e0 <main+0x250>
shl    $0x7,%r13d
or     %eax,%r13d
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %eax,%r14d
lea    -0x2(%r14),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
lea    (%r14,%rcx,1),%ebx
add    $0xfffffffe,%ebx
sar    %ebx
lea    0x3ff(%rbx),%ecx
test   %ebx,%ebx
cmovns %ebx,%ecx
and    $0xfffffc00,%ecx
neg    %ecx
add    %ebx,%ecx
add    $0x400,%ecx
lea    0x7fd(%r14),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xb,%esi
mov    %esi,%edx
xor    $0x2,%edx
cmp    $0x2002,%r14d
cmovge %esi,%edx
lea    0xba9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x1001,%r14d
jg     13a1 <main+0x211>
add    $0x800,%ebx
lea    0xb97(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13af <main+0x21f>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [813 x i8] c"USAGE:\0A\09bdiffhead AgcCoreFilename1 AgcCoreFilename2 [OPTIONS]\0AA binary-compare of two files is performed, and a list of all\0Adifferences is printed. The files are supposed to represent\0AAGC (Apollo Guidance Computer) core-ropes, consisting of 16-bit\0Awords. The output messages use the AGC addressing scheme.\0AThe available options are:\0A--no-super This option discards differences in which one\0A word has 100 (binary) in bit-positions 5,6,7\0A (the least-significant bit being position 1)\0A and 011 in the other word.\0A--only-super The opposite of the --no-super option. Shows\0A ONLY differences involving 100 vs. 011 in \0A bits 5,6,7.\0A--no-zero This option discards differences in which the\0A word from the 2nd file is 00000.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [27 x i8] c"Could not open file \22%s\22.\0A\00"
@.str.3 = [11 x i8] c"--no-super\00"
@.str.4 = [13 x i8] c"--only-super\00"
@.str.5 = [10 x i8] c"--no-zero\00"
@.str.6 = [27 x i8] c"Unrecognized option \22%s\22.\0A\00"
@SEEK_END = global i32 0
@.str.7 = [58 x i8] c"Improper file(s): size of core-rope files should be %d.\0A\00"
@.str.8 = [17 x i8] c"0%06o (%02o,%04o\00"
@.str.9 = [12 x i8] c" or %04o): \00"
@.str.10 = [12 x i8] c"): \00"
@.str.11 = [11 x i8] c"%05o %05o\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2 x i8]
%15 = alloca [2 x i8]
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([813 x i8], [813 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %226
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %32)
store i32 1, i32* %3
br label %226
34: ; preds = %22
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %7
%39 = load i32*, i32** %7
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i32*, i32** %6
%43 = call i32 @fclose(i32* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %46)
store i32 2, i32* %3
br label %226
48: ; preds = %34
store i32 3, i32* %8
br label %49
49: ; preds = %89, %48
%50 = load i32, i32* %8
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %92
53: ; preds = %49
%54 = load i8**, i8*** %5
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %53
store i32 1, i32* %11
br label %62
62: ; preds = %61, %53
%63 = load i8**, i8*** %5
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %62
store i32 1, i32* %13
br label %88
71: ; preds = %62
%72 = load i8**, i8*** %5
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = call i32 @strcmp(i8* %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %80, label %79
79: ; preds = %71
store i32 1, i32* %12
br label %87
80: ; preds = %71
%81 = load i8**, i8*** %5
%82 = load i32, i32* %8
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %80, %79
br label %88
88: ; preds = %87, %70
br label %89
89: ; preds = %88
%90 = load i32, i32* %8
%91 = add nsw i32 %90, 1
store i32 %91, i32* %8
br label %49
92: ; preds = %49
%93 = load i32*, i32** %6
%94 = load i32, i32* @SEEK_END
%95 = call i32 @fseek(i32* %93, i32 0, i32 %94)
%96 = load i32*, i32** %7
%97 = load i32, i32* @SEEK_END
%98 = call i32 @fseek(i32* %96, i32 0, i32 %97)
%99 = load i32*, i32** %6
%100 = call i32 @ftell(i32* %99)
store i32 %100, i32* %8
%101 = load i32*, i32** %7
%102 = call i32 @ftell(i32* %101)
store i32 %102, i32* %9
%103 = load i32*, i32** %6
%104 = call i32 @rewind(i32* %103)
%105 = load i32*, i32** %7
%106 = call i32 @rewind(i32* %105)
%107 = load i32, i32* %8
%108 = icmp ne i32 %107, 73728
br i1 %108, label %112, label %109
109: ; preds = %92
%110 = load i32, i32* %9
%111 = icmp ne i32 %110, 73728
br i1 %111, label %112, label %114
112: ; preds = %109, %92
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i32 73728)
br label %114
114: ; preds = %112, %109
br label %115
115: ; preds = %224, %190, %185, %167, %114
%116 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%117 = load i32*, i32** %6
%118 = call i32 @fread(i8* %116, i32 2, i32 1, i32* %117)
%119 = icmp eq i32 1, %118
br i1 %119, label %120, label %125
120: ; preds = %115
%121 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%122 = load i32*, i32** %7
%123 = call i32 @fread(i8* %121, i32 2, i32 1, i32* %122)
%124 = icmp eq i32 1, %123
br label %125
125: ; preds = %120, %115
%126 = phi i1 [ false, %115 ], [ %124, %120 ]
br i1 %126, label %127, label %225
127: ; preds = %125
%128 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = icmp ne i32 %130, %133
br i1 %134, label %143, label %135
135: ; preds = %127
%136 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
%137 = load i8, i8* %136
%138 = zext i8 %137 to i32
%139 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 1
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp ne i32 %138, %141
br i1 %142, label %143, label %224
143: ; preds = %135, %127
%144 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%145 = load i8, i8* %144
%146 = zext i8 %145 to i32
%147 = shl i32 %146, 7
%148 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
%149 = load i8, i8* %148
%150 = zext i8 %149 to i32
%151 = ashr i32 %150, 1
%152 = or i32 %147, %151
store i32 %152, i32* %8
%153 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%154 = load i8, i8* %153
%155 = zext i8 %154 to i32
%156 = shl i32 %155, 7
%157 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 1
%158 = load i8, i8* %157
%159 = zext i8 %158 to i32
%160 = ashr i32 %159, 1
%161 = or i32 %156, %160
store i32 %161, i32* %9
%162 = load i32, i32* %12
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %143
%165 = load i32, i32* %9
%166 = icmp eq i32 %165, 0
br i1 %166, label %167, label %168
167: ; preds = %164
br label %115
168: ; preds = %164, %143
%169 = load i32, i32* %8
%170 = load i32, i32* %9
%171 = xor i32 %169, %170
%172 = and i32 112, %171
%173 = icmp eq i32 112, %172
br i1 %173, label %174, label %187
174: ; preds = %168
%175 = load i32, i32* %8
%176 = and i32 112, %175
%177 = icmp eq i32 64, %176
br i1 %177, label %182, label %178
178: ; preds = %174
%179 = load i32, i32* %8
%180 = and i32 112, %179
%181 = icmp eq i32 48, %180
br i1 %181, label %182, label %187
182: ; preds = %178, %174
%183 = load i32, i32* %11
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %186
185: ; preds = %182
br label %115
186: ; preds = %182
br label %192
187: ; preds = %178, %168
%188 = load i32, i32* %13
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %191
190: ; preds = %187
br label %115
191: ; preds = %187
br label %192
192: ; preds = %191, %186
%193 = load i32*, i32** %6
%194 = call i32 @ftell(i32* %193)
%195 = sub nsw i32 %194, 2
%196 = sdiv i32 %195, 2
store i32 %196, i32* %10
%197 = load i32, i32* %10
%198 = srem i32 %197, 1024
%199 = add nsw i32 1024, %198
store i32 %199, i32* %17
%200 = load i32, i32* %10
%201 = sdiv i32 %200, 1024
store i32 %201, i32* %16
%202 = load i32, i32* %16
%203 = icmp slt i32 %202, 4
br i1 %203, label %204, label %207
204: ; preds = %192
%205 = load i32, i32* %16
%206 = xor i32 %205, 2
store i32 %206, i32* %16
br label %207
207: ; preds = %204, %192
%208 = load i32, i32* %10
%209 = load i32, i32* %16
%210 = load i32, i32* %17
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %208, i32 %209, i32 %210)
%212 = load i32, i32* %10
%213 = icmp slt i32 %212, 2048
br i1 %213, label %214, label %218
214: ; preds = %207
%215 = load i32, i32* %10
%216 = add nsw i32 %215, 2048
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %216)
br label %220
218: ; preds = %207
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %220
220: ; preds = %218, %214
%221 = load i32, i32* %8
%222 = load i32, i32* %9
%223 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %221, i32 %222)
br label %224
224: ; preds = %220, %135
br label %115
225: ; preds = %125
store i32 0, i32* %3
br label %226
226: ; preds = %225, %41, %29, %20
%227 = load i32, i32* %3
ret i32 %227
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [27 x i8] c"Could not open file \22%s\22.\0A\00"
@.str.3 = [11 x i8] c"--no-super\00"
@.str.4 = [13 x i8] c"--only-super\00"
@.str.5 = [10 x i8] c"--no-zero\00"
@.str.6 = [27 x i8] c"Unrecognized option \22%s\22.\0A\00"
@SEEK_END = global i32 0
@.str.7 = [58 x i8] c"Improper file(s): size of core-rope files should be %d.\0A\00"
@.str.8 = [17 x i8] c"0%06o (%02o,%04o\00"
@.str.9 = [12 x i8] c" or %04o): \00"
@.str.10 = [12 x i8] c"): \00"
@.str.11 = [11 x i8] c"%05o %05o\0A\00"
@str = [812 x i8] c"USAGE:\0A\09bdiffhead AgcCoreFilename1 AgcCoreFilename2 [OPTIONS]\0AA binary-compare of two files is performed, and a list of all\0Adifferences is printed. The files are supposed to represent\0AAGC (Apollo Guidance Computer) core-ropes, consisting of 16-bit\0Awords. The output messages use the AGC addressing scheme.\0AThe available options are:\0A--no-super This option discards differences in which one\0A word has 100 (binary) in bit-positions 5,6,7\0A (the least-significant bit being position 1)\0A and 011 in the other word.\0A--only-super The opposite of the --no-super option. Shows\0A ONLY differences involving 100 vs. 011 in \0A bits 5,6,7.\0A--no-zero This option discards differences in which the\0A word from the 2nd file is 00000.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8]
%4 = alloca [2 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([812 x i8], [812 x i8]* @str, i64 0, i64 0))
br label %133
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %133
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = icmp ugt i32 %0, 3
br i1 %24, label %25, label %53
25: ; preds = %23
%26 = zext i32 %0 to i64
br label %31
27: ; preds = %18
%28 = tail call i32 @fclose(i32* %13)
%29 = load i8*, i8** %19
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %133
31: ; preds = %25, %48
%32 = phi i64 [ 3, %25 ], [ %51, %48 ]
%33 = phi i32 [ 0, %25 ], [ %50, %48 ]
%34 = phi i32 [ 0, %25 ], [ %49, %48 ]
%35 = phi i32 [ 0, %25 ], [ %40, %48 ]
%36 = getelementptr inbounds i8*, i8** %1, i64 %32
%37 = load i8*, i8** %36
%38 = tail call i32 @strcmp(i8* dereferenceable(1) %37, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i32 1, i32 %35
%41 = tail call i32 @strcmp(i8* dereferenceable(1) %37, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %31
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %37, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %37)
br label %48
48: ; preds = %43, %31, %46
%49 = phi i32 [ %34, %46 ], [ %34, %31 ], [ 1, %43 ]
%50 = phi i32 [ %33, %46 ], [ 1, %31 ], [ %33, %43 ]
%51 = add nuw nsw i64 %32, 1
%52 = icmp eq i64 %51, %26
br i1 %52, label %53, label %31
53: ; preds = %48, %23
%54 = phi i32 [ 0, %23 ], [ %40, %48 ]
%55 = phi i32 [ 0, %23 ], [ %49, %48 ]
%56 = phi i32 [ 0, %23 ], [ %50, %48 ]
%57 = load i32, i32* @SEEK_END
%58 = tail call i32 @fseek(i32* %13, i32 0, i32 %57)
%59 = load i32, i32* @SEEK_END
%60 = tail call i32 @fseek(i32* %21, i32 0, i32 %59)
%61 = tail call i32 @ftell(i32* %13)
%62 = tail call i32 @ftell(i32* %21)
%63 = tail call i32 @rewind(i32* %13)
%64 = tail call i32 @rewind(i32* %21)
%65 = icmp ne i32 %61, 73728
%66 = icmp ne i32 %62, 73728
%67 = or i1 %65, %66
br i1 %67, label %68, label %70
68: ; preds = %53
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i32 73728)
br label %70
70: ; preds = %53, %68
%71 = call i32 @fread(i8* %5, i32 2, i32 1, i32* %13)
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %133
73: ; preds = %70
%74 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%75 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%76 = icmp ne i32 %55, 0
%77 = icmp eq i32 %54, 0
%78 = icmp eq i32 %56, 0
br label %79
79: ; preds = %73, %130
%80 = call i32 @fread(i8* %6, i32 2, i32 1, i32* %21)
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %133
82: ; preds = %79
%83 = load i8, i8* %5
%84 = load i8, i8* %6
%85 = icmp eq i8 %83, %84
%86 = load i8, i8* %74
%87 = load i8, i8* %75
%88 = icmp eq i8 %86, %87
%89 = select i1 %85, i1 %88, i1 false
br i1 %89, label %130, label %90
90: ; preds = %82
%91 = zext i8 %83 to i32
%92 = shl nuw nsw i32 %91, 7
%93 = lshr i8 %86, 1
%94 = zext i8 %93 to i32
%95 = or i32 %92, %94
%96 = zext i8 %84 to i32
%97 = shl nuw nsw i32 %96, 7
%98 = lshr i8 %87, 1
%99 = zext i8 %98 to i32
%100 = or i32 %97, %99
%101 = icmp eq i32 %100, 0
%102 = select i1 %76, i1 %101, i1 false
br i1 %102, label %130, label %103
103: ; preds = %90
%104 = xor i8 %98, %93
%105 = and i8 %104, 112
%106 = icmp eq i8 %105, 112
br i1 %106, label %107, label %110
107: ; preds = %103
%108 = and i32 %94, 112
switch i32 %108, label %110 [
i32 64, label %109
i32 48, label %109
]
109: ; preds = %107, %107
br i1 %77, label %111, label %130
110: ; preds = %107, %103
br i1 %78, label %111, label %130
111: ; preds = %110, %109
%112 = tail call i32 @ftell(i32* %13)
%113 = add nsw i32 %112, -2
%114 = sdiv i32 %113, 2
%115 = srem i32 %114, 1024
%116 = add nsw i32 %115, 1024
%117 = sdiv i32 %113, 2048
%118 = icmp slt i32 %112, 8194
%119 = xor i32 %117, 2
%120 = select i1 %118, i32 %119, i32 %117
%121 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %114, i32 %120, i32 %116)
%122 = icmp slt i32 %112, 4098
br i1 %122, label %123, label %126
123: ; preds = %111
%124 = add nsw i32 %114, 2048
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %124)
br label %128
126: ; preds = %111
%127 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %128
128: ; preds = %123, %126
%129 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %95, i32 %100)
br label %130
130: ; preds = %82, %128, %90, %109, %110
%131 = call i32 @fread(i8* %5, i32 2, i32 1, i32* %13)
%132 = icmp eq i32 %131, 1
br i1 %132, label %79, label %133
133: ; preds = %130, %79, %70, %27, %15, %8
%134 = phi i32 [ 1, %8 ], [ 1, %15 ], [ 2, %27 ], [ 0, %70 ], [ 0, %79 ], [ 0, %130 ]
ret i32 %134
}