#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 uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ SEEK_SET;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(int *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int fwrite(int *, int, int, int /*<<< orphan*/ *);
char getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  FILE *fp;
  uint32_t buf[7];
  uint32_t crc = 0;
  uint32_t magic[] = {0x0, 0x12345678, 0x87654321, 0x43218765, 0x4e697370};
  uint32_t crp;
  char *prog;
  char c;
  char verbose = 0;
  char do_crc = 0;
  int do_crp = -1;
  prog = argv[0];
  if (!prog)
    prog = "lpcfix";
  if (strrchr(prog, '/')) {
    prog = strrchr(argv[0], '/');
    prog++;
  }
  while ((c = getopt(argc, argv, "vcp:nh")) != (char)EOF)
    switch (c) {
    case 'c':
      do_crc = 1;
      break;
    case 'v':
      verbose++;
      break;
    case 'p':
      do_crp = atoi(optarg);
      break;
    case 'h':
    default:
      fprintf(
          stderr,
          "Usage: %s [options]\n\n"
          "This program fixes the CRC field for LPC firmware and optionally\n"
          "enables/disables the content read protection flags\n"
          "\n\n"
          "-n           Do not change CRC information\n"
          "-c           Fix CRC\n"
          "-v           Be verbose (-v -v = even more)\n"
          "-p mode      Enable CRP (Content read protection) mode\n"
          "-h           This help\n\n"
          "CRP modes valid:\n"
          "0            Disable CRP\n"
          "1-3          Enable CRP 1-3\n"
          "4            Enable NO_ISP\n"
          "\n",
          prog);
      exit(255);
    }
  argc -= optind;
  argv += optind;
  if (argc != 1) {
    fprintf(stderr, "Error: No filename given!\n");
    exit(254);
  };
  if (do_crp > 4) {
    fprintf(stderr, "CRP %d is not allowed\n", do_crp);
    exit(254);
  };
  if ((fp = fopen(argv[0], "r+b")) == NULL) {
    fprintf(stderr, "Error: Can't open file %s\n", argv[0]);
    exit(253);
  }
  if (do_crc) {
    if (fread(buf, sizeof(uint32_t), 7, fp) != 7) {
      fprintf(stderr, "Error: Read failed\n");
      exit(253);
    }
    int idx;
    for (idx = 0; idx < 7; idx++) {
      crc += buf[idx];
    }
    crc = (~crc) + 1;
    if (verbose)
      printf("New CRC is:    0x%08x\n", crc);
    if (fseek(fp, 7 * sizeof(uint32_t), SEEK_SET) != 0) {
      fprintf(stderr, "Error: Seek failed\n");
      exit(253);
    }
    if (do_crc)
      if (fwrite(&crc, sizeof(uint32_t), 1, fp) != 1) {
        fprintf(stderr, "Error: CRC write failed\n");
        exit(253);
      }
  };
  if (verbose) {
    if (fseek(fp, 0x2fc, SEEK_SET) != 0) {
      fprintf(stderr, "Error: CRP Seek failed\n");
      exit(253);
    }
    if (fread(&crp, sizeof(uint32_t), 1, fp) != 1) {
      fprintf(stderr, "Error: CRP Read failed\n");
      exit(253);
    }
    int idx;
    for (idx = 1; idx <= 4; idx++) {
      if (crp == magic[idx])
        break;
    }
    if (idx > 4)
      idx = 0;
    printf("Curent CRP:    0x%08x (%d)\n", crp, idx);
  };
  if (do_crp != -1) {
    crp = magic[do_crp];
    if (fseek(fp, 0x2fc, SEEK_SET) != 0) {
      fprintf(stderr, "Error: CRP Seek failed\n");
      exit(253);
    }
    if (fwrite(&crp, sizeof(uint32_t), 1, fp) != 1) {
      fprintf(stderr, "Error: CRP Write failed\n");
      exit(253);
    }
    printf("New CRP value: 0x%08x\n", crp);
  };
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
mov    0xe79(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe76(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe74(%rip),%eax
mov    %eax,-0x50(%rbp)
movb   $0x0,-0x72(%rbp)
movb   $0x0,-0x73(%rbp)
movl   $0xffffffff,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    121f <main+0x6f>
lea    0xe49(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
cmp    $0x0,%rax
je     1258 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    125d <main+0xad>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe00(%rip),%rdx
call   10a0 <getopt@plt>
mov    %al,-0x71(%rbp)
movsbl %al,%eax
mov    0x2d63(%rip),%rcx
mov    (%rcx),%rcx
movsbl %cl,%ecx
cmp    %ecx,%eax
je     1316 <main+0x166>
movsbl -0x71(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x88(%rbp)
sub    $0x13,%eax
ja     12ec <main+0x13c>
mov    -0x88(%rbp),%rax
lea    0xd4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x73(%rbp)
jmp    1311 <main+0x161>
mov    -0x72(%rbp),%al
add    $0x1,%al
mov    %al,-0x72(%rbp)
jmp    1311 <main+0x161>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,-0x78(%rbp)
jmp    1311 <main+0x161>
jmp    12ec <main+0x13c>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rdx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xff,%edi
call   10c0 <exit@plt>
jmp    125d <main+0xad>
mov    0x2cbb(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2ca7(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     136b <main+0x1bb>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfe,%edi
call   10c0 <exit@plt>
cmpl   $0x4,-0x78(%rbp)
jle    1399 <main+0x1e9>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%edx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfe,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea6(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    13e2 <main+0x232>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
cmpb   $0x0,-0x73(%rbp)
je     1518 <main+0x368>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
mov    $0x7,%edx
call   1030 <fread@plt>
cmp    $0x7,%eax
je     142d <main+0x27d>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x7,-0x7c(%rbp)
jge    145a <main+0x2aa>
movslq -0x7c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1434 <main+0x284>
mov    -0x44(%rbp),%eax
xor    $0xffffffff,%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpb   $0x0,-0x72(%rbp)
je     1481 <main+0x2d1>
mov    -0x44(%rbp),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2b34(%rip),%rax
mov    (%rax),%edx
mov    $0x1c,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     14c3 <main+0x313>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
cmpb   $0x0,-0x73(%rbp)
je     1513 <main+0x363>
mov    -0x18(%rbp),%rcx
lea    -0x44(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
je     150e <main+0x35e>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
jmp    1513 <main+0x363>
jmp    1518 <main+0x368>
cmpb   $0x0,-0x72(%rbp)
je     1604 <main+0x454>
mov    -0x18(%rbp),%rdi
mov    0x2a93(%rip),%rax
mov    (%rax),%edx
mov    $0x2fc,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     1564 <main+0x3b4>
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
lea    0xd71(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rcx
lea    -0x64(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     15a5 <main+0x3f5>
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
movl   $0x1,-0x80(%rbp)
cmpl   $0x4,-0x80(%rbp)
jg     15df <main+0x42f>
mov    -0x64(%rbp),%eax
movslq -0x80(%rbp),%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
jne    15cc <main+0x41c>
jmp    15df <main+0x42f>
jmp    15d1 <main+0x421>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    15ac <main+0x3fc>
cmpl   $0x4,-0x80(%rbp)
jle    15f0 <main+0x440>
movl   $0x0,-0x80(%rbp)
mov    -0x64(%rbp),%esi
mov    -0x80(%rbp),%edx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0xffffffff,-0x78(%rbp)
je     16ad <main+0x4fd>
movslq -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x299c(%rip),%rax
mov    (%rax),%edx
mov    $0x2fc,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     165b <main+0x4ab>
mov    0x2987(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rcx
lea    -0x64(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
je     169c <main+0x4ec>
mov    0x2946(%rip),%rax
mov    (%rax),%edi
lea    0xc85(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
mov    -0x64(%rbp),%esi
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
mov    (%rsi),%r14
test   %r14,%r14
lea    0xe44(%rip),%rbp
cmovne %r14,%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     11fa <main+0x4a>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%rbp
add    $0x1,%rbp
lea    0xe1a(%rip),%rdx
mov    %ebx,%edi
mov    %r13,%rsi
call   10a0 <getopt@plt>
movsbl %al,%eax
mov    0x2dcb(%rip),%r15
movsbl (%r15),%ecx
cmp    %eax,%ecx
jne    1242 <main+0x92>
mov    0x2db4(%rip),%rax
mov    (%rax),%r15
sub    %r15d,%ebx
cmp    $0x1,%ebx
jne    14f2 <main+0x342>
mov    $0xffffffff,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    12df <main+0x12f>
mov    %rbp,0x30(%rsp)
mov    $0xffffffff,%r14d
movl   $0x0,0x8(%rsp)
lea    0xdbf(%rip),%r12
xor    %ebp,%ebp
jmp    1289 <main+0xd9>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   10a0 <getopt@plt>
movsbl %al,%eax
movsbl (%r15),%ecx
cmp    %eax,%ecx
je     12b8 <main+0x108>
cmp    $0x63,%eax
je     12b0 <main+0x100>
cmp    $0x70,%eax
je     1260 <main+0xb0>
cmp    $0x76,%eax
jne    14b7 <main+0x307>
add    $0x1,%bpl
jmp    1271 <main+0xc1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%al
mov    %eax,0x8(%rsp)
jmp    1271 <main+0xc1>
mov    0x2d19(%rip),%rax
mov    (%rax),%r15
sub    %r15d,%ebx
cmp    $0x1,%ebx
jne    14f2 <main+0x342>
mov    %r14d,%r12d
cmp    $0x5,%r14d
jge    15a2 <main+0x3f2>
mov    0x8(%rsp),%ebx
mov    0x0(%r13,%r15,8),%rdi
lea    0xf12(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1513 <main+0x363>
mov    %rax,%r14
test   %bl,%bl
je     1398 <main+0x1e8>
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    $0x7,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x7,%eax
jne    1539 <main+0x389>
mov    0x10(%rsp),%esi
add    0x14(%rsp),%esi
add    0x18(%rsp),%esi
add    0x1c(%rsp),%esi
add    0x20(%rsp),%esi
add    0x24(%rsp),%esi
add    0x28(%rsp),%esi
neg    %esi
mov    %esi,0xc(%rsp)
test   %bpl,%bpl
je     1359 <main+0x1a9>
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c60(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x1c,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    154b <main+0x39b>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
jne    155d <main+0x3ad>
test   %bpl,%bpl
je     143a <main+0x28a>
mov    0x2c18(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x2fc,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    14dd <main+0x32d>
lea    0x4(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    156f <main+0x3bf>
mov    0x4(%rsp),%esi
cmp    $0x43218764,%esi
jg     1403 <main+0x253>
cmp    $0x87654321,%esi
je     141a <main+0x26a>
cmp    $0x12345678,%esi
je     142a <main+0x27a>
jmp    1428 <main+0x278>
cmp    $0x43218765,%esi
je     1421 <main+0x271>
cmp    $0x4e697370,%esi
jne    1428 <main+0x278>
mov    $0x4,%ebp
jmp    142a <main+0x27a>
mov    $0x2,%ebp
jmp    142a <main+0x27a>
mov    $0x3,%ebp
jmp    142a <main+0x27a>
xor    %ebp,%ebp
lea    0xe73(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xffffffff,%r12d
je     149e <main+0x2ee>
movslq %r12d,%rax
lea    0xbb6(%rip),%rcx
mov    (%rcx,%rax,4),%eax
mov    %eax,0x4(%rsp)
mov    0x2b68(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x2fc,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    14dd <main+0x32d>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
jne    1581 <main+0x3d1>
mov    0x4(%rsp),%esi
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
lea    0xb5b(%rip),%rsi
mov    0x30(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xff,%edi
call   10c0 <exit@plt>
mov    0x2ae4(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
jmp    1591 <main+0x3e1>
mov    0x2acf(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xfe,%edi
call   10c0 <exit@plt>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%r15,8),%rdx
lea    0xcd9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
mov    0x2a88(%rip),%rax
mov    (%rax),%edi
lea    0xcd3(%rip),%rsi
jmp    1591 <main+0x3e1>
mov    0x2a76(%rip),%rax
mov    (%rax),%edi
lea    0xcec(%rip),%rsi
jmp    1591 <main+0x3e1>
mov    0x2a64(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
jmp    1591 <main+0x3e1>
mov    0x2a52(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
jmp    1591 <main+0x3e1>
mov    0x2a40(%rip),%rax
mov    (%rax),%edi
lea    0xd2f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xfd,%edi
call   10c0 <exit@plt>
mov    0x2a1f(%rip),%rax
mov    (%rax),%edi
lea    0xc34(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xfe,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@__const.main.magic = [5 x i32] [i32 0, i32 305419896, i32 -2023406815, i32 1126270821, i32 1315533680]
@.str = [7 x i8] c"lpcfix\00"
@.str.1 = [7 x i8] c"vcp:nh\00"
@EOF = global i64 0
@optarg = global i32 0
@stderr = global i32 0
@.str.2 = [425 x i8] c"Usage: %s [options]\0A\0AThis program fixes the CRC field for LPC firmware and optionally\0Aenables/disables the content read protection flags\0A\0A\0A-n Do not change CRC information\0A-c Fix CRC\0A-v Be verbose (-v -v = even more)\0A-p mode Enable CRP (Content read protection) mode\0A-h This help\0A\0ACRP modes valid:\0A0 Disable CRP\0A1-3 Enable CRP 1-3\0A4 Enable NO_ISP\0A\0A\00"
@optind = global i64 0
@.str.3 = [27 x i8] c"Error: No filename given!\0A\00"
@.str.4 = [23 x i8] c"CRP %d is not allowed\0A\00"
@.str.5 = [4 x i8] c"r+b\00"
@.str.6 = [27 x i8] c"Error: Can't open file %s\0A\00"
@.str.7 = [20 x i8] c"Error: Read failed\0A\00"
@.str.8 = [23 x i8] c"New CRC is: 0x%08x\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [20 x i8] c"Error: Seek failed\0A\00"
@.str.10 = [25 x i8] c"Error: CRC write failed\0A\00"
@.str.11 = [24 x i8] c"Error: CRP Seek failed\0A\00"
@.str.12 = [24 x i8] c"Error: CRP Read failed\0A\00"
@.str.13 = [28 x i8] c"Curent CRP: 0x%08x (%d)\0A\00"
@.str.14 = [25 x i8] c"Error: CRP Write failed\0A\00"
@.str.15 = [23 x i8] c"New CRP value: 0x%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [7 x i32]
%8 = alloca i32
%9 = alloca [5 x i32]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
%15 = alloca i32
%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* %8
%18 = bitcast [5 x i32]* %9 to i8*
store i8 0, i8* %13
store i8 0, i8* %14
store i32 -1, i32* %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
store i8* %21, i8** %11
%22 = load i8*, i8** %11
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %11
br label %25
25: ; preds = %24, %2
%26 = load i8*, i8** %11
%27 = call i8* @strrchr(i8* %26, i8 signext 47)
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i8* @strrchr(i8* %32, i8 signext 47)
store i8* %33, i8** %11
%34 = load i8*, i8** %11
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %11
br label %36
36: ; preds = %29, %25
br label %37
37: ; preds = %62, %36
%38 = load i32, i32* %4
%39 = load i8**, i8*** %5
%40 = call signext i8 @getopt(i32 %38, i8** %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i8 %40, i8* %12
%41 = sext i8 %40 to i32
%42 = load i64, i64* @EOF
%43 = trunc i64 %42 to i8
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %41, %44
br i1 %45, label %46, label %63
46: ; preds = %37
%47 = load i8, i8* %12
%48 = sext i8 %47 to i32
switch i32 %48, label %57 [
i32 99, label %49
i32 118, label %50
i32 112, label %53
i32 104, label %56
]
49: ; preds = %46
store i8 1, i8* %14
br label %62
50: ; preds = %46
%51 = load i8, i8* %13
%52 = add i8 %51, 1
store i8 %52, i8* %13
br label %62
53: ; preds = %46
%54 = load i32, i32* @optarg
%55 = call i32 @atoi(i32 %54)
store i32 %55, i32* %15
br label %62
56: ; preds = %46
br label %57
57: ; preds = %46, %56
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %11
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([425 x i8], [425 x i8]* @.str.2, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 255)
unreachable
62: ; preds = %53, %50, %49
br label %37
63: ; preds = %37
%64 = load i64, i64* @optind
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = sub nsw i64 %66, %64
%68 = trunc i64 %67 to i32
store i32 %68, i32* %4
%69 = load i64, i64* @optind
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 %69
store i8** %71, i8*** %5
%72 = load i32, i32* %4
%73 = icmp ne i32 %72, 1
br i1 %73, label %74, label %78
74: ; preds = %63
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%77 = call i32 @exit(i32 254)
unreachable
78: ; preds = %63
%79 = load i32, i32* %15
%80 = icmp sgt i32 %79, 4
br i1 %80, label %81, label %86
81: ; preds = %78
%82 = load i32, i32* @stderr
%83 = load i32, i32* %15
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %83)
%85 = call i32 @exit(i32 254)
unreachable
86: ; preds = %78
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 0
%89 = load i8*, i8** %88
%90 = call i32* @fopen(i8* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32* %90, i32** %6
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %99
92: ; preds = %86
%93 = load i32, i32* @stderr
%94 = load i8**, i8*** %5
%95 = getelementptr inbounds i8*, i8** %94, i64 0
%96 = load i8*, i8** %95
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %96)
%98 = call i32 @exit(i32 253)
unreachable
99: ; preds = %86
%100 = load i8, i8* %14
%101 = icmp ne i8 %100, 0
br i1 %101, label %102, label %156
102: ; preds = %99
%103 = getelementptr inbounds [7 x i32], [7 x i32]* %7, i64 0, i64 0
%104 = load i32*, i32** %6
%105 = call i32 @fread(i32* %103, i32 4, i32 7, i32* %104)
%106 = icmp ne i32 %105, 7
br i1 %106, label %107, label %111
107: ; preds = %102
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%110 = call i32 @exit(i32 253)
unreachable
111: ; preds = %102
store i32 0, i32* %16
br label %112
112: ; preds = %122, %111
%113 = load i32, i32* %16
%114 = icmp slt i32 %113, 7
br i1 %114, label %115, label %125
115: ; preds = %112
%116 = load i32, i32* %16
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [7 x i32], [7 x i32]* %7, i64 0, i64 %117
%119 = load i32, i32* %118
%120 = load i32, i32* %8
%121 = add nsw i32 %120, %119
store i32 %121, i32* %8
br label %122
122: ; preds = %115
%123 = load i32, i32* %16
%124 = add nsw i32 %123, 1
store i32 %124, i32* %16
br label %112
125: ; preds = %112
%126 = load i32, i32* %8
%127 = xor i32 %126, -1
%128 = add nsw i32 %127, 1
store i32 %128, i32* %8
%129 = load i8, i8* %13
%130 = icmp ne i8 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %125
%132 = load i32, i32* %8
%133 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %132)
br label %134
134: ; preds = %131, %125
%135 = load i32*, i32** %6
%136 = load i32, i32* @SEEK_SET
%137 = call i64 @fseek(i32* %135, i32 28, i32 %136)
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %134
%140 = load i32, i32* @stderr
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%142 = call i32 @exit(i32 253)
unreachable
143: ; preds = %134
%144 = load i8, i8* %14
%145 = icmp ne i8 %144, 0
br i1 %145, label %146, label %155
146: ; preds = %143
%147 = load i32*, i32** %6
%148 = call i32 @fwrite(i32* %8, i32 4, i32 1, i32* %147)
%149 = icmp ne i32 %148, 1
br i1 %149, label %150, label %154
150: ; preds = %146
%151 = load i32, i32* @stderr
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%153 = call i32 @exit(i32 253)
unreachable
154: ; preds = %146
br label %155
155: ; preds = %154, %143
br label %156
156: ; preds = %155, %99
%157 = load i8, i8* %13
%158 = icmp ne i8 %157, 0
br i1 %158, label %159, label %200
159: ; preds = %156
%160 = load i32*, i32** %6
%161 = load i32, i32* @SEEK_SET
%162 = call i64 @fseek(i32* %160, i32 764, i32 %161)
%163 = icmp ne i64 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %159
%165 = load i32, i32* @stderr
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%167 = call i32 @exit(i32 253)
unreachable
168: ; preds = %159
%169 = load i32*, i32** %6
%170 = call i32 @fread(i32* %10, i32 4, i32 1, i32* %169)
%171 = icmp ne i32 %170, 1
br i1 %171, label %172, label %176
172: ; preds = %168
%173 = load i32, i32* @stderr
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%175 = call i32 @exit(i32 253)
unreachable
176: ; preds = %168
store i32 1, i32* %17
br label %177
177: ; preds = %189, %176
%178 = load i32, i32* %17
%179 = icmp sle i32 %178, 4
br i1 %179, label %180, label %192
180: ; preds = %177
%181 = load i32, i32* %10
%182 = load i32, i32* %17
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 %183
%185 = load i32, i32* %184
%186 = icmp eq i32 %181, %185
br i1 %186, label %187, label %188
187: ; preds = %180
br label %192
188: ; preds = %180
br label %189
189: ; preds = %188
%190 = load i32, i32* %17
%191 = add nsw i32 %190, 1
store i32 %191, i32* %17
br label %177
192: ; preds = %187, %177
%193 = load i32, i32* %17
%194 = icmp sgt i32 %193, 4
br i1 %194, label %195, label %196
195: ; preds = %192
store i32 0, i32* %17
br label %196
196: ; preds = %195, %192
%197 = load i32, i32* %10
%198 = load i32, i32* %17
%199 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), i32 %197, i32 %198)
br label %200
200: ; preds = %196, %156
%201 = load i32, i32* %15
%202 = icmp ne i32 %201, -1
br i1 %202, label %203, label %227
203: ; preds = %200
%204 = load i32, i32* %15
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 %205
%207 = load i32, i32* %206
store i32 %207, i32* %10
%208 = load i32*, i32** %6
%209 = load i32, i32* @SEEK_SET
%210 = call i64 @fseek(i32* %208, i32 764, i32 %209)
%211 = icmp ne i64 %210, 0
br i1 %211, label %212, label %216
212: ; preds = %203
%213 = load i32, i32* @stderr
%214 = call i32 (i32, i8*, ...) @fprintf(i32 %213, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%215 = call i32 @exit(i32 253)
unreachable
216: ; preds = %203
%217 = load i32*, i32** %6
%218 = call i32 @fwrite(i32* %10, i32 4, i32 1, i32* %217)
%219 = icmp ne i32 %218, 1
br i1 %219, label %220, label %224
220: ; preds = %216
%221 = load i32, i32* @stderr
%222 = call i32 (i32, i8*, ...) @fprintf(i32 %221, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%223 = call i32 @exit(i32 253)
unreachable
224: ; preds = %216
%225 = load i32, i32* %10
%226 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %225)
br label %227
227: ; preds = %224, %200
%228 = load i32*, i32** %6
%229 = call i32 @fclose(i32* %228)
ret i32 0
}

LLVM IR (-O2):
@__const.main.magic = [5 x i32] [i32 0, i32 305419896, i32 -2023406815, i32 1126270821, i32 1315533680]
@.str = [7 x i8] c"lpcfix\00"
@.str.1 = [7 x i8] c"vcp:nh\00"
@EOF = global i64 0
@optarg = global i32 0
@stderr = global i32 0
@.str.2 = [425 x i8] c"Usage: %s [options]\0A\0AThis program fixes the CRC field for LPC firmware and optionally\0Aenables/disables the content read protection flags\0A\0A\0A-n Do not change CRC information\0A-c Fix CRC\0A-v Be verbose (-v -v = even more)\0A-p mode Enable CRP (Content read protection) mode\0A-h This help\0A\0ACRP modes valid:\0A0 Disable CRP\0A1-3 Enable CRP 1-3\0A4 Enable NO_ISP\0A\0A\00"
@optind = global i64 0
@.str.3 = [27 x i8] c"Error: No filename given!\0A\00"
@.str.4 = [23 x i8] c"CRP %d is not allowed\0A\00"
@.str.5 = [4 x i8] c"r+b\00"
@.str.6 = [27 x i8] c"Error: Can't open file %s\0A\00"
@.str.7 = [20 x i8] c"Error: Read failed\0A\00"
@.str.8 = [23 x i8] c"New CRC is: 0x%08x\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [20 x i8] c"Error: Seek failed\0A\00"
@.str.10 = [25 x i8] c"Error: CRC write failed\0A\00"
@.str.11 = [24 x i8] c"Error: CRP Seek failed\0A\00"
@.str.12 = [24 x i8] c"Error: CRP Read failed\0A\00"
@.str.13 = [28 x i8] c"Curent CRP: 0x%08x (%d)\0A\00"
@.str.14 = [25 x i8] c"Error: CRP Write failed\0A\00"
@.str.15 = [23 x i8] c"New CRP value: 0x%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [7 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [7 x i32]* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, null
%11 = select i1 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %9
%12 = tail call i8* @strrchr(i8* dereferenceable(1) %11, i8 signext 47)
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = tail call i8* @strrchr(i8* dereferenceable(1) %9, i8 signext 47)
%16 = getelementptr inbounds i8, i8* %15, i64 1
br label %17
17: ; preds = %14, %2
%18 = phi i8* [ %16, %14 ], [ %11, %2 ]
%19 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = sext i8 %19 to i32
%21 = load i64, i64* @EOF
%22 = trunc i64 %21 to i32
%23 = shl i32 %22, 24
%24 = ashr exact i32 %23, 24
%25 = icmp eq i32 %24, %20
br i1 %25, label %56, label %26
26: ; preds = %17, %40
%27 = phi i32 [ %45, %40 ], [ %20, %17 ]
%28 = phi i32 [ %43, %40 ], [ -1, %17 ]
%29 = phi i8 [ %42, %40 ], [ 0, %17 ]
%30 = phi i8 [ %41, %40 ], [ 0, %17 ]
switch i32 %27, label %36 [
i32 99, label %40
i32 118, label %31
i32 112, label %33
]
31: ; preds = %26
%32 = add i8 %30, 1
br label %40
33: ; preds = %26
%34 = load i32, i32* @optarg
%35 = tail call i32 @atoi(i32 %34)
br label %40
36: ; preds = %26
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([425 x i8], [425 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%39 = tail call i32 @exit(i32 255)
unreachable
40: ; preds = %26, %33, %31
%41 = phi i8 [ %30, %33 ], [ %32, %31 ], [ %30, %26 ]
%42 = phi i8 [ %29, %33 ], [ %29, %31 ], [ 1, %26 ]
%43 = phi i32 [ %35, %33 ], [ %28, %31 ], [ %28, %26 ]
%44 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%45 = sext i8 %44 to i32
%46 = load i64, i64* @EOF
%47 = trunc i64 %46 to i32
%48 = shl i32 %47, 24
%49 = ashr exact i32 %48, 24
%50 = icmp eq i32 %49, %45
br i1 %50, label %51, label %26
51: ; preds = %40
%52 = load i64, i64* @optind
%53 = trunc i64 %52 to i32
%54 = sub i32 %0, %53
%55 = icmp eq i32 %54, 1
br i1 %55, label %65, label %61
56: ; preds = %17
%57 = load i64, i64* @optind
%58 = trunc i64 %57 to i32
%59 = sub i32 %0, %58
%60 = icmp eq i32 %59, 1
br i1 %60, label %71, label %61
61: ; preds = %56, %51
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%64 = tail call i32 @exit(i32 254)
unreachable
65: ; preds = %51
%66 = icmp sgt i32 %43, 4
br i1 %66, label %67, label %71
67: ; preds = %65
%68 = load i32, i32* @stderr
%69 = tail call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%70 = tail call i32 @exit(i32 254)
unreachable
71: ; preds = %56, %65
%72 = phi i8 [ %41, %65 ], [ 0, %56 ]
%73 = phi i8 [ %42, %65 ], [ 0, %56 ]
%74 = phi i32 [ %43, %65 ], [ -1, %56 ]
%75 = phi i64 [ %52, %65 ], [ %57, %56 ]
%76 = getelementptr inbounds i8*, i8** %1, i64 %75
%77 = load i8*, i8** %76
%78 = tail call i32* @fopen(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %85
80: ; preds = %71
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %76
%83 = tail call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %82)
%84 = tail call i32 @exit(i32 253)
unreachable
85: ; preds = %71
%86 = icmp eq i8 %73, 0
br i1 %86, label %134, label %87
87: ; preds = %85
%88 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%89 = call i32 @fread(i32* %88, i32 4, i32 7, i32* %78)
%90 = icmp eq i32 %89, 7
br i1 %90, label %91, label %113
91: ; preds = %87
%92 = load i32, i32* %88
%93 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 1
%94 = load i32, i32* %93
%95 = add nsw i32 %92, %94
%96 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 2
%97 = load i32, i32* %96
%98 = add nsw i32 %95, %97
%99 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 3
%100 = load i32, i32* %99
%101 = add nsw i32 %98, %100
%102 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 4
%103 = load i32, i32* %102
%104 = add nsw i32 %101, %103
%105 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 5
%106 = load i32, i32* %105
%107 = add nsw i32 %104, %106
%108 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 6
%109 = load i32, i32* %108
%110 = add nsw i32 %107, %109
%111 = sub i32 0, %110
store i32 %111, i32* %4
%112 = icmp eq i8 %72, 0
br i1 %112, label %119, label %117
113: ; preds = %87
%114 = load i32, i32* @stderr
%115 = tail call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%116 = tail call i32 @exit(i32 253)
unreachable
117: ; preds = %91
%118 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %111)
br label %119
119: ; preds = %117, %91
%120 = load i32, i32* @SEEK_SET
%121 = tail call i64 @fseek(i32* %78, i32 28, i32 %120)
%122 = icmp eq i64 %121, 0
br i1 %122, label %127, label %123
123: ; preds = %119
%124 = load i32, i32* @stderr
%125 = tail call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%126 = tail call i32 @exit(i32 253)
unreachable
127: ; preds = %119
%128 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32* %78)
%129 = icmp eq i32 %128, 1
br i1 %129, label %134, label %130
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = tail call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%133 = tail call i32 @exit(i32 253)
unreachable
134: ; preds = %127, %85
%135 = icmp eq i8 %72, 0
br i1 %135, label %160, label %136
136: ; preds = %134
%137 = load i32, i32* @SEEK_SET
%138 = tail call i64 @fseek(i32* %78, i32 764, i32 %137)
%139 = icmp eq i64 %138, 0
br i1 %139, label %144, label %140
140: ; preds = %136
%141 = load i32, i32* @stderr
%142 = tail call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%143 = tail call i32 @exit(i32 253)
unreachable
144: ; preds = %136
%145 = call i32 @fread(i32* %5, i32 4, i32 1, i32* %78)
%146 = icmp eq i32 %145, 1
br i1 %146, label %147, label %149
147: ; preds = %144
%148 = load i32, i32* %5
switch i32 %148, label %153 [
i32 305419896, label %157
i32 -2023406815, label %154
i32 1126270821, label %155
i32 1315533680, label %156
]
149: ; preds = %144
%150 = load i32, i32* @stderr
%151 = tail call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%152 = tail call i32 @exit(i32 253)
unreachable
153: ; preds = %147
br label %157
154: ; preds = %147
br label %157
155: ; preds = %147
br label %157
156: ; preds = %147
br label %157
157: ; preds = %147, %156, %155, %154, %153
%158 = phi i32 [ 0, %153 ], [ 1, %147 ], [ 2, %154 ], [ 3, %155 ], [ 4, %156 ]
%159 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), i32 %148, i32 %158)
br label %160
160: ; preds = %157, %134
%161 = icmp eq i32 %74, -1
br i1 %161, label %183, label %162
162: ; preds = %160
%163 = sext i32 %74 to i64
%164 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.magic, i64 0, i64 %163
%165 = load i32, i32* %164
store i32 %165, i32* %5
%166 = load i32, i32* @SEEK_SET
%167 = tail call i64 @fseek(i32* %78, i32 764, i32 %166)
%168 = icmp eq i64 %167, 0
br i1 %168, label %173, label %169
169: ; preds = %162
%170 = load i32, i32* @stderr
%171 = tail call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%172 = tail call i32 @exit(i32 253)
unreachable
173: ; preds = %162
%174 = call i32 @fwrite(i32* %5, i32 4, i32 1, i32* %78)
%175 = icmp eq i32 %174, 1
br i1 %175, label %180, label %176
176: ; preds = %173
%177 = load i32, i32* @stderr
%178 = tail call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%179 = tail call i32 @exit(i32 253)
unreachable
180: ; preds = %173
%181 = load i32, i32* %5
%182 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %181)
br label %183
183: ; preds = %180, %160
%184 = tail call i32 @fclose(i32* %78)
ret i32 0
}