#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*/ I2C_SLAVE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
size_t atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned int fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
unsigned int fwrite(unsigned char *, int, unsigned int, int /*<<< orphan*/ *);
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
unsigned char *malloc(size_t);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
scalar_t__ vct_erase(int);
int vct_get_version(int);
scalar_t__ vct_transfer(int, unsigned int, int, unsigned char *, int);
int main(int argc, char *argv[]) {
  FILE *f;
  unsigned int i;
  unsigned char *buf;
  size_t size;
  int ret = 0;
  printf("vct_flash - Micronas VCT I2C Flash Utility\n");
  printf(
      "Copyright (c) 2015 Ondrej Zary - http://www.rainbow-software.org\n\n");
  if (argc < 4) {
    usage();
    exit(1);
  }
  int i2c = open(argv[1], O_RDWR);
  if (i2c < 0) {
    perror("Unable to open I2C device");
    exit(2);
  }
  if (ioctl(i2c, I2C_SLAVE, 0x68) < 0) {
    perror("Error setting I2C slave address");
    exit(2);
  }
  printf("Bootloader version: 0x%02x\n", vct_get_version(i2c));
  if (!strcmp(argv[2], "write")) {
    f = fopen(argv[3], "r");
    if (!f) {
      perror("Error opening file");
      exit(5);
    }
    fseek(f, 0, SEEK_END);
    size = ftell(f);
    fseek(f, 0, SEEK_SET);
    if (size % 16 != 0 || size > (8 * 1024 * 1024)) {
      fprintf(
          stderr,
          "Invalid file size: must be multiple of %d B and smaller than %d B\n",
          16, (8 * 1024 * 1024));
      exit(1);
    }
    buf = malloc(size);
    if (!buf) {
      fprintf(stderr, "Memory allocation error, %d bytes required.\n", size);
      exit(1);
    }
    unsigned int len = fread(buf, 1, size, f);
    if (len < size) {
      fprintf(stderr, "Error reading file\n");
      exit(5);
    }
    printf("Erasing flash: ");
    if (vct_erase(i2c))
      exit(6);
    vct_get_version(i2c);
    printf("done\n");
    printf("Writing flash: ");
    for (i = 0; i < size; i += 16) {
      if (vct_transfer(i2c, i, 16, buf + i, 0x22)) {
        ret = 10;
        break;
      }
      if (i % 1024 == 0) {
        printf(".");
        fflush(stdout);
      }
    }
    if (i == size)
      printf("done\n");
  } else if (!strcmp(argv[2], "read")) {
    if (argc < 5) {
      fprintf(stderr, "Size not specified\n");
      exit(1);
    }
    size = atoi(argv[4]);
    if (size % 16 != 0 || size > (8 * 1024 * 1024)) {
      fprintf(stderr,
              "Invalid size specified: must be multiple of %d and smaller than "
              "%d\n",
              16, (8 * 1024 * 1024));
      exit(1);
    }
    buf = malloc(size);
    if (!buf) {
      fprintf(stderr, "Memory allocation error, %d bytes required.\n", size);
      exit(1);
    }
    f = fopen(argv[3], "w");
    if (!f) {
      perror("Error opening file");
      exit(5);
    }
    printf("Reading flash: ");
    for (i = 0; i < size; i += 16) {
      if (vct_transfer(i2c, i, 16, buf + i, 0x23)) {
        ret = 10;
        break;
      }
      if (i % 1024 == 0) {
        printf(".");
        fflush(stdout);
      }
    }
    if (i == size)
      printf("done\n");
    if (fwrite(buf, 1, i, f) != i) {
      fprintf(stderr, "Error writing file\n");
      exit(5);
    }
  } else {
    usage();
    exit(1);
  }
  fclose(f);
  free(buf);
  close(i2c);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x4,-0x8(%rbp)
jge    12b4 <main+0x54>
mov    $0x0,%al
call   1110 <usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d25(%rip),%rax
mov    (%rax),%esi
call   1130 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    12ed <main+0x8d>
lea    0xd91(%rip),%rdi
call   1150 <perror@plt>
mov    $0x2,%edi
call   1170 <exit@plt>
mov    -0x38(%rbp),%edi
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edx
call   1080 <ioctl@plt>
cmp    $0x0,%rax
jge    1323 <main+0xc3>
lea    0xd75(%rip),%rdi
call   1150 <perror@plt>
mov    $0x2,%edi
call   1170 <exit@plt>
mov    -0x38(%rbp),%edi
call   10f0 <vct_get_version@plt>
mov    %eax,%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd7b(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    158d <main+0x32d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd64(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1391 <main+0x131>
lea    0xd4b(%rip),%rdi
call   1150 <perror@plt>
mov    $0x5,%edi
call   1170 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c44(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1100 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c03(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1100 <fseek@plt>
mov    -0x30(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    13e6 <main+0x186>
cmpq   $0x800000,-0x30(%rbp)
jbe    1411 <main+0x1b1>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xcea(%rip),%rsi
mov    $0x10,%edx
mov    $0x800000,%ecx
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    144e <main+0x1ee>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xce6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x30(%rbp),%rax
jae    1495 <main+0x235>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x5,%edi
call   1170 <exit@plt>
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%edi
call   1120 <vct_erase@plt>
cmp    $0x0,%rax
je     14bf <main+0x25f>
mov    $0x6,%edi
call   1170 <exit@plt>
mov    -0x38(%rbp),%edi
call   10f0 <vct_get_version@plt>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%rax
jae    156d <main+0x30d>
mov    -0x38(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%eax
add    %rax,%rcx
mov    $0x10,%edx
mov    $0x22,%r8d
call   1040 <vct_transfer@plt>
cmp    $0x0,%rax
je     152d <main+0x2cd>
movl   $0xa,-0x34(%rbp)
jmp    156d <main+0x30d>
mov    -0x1c(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
jne    155a <main+0x2fa>
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2a65(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
jmp    155f <main+0x2ff>
mov    -0x1c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x1c(%rbp)
jmp    14ea <main+0x28a>
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%rax
jne    1588 <main+0x328>
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    17b4 <main+0x554>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xbf0(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    179e <main+0x53e>
cmpl   $0x5,-0x8(%rbp)
jge    15d5 <main+0x375>
mov    0x2a0d(%rip),%rax
mov    (%rax),%edi
lea    0xbcd(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1160 <atoi@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    1606 <main+0x3a6>
cmpq   $0x800000,-0x30(%rbp)
jbe    1631 <main+0x3d1>
mov    0x29bb(%rip),%rax
mov    (%rax),%edi
lea    0xb8f(%rip),%rsi
mov    $0x10,%edx
mov    $0x800000,%ecx
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    166e <main+0x40e>
mov    0x2978(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xac6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xb6c(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    16a7 <main+0x447>
lea    0xa35(%rip),%rdi
call   1150 <perror@plt>
mov    $0x5,%edi
call   1170 <exit@plt>
lea    0xb3d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%rax
jae    173f <main+0x4df>
mov    -0x38(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%eax
add    %rax,%rcx
mov    $0x10,%edx
mov    $0x23,%r8d
call   1040 <vct_transfer@plt>
cmp    $0x0,%rax
je     16ff <main+0x49f>
movl   $0xa,-0x34(%rbp)
jmp    173f <main+0x4df>
mov    -0x1c(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
jne    172c <main+0x4cc>
lea    0xa73(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2893(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
jmp    1731 <main+0x4d1>
mov    -0x1c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x1c(%rbp)
jmp    16bc <main+0x45c>
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%rax
jne    175a <main+0x4fa>
lea    0xa21(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1180 <fwrite@plt>
cmp    -0x1c(%rbp),%eax
je     1799 <main+0x539>
mov    0x2849(%rip),%rax
mov    (%rax),%edi
lea    0xa73(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x5,%edi
call   1170 <exit@plt>
jmp    17af <main+0x54f>
mov    $0x0,%al
call   1110 <usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    17b4 <main+0x554>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%edi
call   1090 <close@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xf01(%rip),%rdi
call   1060 <puts@plt>
lea    0xf20(%rip),%rdi
call   1060 <puts@plt>
cmp    $0x3,%ebx
jle    15ec <main+0x36c>
mov    0x8(%r14),%rdi
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
call   1150 <open@plt>
test   %eax,%eax
js     15fd <main+0x37d>
mov    %eax,%r15d
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    $0x68,%edx
call   10a0 <ioctl@plt>
test   %rax,%rax
js     1606 <main+0x386>
mov    %r15d,%edi
call   1110 <vct_get_version@plt>
lea    0xd3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%r14),%rbp
lea    0xd46(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     140a <main+0x18a>
lea    0xdee(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
jne    15ec <main+0x36c>
cmp    $0x4,%ebx
jbe    1632 <main+0x3b2>
mov    0x20(%r14),%rdi
call   1180 <atoi@plt>
cmp    $0x800000,%rax
ja     1653 <main+0x3d3>
mov    %rax,%rbp
and    $0xf,%eax
test   %rax,%rax
jne    1653 <main+0x3d3>
mov    %rbp,%rdi
call   10f0 <malloc@plt>
test   %rax,%rax
je     1665 <main+0x3e5>
mov    %rax,%r13
mov    0x18(%r14),%rdi
lea    0xdef(%rip),%rsi
call   1160 <fopen@plt>
test   %rax,%rax
je     161c <main+0x39c>
mov    %rax,%r12
lea    0xdd9(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x0,%r14d
test   %rbp,%rbp
je     1562 <main+0x2e2>
xor    %ebx,%ebx
mov    0x2bfc(%rip),%r14
jmp    13cc <main+0x14c>
xchg   %ax,%ax
add    $0x10,%ebx
cmp    %rbx,%rbp
jbe    155f <main+0x2df>
lea    (%rbx,%r13,1),%rcx
mov    %r15d,%edi
mov    %ebx,%esi
mov    $0x10,%edx
mov    $0x23,%r8d
call   1050 <vct_transfer@plt>
test   %rax,%rax
jne    1557 <main+0x2d7>
test   $0x3f0,%ebx
jne    13c0 <main+0x140>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    (%r14),%edi
call   1100 <fflush@plt>
jmp    13c0 <main+0x140>
mov    0x18(%r14),%rdi
lea    0xc47(%rip),%rsi
call   1160 <fopen@plt>
test   %rax,%rax
je     161c <main+0x39c>
mov    %rax,%rbx
mov    0x2bb3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1120 <fseek@plt>
mov    %rbx,%rdi
call   10e0 <ftell@plt>
mov    %rax,%r12
mov    0x2b75(%rip),%rax
mov    (%rax),%edx
mov    %rbx,(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1120 <fseek@plt>
cmp    $0x800000,%r12
ja     167a <main+0x3fa>
mov    %r12d,%eax
and    $0xf,%eax
test   %rax,%rax
jne    167a <main+0x3fa>
mov    %r12,%rdi
call   10f0 <malloc@plt>
test   %rax,%rax
je     16a5 <main+0x425>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    (%rsp),%rcx
call   1070 <fread@plt>
mov    %eax,%eax
cmp    %rax,%r12
ja     16c9 <main+0x449>
lea    0xc44(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15d,%edi
call   1140 <vct_erase@plt>
test   %rax,%rax
jne    16ea <main+0x46a>
mov    %r15d,%edi
call   1110 <vct_get_version@plt>
lea    0xd2b(%rip),%rdi
call   1060 <puts@plt>
lea    0xc1f(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x0,%r14d
test   %r12,%r12
je     15ab <main+0x32b>
xor    %ebp,%ebp
mov    0x2ab3(%rip),%rbx
jmp    151c <main+0x29c>
nopw   0x0(%rax,%rax,1)
add    $0x10,%ebp
cmp    %rbp,%r12
jbe    15a8 <main+0x328>
mov    %r13,%rcx
add    %rbp,%rcx
mov    %r15d,%edi
mov    %ebp,%esi
mov    $0x10,%edx
mov    $0x22,%r8d
call   1050 <vct_transfer@plt>
test   %rax,%rax
jne    15a0 <main+0x320>
test   $0x3f0,%ebp
jne    1510 <main+0x290>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    (%rbx),%edi
call   1100 <fflush@plt>
jmp    1510 <main+0x290>
mov    $0xa,%r14d
jmp    1562 <main+0x2e2>
xor    %r14d,%r14d
mov    %ebx,%eax
cmp    %rax,%rbp
jne    1575 <main+0x2f5>
lea    0xc95(%rip),%rdi
call   1060 <puts@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   11a0 <fwrite@plt>
cmp    %ebx,%eax
je     15c2 <main+0x342>
mov    0x2a36(%rip),%rax
mov    (%rax),%edi
lea    0xbe9(%rip),%rsi
jmp    16d9 <main+0x459>
mov    $0xa,%r14d
jmp    15ab <main+0x32b>
xor    %r14d,%r14d
mov    %ebp,%eax
cmp    %rax,%r12
jne    15be <main+0x33e>
lea    0xc4c(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%r12
mov    %r12,%rdi
call   1080 <fclose@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15d,%edi
call   10b0 <close@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1130 <usage@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
lea    0x9fc(%rip),%rdi
jmp    160d <main+0x38d>
lea    0xa0d(%rip),%rdi
call   1170 <perror@plt>
mov    $0x2,%edi
call   1190 <exit@plt>
lea    0xa3b(%rip),%rdi
call   1170 <perror@plt>
mov    $0x5,%edi
call   1190 <exit@plt>
mov    0x298f(%rip),%rax
mov    (%rax),%edi
lea    0xad8(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    0x296e(%rip),%rax
mov    (%rax),%edi
lea    0xacb(%rip),%rsi
jmp    168a <main+0x40a>
mov    0x295c(%rip),%rax
mov    (%rax),%edi
lea    0xa3f(%rip),%rsi
mov    %rbp,%rdx
jmp    16b8 <main+0x438>
mov    0x2947(%rip),%rax
mov    (%rax),%edi
lea    0x9e7(%rip),%rsi
mov    $0x10,%edx
mov    $0x800000,%ecx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    0x291c(%rip),%rax
mov    (%rax),%edi
lea    0x9ff(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    0x28f8(%rip),%rax
mov    (%rax),%edi
lea    0xa08(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x5,%edi
call   1190 <exit@plt>
mov    $0x6,%edi
call   1190 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"vct_flash - Micronas VCT I2C Flash Utility\0A\00"
@.str.1 = [67 x i8] c"Copyright (c) 2015 Ondrej Zary - http://www.rainbow-software.org\0A\0A\00"
@O_RDWR = global i32 0
@.str.2 = [26 x i8] c"Unable to open I2C device\00"
@I2C_SLAVE = global i32 0
@.str.3 = [32 x i8] c"Error setting I2C slave address\00"
@.str.4 = [28 x i8] c"Bootloader version: 0x%02x\0A\00"
@.str.5 = [6 x i8] c"write\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [19 x i8] c"Error opening file\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.8 = [67 x i8] c"Invalid file size: must be multiple of %d B and smaller than %d B\0A\00"
@.str.9 = [45 x i8] c"Memory allocation error, %d bytes required.\0A\00"
@.str.10 = [20 x i8] c"Error reading file\0A\00"
@.str.11 = [16 x i8] c"Erasing flash: \00"
@.str.12 = [6 x i8] c"done\0A\00"
@.str.13 = [16 x i8] c"Writing flash: \00"
@.str.14 = [2 x i8] c".\00"
@stdout = global i32 0
@.str.15 = [5 x i8] c"read\00"
@.str.16 = [20 x i8] c"Size not specified\0A\00"
@.str.17 = [68 x i8] c"Invalid size specified: must be multiple of %d and smaller than %d\0A\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [16 x i8] c"Reading flash: \00"
@.str.20 = [20 x i8] c"Error writing file\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 i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 (...) @usage()
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDWR
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %20
%32 = load i32, i32* %11
%33 = load i32, i32* @I2C_SLAVE
%34 = call i64 @ioctl(i32 %32, i32 %33, i32 104)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @exit(i32 2)
unreachable
39: ; preds = %31
%40 = load i32, i32* %11
%41 = call i32 @vct_get_version(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %147, label %48
48: ; preds = %39
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 3
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %52, i32** %6
%53 = load i32*, i32** %6
%54 = icmp ne i32* %53, null
br i1 %54, label %58, label %55
55: ; preds = %48
%56 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%57 = call i32 @exit(i32 5)
unreachable
58: ; preds = %48
%59 = load i32*, i32** %6
%60 = load i32, i32* @SEEK_END
%61 = call i32 @fseek(i32* %59, i32 0, i32 %60)
%62 = load i32*, i32** %6
%63 = call i64 @ftell(i32* %62)
store i64 %63, i64* %9
%64 = load i32*, i32** %6
%65 = load i32, i32* @SEEK_SET
%66 = call i32 @fseek(i32* %64, i32 0, i32 %65)
%67 = load i64, i64* %9
%68 = urem i64 %67, 16
%69 = icmp ne i64 %68, 0
br i1 %69, label %73, label %70
70: ; preds = %58
%71 = load i64, i64* %9
%72 = icmp ugt i64 %71, 8388608
br i1 %72, label %73, label %77
73: ; preds = %70, %58
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i32 16, i32 8388608)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %70
%78 = load i64, i64* %9
%79 = call i8* @malloc(i64 %78)
store i8* %79, i8** %8
%80 = load i8*, i8** %8
%81 = icmp ne i8* %80, null
br i1 %81, label %87, label %82
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = load i64, i64* %9
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i64 %84)
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %77
%88 = load i8*, i8** %8
%89 = load i64, i64* %9
%90 = load i32*, i32** %6
%91 = call i32 @fread(i8* %88, i32 1, i64 %89, i32* %90)
store i32 %91, i32* %12
%92 = load i32, i32* %12
%93 = zext i32 %92 to i64
%94 = load i64, i64* %9
%95 = icmp ult i64 %93, %94
br i1 %95, label %96, label %100
96: ; preds = %87
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%99 = call i32 @exit(i32 5)
unreachable
100: ; preds = %87
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%102 = load i32, i32* %11
%103 = call i64 @vct_erase(i32 %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %100
%106 = call i32 @exit(i32 6)
unreachable
107: ; preds = %100
%108 = load i32, i32* %11
%109 = call i32 @vct_get_version(i32 %108)
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %7
br label %112
112: ; preds = %136, %107
%113 = load i32, i32* %7
%114 = zext i32 %113 to i64
%115 = load i64, i64* %9
%116 = icmp ult i64 %114, %115
br i1 %116, label %117, label %139
117: ; preds = %112
%118 = load i32, i32* %11
%119 = load i32, i32* %7
%120 = load i8*, i8** %8
%121 = load i32, i32* %7
%122 = zext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = call i64 @vct_transfer(i32 %118, i32 %119, i32 16, i8* %123, i32 34)
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %117
store i32 10, i32* %10
br label %139
127: ; preds = %117
%128 = load i32, i32* %7
%129 = urem i32 %128, 1024
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %127
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%133 = load i32, i32* @stdout
%134 = call i32 @fflush(i32 %133)
br label %135
135: ; preds = %131, %127
br label %136
136: ; preds = %135
%137 = load i32, i32* %7
%138 = add i32 %137, 16
store i32 %138, i32* %7
br label %112
139: ; preds = %126, %112
%140 = load i32, i32* %7
%141 = zext i32 %140 to i64
%142 = load i64, i64* %9
%143 = icmp eq i64 %141, %142
br i1 %143, label %144, label %146
144: ; preds = %139
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %146
146: ; preds = %144, %139
br label %247
147: ; preds = %39
%148 = load i8**, i8*** %5
%149 = getelementptr inbounds i8*, i8** %148, i64 2
%150 = load i8*, i8** %149
%151 = call i32 @strcmp(i8* %150, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%152 = icmp ne i32 %151, 0
br i1 %152, label %243, label %153
153: ; preds = %147
%154 = load i32, i32* %4
%155 = icmp slt i32 %154, 5
br i1 %155, label %156, label %160
156: ; preds = %153
%157 = load i32, i32* @stderr
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %157, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%159 = call i32 @exit(i32 1)
unreachable
160: ; preds = %153
%161 = load i8**, i8*** %5
%162 = getelementptr inbounds i8*, i8** %161, i64 4
%163 = load i8*, i8** %162
%164 = call i64 @atoi(i8* %163)
store i64 %164, i64* %9
%165 = load i64, i64* %9
%166 = urem i64 %165, 16
%167 = icmp ne i64 %166, 0
br i1 %167, label %171, label %168
168: ; preds = %160
%169 = load i64, i64* %9
%170 = icmp ugt i64 %169, 8388608
br i1 %170, label %171, label %175
171: ; preds = %168, %160
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 16, i32 8388608)
%174 = call i32 @exit(i32 1)
unreachable
175: ; preds = %168
%176 = load i64, i64* %9
%177 = call i8* @malloc(i64 %176)
store i8* %177, i8** %8
%178 = load i8*, i8** %8
%179 = icmp ne i8* %178, null
br i1 %179, label %185, label %180
180: ; preds = %175
%181 = load i32, i32* @stderr
%182 = load i64, i64* %9
%183 = call i32 (i32, i8*, ...) @fprintf(i32 %181, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i64 %182)
%184 = call i32 @exit(i32 1)
unreachable
185: ; preds = %175
%186 = load i8**, i8*** %5
%187 = getelementptr inbounds i8*, i8** %186, i64 3
%188 = load i8*, i8** %187
%189 = call i32* @fopen(i8* %188, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %189, i32** %6
%190 = load i32*, i32** %6
%191 = icmp ne i32* %190, null
br i1 %191, label %195, label %192
192: ; preds = %185
%193 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%194 = call i32 @exit(i32 5)
unreachable
195: ; preds = %185
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
store i32 0, i32* %7
br label %197
197: ; preds = %221, %195
%198 = load i32, i32* %7
%199 = zext i32 %198 to i64
%200 = load i64, i64* %9
%201 = icmp ult i64 %199, %200
br i1 %201, label %202, label %224
202: ; preds = %197
%203 = load i32, i32* %11
%204 = load i32, i32* %7
%205 = load i8*, i8** %8
%206 = load i32, i32* %7
%207 = zext i32 %206 to i64
%208 = getelementptr inbounds i8, i8* %205, i64 %207
%209 = call i64 @vct_transfer(i32 %203, i32 %204, i32 16, i8* %208, i32 35)
%210 = icmp ne i64 %209, 0
br i1 %210, label %211, label %212
211: ; preds = %202
store i32 10, i32* %10
br label %224
212: ; preds = %202
%213 = load i32, i32* %7
%214 = urem i32 %213, 1024
%215 = icmp eq i32 %214, 0
br i1 %215, label %216, label %220
216: ; preds = %212
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%218 = load i32, i32* @stdout
%219 = call i32 @fflush(i32 %218)
br label %220
220: ; preds = %216, %212
br label %221
221: ; preds = %220
%222 = load i32, i32* %7
%223 = add i32 %222, 16
store i32 %223, i32* %7
br label %197
224: ; preds = %211, %197
%225 = load i32, i32* %7
%226 = zext i32 %225 to i64
%227 = load i64, i64* %9
%228 = icmp eq i64 %226, %227
br i1 %228, label %229, label %231
229: ; preds = %224
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %231
231: ; preds = %229, %224
%232 = load i8*, i8** %8
%233 = load i32, i32* %7
%234 = load i32*, i32** %6
%235 = call i32 @fwrite(i8* %232, i32 1, i32 %233, i32* %234)
%236 = load i32, i32* %7
%237 = icmp ne i32 %235, %236
br i1 %237, label %238, label %242
238: ; preds = %231
%239 = load i32, i32* @stderr
%240 = call i32 (i32, i8*, ...) @fprintf(i32 %239, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0))
%241 = call i32 @exit(i32 5)
unreachable
242: ; preds = %231
br label %246
243: ; preds = %147
%244 = call i32 (...) @usage()
%245 = call i32 @exit(i32 1)
unreachable
246: ; preds = %242
br label %247
247: ; preds = %246, %146
%248 = load i32*, i32** %6
%249 = call i32 @fclose(i32* %248)
%250 = load i8*, i8** %8
%251 = call i32 @free(i8* %250)
%252 = load i32, i32* %11
%253 = call i32 @close(i32 %252)
%254 = load i32, i32* %10
ret i32 %254
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str.2 = [26 x i8] c"Unable to open I2C device\00"
@I2C_SLAVE = global i32 0
@.str.3 = [32 x i8] c"Error setting I2C slave address\00"
@.str.4 = [28 x i8] c"Bootloader version: 0x%02x\0A\00"
@.str.5 = [6 x i8] c"write\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [19 x i8] c"Error opening file\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.8 = [67 x i8] c"Invalid file size: must be multiple of %d B and smaller than %d B\0A\00"
@.str.9 = [45 x i8] c"Memory allocation error, %d bytes required.\0A\00"
@.str.10 = [20 x i8] c"Error reading file\0A\00"
@.str.11 = [16 x i8] c"Erasing flash: \00"
@.str.13 = [16 x i8] c"Writing flash: \00"
@stdout = global i32 0
@.str.15 = [5 x i8] c"read\00"
@.str.16 = [20 x i8] c"Size not specified\0A\00"
@.str.17 = [68 x i8] c"Invalid size specified: must be multiple of %d and smaller than %d\0A\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [16 x i8] c"Reading flash: \00"
@.str.20 = [20 x i8] c"Error writing file\0A\00"
@str = [43 x i8] c"vct_flash - Micronas VCT I2C Flash Utility\00"
@str.21 = [66 x i8] c"Copyright (c) 2015 Ondrej Zary - http://www.rainbow-software.org\0A\00"
@str.24 = [5 x i8] c"done\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.21, i64 0, i64 0))
%5 = icmp slt i32 %0, 4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (...) @usage()
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDWR
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 2)
unreachable
18: ; preds = %9
%19 = load i32, i32* @I2C_SLAVE
%20 = tail call i64 @ioctl(i32 %13, i32 %19, i32 104)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @exit(i32 2)
unreachable
25: ; preds = %18
%26 = tail call i32 @vct_get_version(i32 %13)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %106
32: ; preds = %25
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%39 = tail call i32 @exit(i32 5)
unreachable
40: ; preds = %32
%41 = load i32, i32* @SEEK_END
%42 = tail call i32 @fseek(i32* %35, i32 0, i32 %41)
%43 = tail call i64 @ftell(i32* %35)
%44 = load i32, i32* @SEEK_SET
%45 = tail call i32 @fseek(i32* %35, i32 0, i32 %44)
%46 = and i64 %43, 15
%47 = icmp ne i64 %46, 0
%48 = icmp ugt i64 %43, 8388608
%49 = or i1 %48, %47
br i1 %49, label %50, label %54
50: ; preds = %40
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i32 16, i32 8388608)
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %40
%55 = tail call i8* @malloc(i64 %43)
%56 = icmp eq i8* %55, null
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i64 %43)
%60 = tail call i32 @exit(i32 1)
unreachable
61: ; preds = %54
%62 = tail call i32 @fread(i8* %55, i32 1, i64 %43, i32* %35)
%63 = zext i32 %62 to i64
%64 = icmp ugt i64 %43, %63
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%68 = tail call i32 @exit(i32 5)
unreachable
69: ; preds = %61
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%71 = tail call i64 @vct_erase(i32 %13)
%72 = icmp eq i64 %71, 0
br i1 %72, label %75, label %73
73: ; preds = %69
%74 = tail call i32 @exit(i32 6)
unreachable
75: ; preds = %69
%76 = tail call i32 @vct_get_version(i32 %13)
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.24, i64 0, i64 0))
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
%79 = icmp eq i64 %43, 0
br i1 %79, label %99, label %80
80: ; preds = %75, %93
%81 = phi i64 [ %95, %93 ], [ 0, %75 ]
%82 = trunc i64 %81 to i32
%83 = getelementptr inbounds i8, i8* %55, i64 %81
%84 = tail call i64 @vct_transfer(i32 %13, i32 %82, i32 16, i8* %83, i32 34)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %97
86: ; preds = %80
%87 = and i32 %82, 1008
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = tail call i32 @putchar(i32 46)
%91 = load i32, i32* @stdout
%92 = tail call i32 @fflush(i32 %91)
br label %93
93: ; preds = %86, %89
%94 = add i32 %82, 16
%95 = zext i32 %94 to i64
%96 = icmp ugt i64 %43, %95
br i1 %96, label %80, label %99
97: ; preds = %80
%98 = trunc i64 %81 to i32
br label %99
99: ; preds = %93, %97, %75
%100 = phi i32 [ 0, %75 ], [ %98, %97 ], [ %94, %93 ]
%101 = phi i32 [ 0, %75 ], [ 10, %97 ], [ 0, %93 ]
%102 = zext i32 %100 to i64
%103 = icmp eq i64 %43, %102
br i1 %103, label %104, label %181
104: ; preds = %99
%105 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.24, i64 0, i64 0))
br label %181
106: ; preds = %25
%107 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %178
109: ; preds = %106
%110 = icmp ult i32 %0, 5
br i1 %110, label %111, label %115
111: ; preds = %109
%112 = load i32, i32* @stderr
%113 = tail call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%114 = tail call i32 @exit(i32 1)
unreachable
115: ; preds = %109
%116 = getelementptr inbounds i8*, i8** %1, i64 4
%117 = load i8*, i8** %116
%118 = tail call i64 @atoi(i8* %117)
%119 = and i64 %118, 15
%120 = icmp ne i64 %119, 0
%121 = icmp ugt i64 %118, 8388608
%122 = or i1 %121, %120
br i1 %122, label %123, label %127
123: ; preds = %115
%124 = load i32, i32* @stderr
%125 = tail call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 16, i32 8388608)
%126 = tail call i32 @exit(i32 1)
unreachable
127: ; preds = %115
%128 = tail call i8* @malloc(i64 %118)
%129 = icmp eq i8* %128, null
br i1 %129, label %130, label %134
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = tail call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i64 %118)
%133 = tail call i32 @exit(i32 1)
unreachable
134: ; preds = %127
%135 = getelementptr inbounds i8*, i8** %1, i64 3
%136 = load i8*, i8** %135
%137 = tail call i32* @fopen(i8* %136, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%138 = icmp eq i32* %137, null
br i1 %138, label %139, label %142
139: ; preds = %134
%140 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%141 = tail call i32 @exit(i32 5)
unreachable
142: ; preds = %134
%143 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%144 = icmp eq i64 %118, 0
br i1 %144, label %164, label %145
145: ; preds = %142, %158
%146 = phi i64 [ %160, %158 ], [ 0, %142 ]
%147 = trunc i64 %146 to i32
%148 = getelementptr inbounds i8, i8* %128, i64 %146
%149 = tail call i64 @vct_transfer(i32 %13, i32 %147, i32 16, i8* %148, i32 35)
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %162
151: ; preds = %145
%152 = and i32 %147, 1008
%153 = icmp eq i32 %152, 0
br i1 %153, label %154, label %158
154: ; preds = %151
%155 = tail call i32 @putchar(i32 46)
%156 = load i32, i32* @stdout
%157 = tail call i32 @fflush(i32 %156)
br label %158
158: ; preds = %151, %154
%159 = add i32 %147, 16
%160 = zext i32 %159 to i64
%161 = icmp ugt i64 %118, %160
br i1 %161, label %145, label %164
162: ; preds = %145
%163 = trunc i64 %146 to i32
br label %164
164: ; preds = %158, %162, %142
%165 = phi i32 [ 0, %142 ], [ %163, %162 ], [ %159, %158 ]
%166 = phi i32 [ 0, %142 ], [ 10, %162 ], [ 0, %158 ]
%167 = zext i32 %165 to i64
%168 = icmp eq i64 %118, %167
br i1 %168, label %169, label %171
169: ; preds = %164
%170 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.24, i64 0, i64 0))
br label %171
171: ; preds = %169, %164
%172 = tail call i32 @fwrite(i8* %128, i32 1, i32 %165, i32* %137)
%173 = icmp eq i32 %172, %165
br i1 %173, label %181, label %174
174: ; preds = %171
%175 = load i32, i32* @stderr
%176 = tail call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0))
%177 = tail call i32 @exit(i32 5)
unreachable
178: ; preds = %106
%179 = tail call i32 (...) @usage()
%180 = tail call i32 @exit(i32 1)
unreachable
181: ; preds = %99, %104, %171
%182 = phi i8* [ %128, %171 ], [ %55, %104 ], [ %55, %99 ]
%183 = phi i32 [ %166, %171 ], [ %101, %104 ], [ %101, %99 ]
%184 = phi i32* [ %137, %171 ], [ %35, %104 ], [ %35, %99 ]
%185 = tail call i32 @fclose(i32* %184)
%186 = tail call i32 @free(i8* %182)
%187 = tail call i32 @close(i32 %13)
ret i32 %183
}