#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*/ warnbuf;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int O_WRONLY;
int /*<<< orphan*/ close(int);
scalar_t__ eeprom_read(int, unsigned int, int, unsigned char *, int);
scalar_t__ eeprom_write(int, unsigned int, int, unsigned char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int open(char *, int, ...);
char *optarg;
int /*<<< orphan*/ perror(char *);
int read(int, unsigned char *, int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strncmp(unsigned char *, char *, int);
int write(int, unsigned char *, int);
int main(int argc, char **argv) {
  int i, j;
  int d;
  char *dn = "/dev/i2c-0";
  int f = -1;
  char *fn = NULL;
  unsigned int addr = 0x50;
  int rwmode = 0;
  int pages = 8;
  int force = 0;
  while ((i = getopt(argc, argv, "d:a:p:wyf:h")) >= 0) {
    switch (i) {
    case 'h':
      fprintf(stderr, "%s [-d dev] [-a adr] [-p pgs] [-w] [-y] [-f file]\n",
              argv[0]);
      fprintf(stderr, "\tdev: device, e.g. /dev/i2c-0    (def)\n");
      fprintf(stderr, "\tadr: base address of eeprom, eg 0xA0 (def)\n");
      fprintf(stderr, "\tpgs: number of pages to read, eg 8 (def)\n");
      fprintf(stderr, "\t-w : write to eeprom (default is reading!)\n");
      fprintf(stderr,
              "\t-y : suppress warning when writing (default is to warn!)\n");
      fprintf(stderr, "\t-f file: copy eeprom contents to/from file\n");
      fprintf(stderr, "\t         (default for read is test only; for write is "
                      "all zeros)\n");
      fprintf(stderr, "Note on pages/addresses:\n");
      fprintf(stderr, "\teeproms with more than 256 byte appear as if they\n");
      fprintf(stderr,
              "\twere several eeproms with consecutive addresses on the bus\n");
      fprintf(stderr,
              "\tso we might as well address several seperate eeproms with\n");
      fprintf(stderr, "\tincreasing addresses....\n\n");
      exit(1);
      break;
    case 'd':
      dn = optarg;
      break;
    case 'a':
      if (sscanf(optarg, "0x%x", &addr) != 1) {
        fprintf(stderr, "Cannot parse '%s' as addrs., example: 0xa0\n", optarg);
        exit(1);
      }
      break;
    case 'p':
      if (sscanf(optarg, "%d", &pages) != 1) {
        fprintf(stderr, "Cannot parse '%s' as number of pages, example: 8\n",
                optarg);
        exit(1);
      }
      break;
    case 'w':
      rwmode++;
      break;
    case 'f':
      fn = optarg;
      break;
    case 'y':
      force++;
      break;
    }
  }
  fprintf(stderr, "base-address of eeproms       : 0x%02x\n", addr);
  fprintf(stderr, "number of pages to read       : %d (0x%02x .. 0x%02x)\n",
          pages, addr, addr + pages - 1);
  if (fn) {
    if (!rwmode)
      f = open(fn, O_WRONLY | O_CREAT, 0666);
    else
      f = open(fn, O_RDONLY);
    if (f < 0) {
      fprintf(stderr, "Could not open data-file %s for reading or writing\n",
              fn);
      perror(fn);
      exit(1);
    }
    fprintf(stderr, "file opened for %7s       : %s\n",
            rwmode ? "reading" : "writing", fn);
    fprintf(stderr, "            on filedescriptor : %d\n", f);
  }
  if ((d = open(dn, O_RDWR)) < 0) {
    fprintf(stderr, "Could not open i2c at %s\n", dn);
    perror(dn);
    exit(1);
  }
  fprintf(stderr, "i2c-devicenode is             : %s\n", dn);
  fprintf(stderr, "            on filedescriptor : %d\n\n", d);
  if (rwmode && !force) {
    unsigned char warnbuf[4];
    fprintf(stderr, "**WARNING**\n");
    fprintf(stderr, " - \tYou have chosen to WRITE to this eeprom.\n");
    fprintf(stderr, "\tMake sure that this tiny chip is *NOT* vital to the\n");
    fprintf(stderr, "\toperation of your computer as you can easily corrupt\n");
    fprintf(stderr,
            "\tthe configuration memory of your SDRAM-memory-module,\n");
    fprintf(stderr,
            "\tyour IBM ThinkPad or whatnot...! Fixing these errors can be\n");
    fprintf(stderr, "\ta time-consuming and very costly process!\n\n");
    fprintf(stderr, "Things to consider:\n");
    fprintf(
        stderr,
        " - \tYou can have more than one i2c-bus, check in /proc/bus/i2c\n");
    fprintf(stderr, "\tand specify the correct one with -d\n");
    fprintf(stderr, "\tright now you have chosen to use '%s'\n", dn);
    fprintf(stderr,
            " - \tA eeprom can occupy several i2c-addresses (one per page)\n");
    fprintf(stderr, "\tso please make sure that there is no vital eeprom in "
                    "your computer\n");
    fprintf(stderr, "\tsitting at addresses between 0x%02x and 0x%02x\n", addr,
            addr + pages - 1);
    fprintf(stderr, "Enter 'yes' to continue:");
    fflush(stderr);
    if (!fgets(warnbuf, sizeof(warnbuf), stdin)) {
      fprintf(stderr, "\nCould not read confirmation from stdin!\n");
      exit(1);
    }
    if (strncmp(warnbuf, "yes", 3)) {
      fprintf(stderr, "\n** ABORTING WRITE! **, you did not answer 'yes'\n");
      exit(1);
    }
  }
  for (i = 0; i < pages; i++) {
    unsigned char buf[256];
    if (rwmode) {
      if (f >= 0) {
        j = read(f, buf, sizeof(buf));
        if (j < 0) {
          fprintf(stderr, "Cannot read from file '%s'\n", fn);
          perror(fn);
          exit(1);
        }
        if (j != sizeof(buf)) {
          fprintf(stderr,
                  "File '%s' is too small, padding eeprom with zeroes\n", fn);
          while (j < sizeof(buf))
            buf[j++] = 0;
        }
      } else {
        for (j = 0; j < sizeof(buf); j++)
          buf[j] = 0;
      }
      for (j = 0; j < (256 / 8); j++)
        if (eeprom_write(d, addr + i, j * 8, buf + (j * 8), 8) < 0)
          exit(1);
    } else {
      for (j = 0; j < (256 / 8); j++)
        if (eeprom_read(d, addr + i, j * 8, buf + (j * 8), 8) < 0)
          exit(1);
    }
    if (!rwmode && f >= 0) {
      j = write(f, buf, sizeof(buf));
      if (j != sizeof(buf)) {
        fprintf(stderr, "Cannot write to file '%s'\n", fn);
        perror(fn);
        exit(1);
      }
    }
  }
  if (f >= 0)
    close(f);
  close(d);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe64(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x50,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x8,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe32(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     14a5 <main+0x2c5>
mov    -0x14(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x158(%rbp)
sub    $0x18,%eax
ja     14a0 <main+0x2c0>
mov    -0x158(%rbp),%rax
lea    0xd8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    0xeda(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
lea    0xf00(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
lea    0xf25(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    14a0 <main+0x2c0>
mov    0x2c1d(%rip),%rax
mov    (%rax),%rdi
lea    0xf0c(%rip),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     141c <main+0x23c>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
mov    0x2bef(%rip),%rax
mov    (%rax),%rdx
lea    0xee3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    14a0 <main+0x2c0>
mov    0x2bc8(%rip),%rax
mov    (%rax),%rdi
lea    0xee8(%rip),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1471 <main+0x291>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
mov    0x2b9a(%rip),%rax
mov    (%rax),%rdx
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    14a0 <main+0x2c0>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    14a0 <main+0x2c0>
mov    0x2b65(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    14a0 <main+0x2c0>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    122f <main+0x4f>
mov    0x2b0c(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
add    -0x44(%rbp),%r8d
sub    $0x1,%r8d
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpq   $0x0,-0x38(%rbp)
je     15c3 <main+0x3e3>
cmpl   $0x0,-0x40(%rbp)
jne    1527 <main+0x347>
mov    -0x38(%rbp),%rdi
mov    0x2aa0(%rip),%rax
mov    (%rax),%esi
mov    0x2ae7(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x2c(%rbp)
jmp    153e <main+0x35e>
mov    -0x38(%rbp),%rdi
mov    0x2a9e(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1576 <main+0x396>
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2a3b(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%ecx
lea    0xe81(%rip),%rdx
lea    0xe72(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x38(%rbp),%rcx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2a08(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    0x2a0a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1611 <main+0x431>
mov    0x29ce(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x29a0(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2985(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x0,-0x40(%rbp)
je     1857 <main+0x677>
cmpl   $0x0,-0x48(%rbp)
jne    1857 <main+0x677>
mov    0x2957(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2940(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2929(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2912(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28fb(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28e4(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28cd(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28b6(%rip),%rax
mov    (%rax),%edi
lea    0xed9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x289f(%rip),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2888(%rip),%rax
mov    (%rax),%edi
lea    0xf00(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2871(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xf0b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2856(%rip),%rax
mov    (%rax),%edi
lea    0xf1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x283f(%rip),%rax
mov    (%rax),%edi
lea    0xf43(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2828(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
mov    -0x3c(%rbp),%ecx
add    -0x44(%rbp),%ecx
sub    $0x1,%ecx
lea    0xf65(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2805(%rip),%rax
mov    (%rax),%edi
lea    0xf7f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x27ee(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x4c(%rbp),%rdi
mov    0x27ec(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1070 <fgets@plt>
cmp    $0x0,%eax
jne    1812 <main+0x632>
mov    0x27c0(%rip),%rax
mov    (%rax),%edi
lea    0xf53(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x4c(%rbp),%rdi
lea    0xf61(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1852 <main+0x672>
mov    0x2780(%rip),%rax
mov    (%rax),%edi
lea    0xf41(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1857 <main+0x677>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1ab5 <main+0x8d5>
cmpl   $0x0,-0x40(%rbp)
je     19cb <main+0x7eb>
cmpl   $0x0,-0x2c(%rbp)
jl     192c <main+0x74c>
mov    -0x2c(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x100,%edx
call   1060 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    18cd <main+0x6ed>
mov    0x2712(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xf01(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
je     1927 <main+0x747>
mov    0x26d4(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xedf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
jae    1922 <main+0x742>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
cltq
movb   $0x0,-0x150(%rbp,%rax,1)
jmp    18f8 <main+0x718>
jmp    1927 <main+0x747>
jmp    1962 <main+0x782>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
jae    195d <main+0x77d>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1933 <main+0x753>
jmp    1962 <main+0x782>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    19c6 <main+0x7e6>
mov    -0x1c(%rbp),%edi
mov    -0x3c(%rbp),%esi
add    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
shl    $0x3,%edx
lea    -0x150(%rbp),%rcx
mov    -0x18(%rbp),%eax
shl    $0x3,%eax
cltq
add    %rax,%rcx
mov    $0x8,%r8d
call   1100 <eeprom_write@plt>
cmp    $0x0,%rax
jge    19b3 <main+0x7d3>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    19b8 <main+0x7d8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1969 <main+0x789>
jmp    1a34 <main+0x854>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    1a2f <main+0x84f>
mov    -0x1c(%rbp),%edi
mov    -0x3c(%rbp),%esi
add    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
shl    $0x3,%edx
lea    -0x150(%rbp),%rcx
mov    -0x18(%rbp),%eax
shl    $0x3,%eax
cltq
add    %rax,%rcx
mov    $0x8,%r8d
call   10e0 <eeprom_read@plt>
cmp    $0x0,%rax
jge    1a1c <main+0x83c>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1a21 <main+0x841>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    19d2 <main+0x7f2>
jmp    1a34 <main+0x854>
cmpl   $0x0,-0x40(%rbp)
jne    1aa2 <main+0x8c2>
cmpl   $0x0,-0x2c(%rbp)
jl     1aa2 <main+0x8c2>
mov    -0x2c(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x100,%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
je     1a9d <main+0x8bd>
mov    0x2542(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1aa2 <main+0x8c2>
jmp    1aa7 <main+0x8c7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    185e <main+0x67e>
cmpl   $0x0,-0x2c(%rbp)
jl     1ac7 <main+0x8e7>
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x50,0x8(%rsp)
movl   $0x8,0xc(%rsp)
lea    0xe52(%rip),%rdx
call   10e0 <getopt@plt>
test   %eax,%eax
js     12ee <main+0xfe>
lea    0xe33(%rip),%rcx
mov    %rcx,0x18(%rsp)
lea    0xe32(%rip),%r14
lea    0xdbc(%rip),%r13
mov    0x2da5(%rip),%r15
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x10(%rsp)
jmp    1285 <main+0x95>
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
test   %eax,%eax
js     130a <main+0x11a>
add    $0xffffff9f,%eax
cmp    $0x18,%eax
ja     1270 <main+0x80>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%r15),%rdi
lea    0x1048(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <main+0x80>
jmp    18d0 <main+0x6e0>
mov    (%r15),%rdi
lea    0x1059(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <main+0x80>
jmp    18e5 <main+0x6f5>
mov    (%r15),%rax
mov    %rax,0x10(%rsp)
jmp    1270 <main+0x80>
addl   $0x1,0x4(%rsp)
jmp    1270 <main+0x80>
add    $0x1,%r12d
jmp    1270 <main+0x80>
xor    %r15d,%r15d
lea    0xd6c(%rip),%r13
mov    $0x50,%edx
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
jmp    1318 <main+0x128>
mov    0x8(%rsp),%edx
mov    0x10(%rsp),%r15
mov    0x18(%rsp),%r13
mov    0x2c99(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x1026(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    (%rdx,%rcx,1),%r8d
add    $0xffffffff,%r8d
lea    0x102d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%r14d
test   %r15,%r15
je     13f9 <main+0x209>
cmpl   $0x0,0x4(%rsp)
jne    138a <main+0x19a>
mov    0x2c3a(%rip),%rax
mov    0x2c83(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r15,%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   10c0 <open@plt>
jmp    139d <main+0x1ad>
mov    0x2c3f(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%edi
test   %eax,%eax
jns    13bd <main+0x1cd>
lea    0x1000(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r15,%rdi
jmp    1427 <main+0x237>
cmpl   $0x0,0x4(%rsp)
lea    0x1041(%rip),%rax
lea    0x1032(%rip),%rdx
cmove  %rax,%rdx
lea    0x1007(%rip),%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x1023(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2bd8(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    0x0(%rbp),%edi
test   %eax,%eax
jns    1436 <main+0x246>
lea    0x101c(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r13,%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %eax,%ebx
lea    0x1011(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x1021(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
cmpl   $0x0,0x4(%rsp)
je     15d2 <main+0x3e2>
test   %r12d,%r12d
jne    15d2 <main+0x3e2>
mov    0x0(%rbp),%edi
lea    0x101f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x101b(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x1038(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x105d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x1083(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x10aa(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x10d7(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x10f3(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x10f7(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x1126(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x113b(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x114f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x117c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%eax
lea    (%rdx,%rax,1),%ecx
add    $0xffffffff,%ecx
lea    0x11a2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x11c2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
call   10a0 <fflush@plt>
mov    0x2a39(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
call   1080 <fgets@plt>
test   %eax,%eax
jne    15b3 <main+0x3c3>
mov    0x0(%rbp),%edi
lea    0x11a6(%rip),%rsi
jmp    1913 <main+0x723>
lea    0x11c4(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1909 <main+0x719>
mov    %r15,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    17c9 <main+0x5d9>
cmpl   $0x0,0x4(%rsp)
sete   %al
test   %r14d,%r14d
setns  %r13b
and    %al,%r13b
lea    0x20(%rsp),%r15
xor    %r12d,%r12d
jmp    160f <main+0x41f>
xchg   %ax,%ax
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jge    17c9 <main+0x5d9>
cmpl   $0x0,0x4(%rsp)
je     1690 <main+0x4a0>
test   %r14d,%r14d
js     16e0 <main+0x4f0>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
js     1924 <main+0x734>
mov    %eax,%ebp
cmp    $0x100,%eax
je     1680 <main+0x490>
mov    0x2971(%rip),%rax
mov    (%rax),%edi
lea    0x1180(%rip),%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
cmp    $0xff,%ebp
ja     1680 <main+0x490>
mov    %ebp,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
mov    $0xff,%edx
sub    %ebp,%edx
add    $0x1,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %ebp,%ebp
jmp    1760 <main+0x570>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%esi
add    %r12d,%esi
lea    (%rsp,%rbp,1),%rcx
add    $0x20,%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x8,%r8d
call   10f0 <eeprom_read@plt>
test   %rax,%rax
js     17e4 <main+0x5f4>
add    $0x8,%rbp
cmp    $0x100,%rbp
jne    16a0 <main+0x4b0>
jmp    1790 <main+0x5a0>
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%esi
add    %r12d,%esi
lea    (%rsp,%rbp,1),%rcx
add    $0x20,%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x8,%r8d
call   1110 <eeprom_write@plt>
test   %rax,%rax
js     17e4 <main+0x5f4>
add    $0x8,%rbp
cmp    $0x100,%rbp
jne    1760 <main+0x570>
test   %r13b,%r13b
je     1600 <main+0x410>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1040 <write@plt>
cmp    $0x100,%eax
je     1600 <main+0x410>
mov    0x27fd(%rip),%rax
mov    (%rax),%edi
lea    0x1040(%rip),%rsi
jmp    1934 <main+0x744>
test   %r14d,%r14d
js     17d6 <main+0x5e6>
mov    %r14d,%edi
call   1060 <close@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x27c3(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0x879(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x89b(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8b2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8ce(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8e8(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x904(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x92e(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x94a(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x97c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x985(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9a8(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9d4(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9ff(%rip),%rsi
jmp    1913 <main+0x723>
mov    0x26e1(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xa0b(%rip),%rsi
jmp    18f8 <main+0x708>
mov    0x26cc(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xa25(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x0(%rbp),%edi
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x268d(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
jmp    1427 <main+0x237>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-0\00"
@.str.1 = [12 x i8] c"d:a:p:wyf:h\00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"%s [-d dev] [-a adr] [-p pgs] [-w] [-y] [-f file]\0A\00"
@.str.3 = [40 x i8] c"\09dev: device, e.g. /dev/i2c-0 (def)\0A\00"
@.str.4 = [45 x i8] c"\09adr: base address of eeprom, eg 0xA0 (def)\0A\00"
@.str.5 = [43 x i8] c"\09pgs: number of pages to read, eg 8 (def)\0A\00"
@.str.6 = [45 x i8] c"\09-w : write to eeprom (default is reading!)\0A\00"
@.str.7 = [59 x i8] c"\09-y : suppress warning when writing (default is to warn!)\0A\00"
@.str.8 = [45 x i8] c"\09-f file: copy eeprom contents to/from file\0A\00"
@.str.9 = [67 x i8] c"\09 (default for read is test only; for write is all zeros)\0A\00"
@.str.10 = [26 x i8] c"Note on pages/addresses:\0A\00"
@.str.11 = [52 x i8] c"\09eeproms with more than 256 byte appear as if they\0A\00"
@.str.12 = [61 x i8] c"\09were several eeproms with consecutive addresses on the bus\0A\00"
@.str.13 = [60 x i8] c"\09so we might as well address several seperate eeproms with\0A\00"
@.str.14 = [28 x i8] c"\09increasing addresses....\0A\0A\00"
@optarg = global i8* null
@.str.15 = [5 x i8] c"0x%x\00"
@.str.16 = [44 x i8] c"Cannot parse '%s' as addrs., example: 0xa0\0A\00"
@.str.17 = [3 x i8] c"%d\00"
@.str.18 = [50 x i8] c"Cannot parse '%s' as number of pages, example: 8\0A\00"
@.str.19 = [40 x i8] c"base-address of eeproms : 0x%02x\0A\00"
@.str.20 = [55 x i8] c"number of pages to read : %d (0x%02x .. 0x%02x)\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.21 = [52 x i8] c"Could not open data-file %s for reading or writing\0A\00"
@.str.22 = [32 x i8] c"file opened for %7s : %s\0A\00"
@.str.23 = [8 x i8] c"reading\00"
@.str.24 = [8 x i8] c"writing\00"
@.str.25 = [36 x i8] c" on filedescriptor : %d\0A\00"
@O_RDWR = global i32 0
@.str.26 = [26 x i8] c"Could not open i2c at %s\0A\00"
@.str.27 = [36 x i8] c"i2c-devicenode is : %s\0A\00"
@.str.28 = [37 x i8] c" on filedescriptor : %d\0A\0A\00"
@.str.29 = [13 x i8] c"**WARNING**\0A\00"
@.str.30 = [46 x i8] c" - \09You have chosen to WRITE to this eeprom.\0A\00"
@.str.31 = [54 x i8] c"\09Make sure that this tiny chip is *NOT* vital to the\0A\00"
@.str.32 = [55 x i8] c"\09operation of your computer as you can easily corrupt\0A\00"
@.str.33 = [56 x i8] c"\09the configuration memory of your SDRAM-memory-module,\0A\00"
@.str.34 = [62 x i8] c"\09your IBM ThinkPad or whatnot...! Fixing these errors can be\0A\00"
@.str.35 = [45 x i8] c"\09a time-consuming and very costly process!\0A\0A\00"
@.str.36 = [21 x i8] c"Things to consider:\0A\00"
@.str.37 = [64 x i8] c" - \09You can have more than one i2c-bus, check in /proc/bus/i2c\0A\00"
@.str.38 = [38 x i8] c"\09and specify the correct one with -d\0A\00"
@.str.39 = [40 x i8] c"\09right now you have chosen to use '%s'\0A\00"
@.str.40 = [62 x i8] c" - \09A eeprom can occupy several i2c-addresses (one per page)\0A\00"
@.str.41 = [69 x i8] c"\09so please make sure that there is no vital eeprom in your computer\0A\00"
@.str.42 = [49 x i8] c"\09sitting at addresses between 0x%02x and 0x%02x\0A\00"
@.str.43 = [25 x i8] c"Enter 'yes' to continue:\00"
@stdin = global i32 0
@.str.44 = [42 x i8] c"\0ACould not read confirmation from stdin!\0A\00"
@.str.45 = [4 x i8] c"yes\00"
@.str.46 = [50 x i8] c"\0A** ABORTING WRITE! **, you did not answer 'yes'\0A\00"
@.str.47 = [28 x i8] c"Cannot read from file '%s'\0A\00"
@.str.48 = [52 x i8] c"File '%s' is too small, padding eeprom with zeroes\0A\00"
@.str.49 = [27 x i8] c"Cannot write to file '%s'\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 i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [4 x i8]
%17 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %9
store i32 -1, i32* %10
store i8* null, i8** %11
store i32 80, i32* %12
store i32 0, i32* %13
store i32 8, i32* %14
store i32 0, i32* %15
br label %18
18: ; preds = %86, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %6
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %87
23: ; preds = %18
%24 = load i32, i32* %6
switch i32 %24, label %86 [
i32 104, label %25
i32 100, label %56
i32 97, label %58
i32 112, label %68
i32 119, label %78
i32 102, label %81
i32 121, label %83
]
25: ; preds = %23
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0))
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.9, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.11, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %23
%57 = load i8*, i8** @optarg
store i8* %57, i8** %9
br label %86
58: ; preds = %23
%59 = load i8*, i8** @optarg
%60 = call i32 (i8*, i8*, ...) @sscanf(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32* %12)
%61 = icmp ne i32 %60, 1
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i8*, i8** @optarg
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.16, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %58
br label %86
68: ; preds = %23
%69 = load i8*, i8** @optarg
%70 = call i32 (i8*, i8*, ...) @sscanf(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32* %14)
%71 = icmp ne i32 %70, 1
br i1 %71, label %72, label %77
72: ; preds = %68
%73 = load i32, i32* @stderr
%74 = load i8*, i8** @optarg
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.18, i64 0, i64 0), i8* %74)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %68
br label %86
78: ; preds = %23
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 1
store i32 %80, i32* %13
br label %86
81: ; preds = %23
%82 = load i8*, i8** @optarg
store i8* %82, i8** %11
br label %86
83: ; preds = %23
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 1
store i32 %85, i32* %15
br label %86
86: ; preds = %23, %83, %81, %78, %77, %67, %56
br label %18
87: ; preds = %18
%88 = load i32, i32* @stderr
%89 = load i32, i32* %12
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %89)
%91 = load i32, i32* @stderr
%92 = load i32, i32* %14
%93 = load i32, i32* %12
%94 = load i32, i32* %12
%95 = load i32, i32* %14
%96 = add i32 %94, %95
%97 = sub i32 %96, 1
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.20, i64 0, i64 0), i32 %92, i32 %93, i32 %97)
%99 = load i8*, i8** %11
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %135
101: ; preds = %87
%102 = load i32, i32* %13
%103 = icmp ne i32 %102, 0
br i1 %103, label %110, label %104
104: ; preds = %101
%105 = load i8*, i8** %11
%106 = load i32, i32* @O_WRONLY
%107 = load i32, i32* @O_CREAT
%108 = or i32 %106, %107
%109 = call i32 (i8*, i32, ...) @open(i8* %105, i32 %108, i32 438)
store i32 %109, i32* %10
br label %114
110: ; preds = %101
%111 = load i8*, i8** %11
%112 = load i32, i32* @O_RDONLY
%113 = call i32 (i8*, i32, ...) @open(i8* %111, i32 %112)
store i32 %113, i32* %10
br label %114
114: ; preds = %110, %104
%115 = load i32, i32* %10
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %124
117: ; preds = %114
%118 = load i32, i32* @stderr
%119 = load i8*, i8** %11
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0), i8* %119)
%121 = load i8*, i8** %11
%122 = call i32 @perror(i8* %121)
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %114
%125 = load i32, i32* @stderr
%126 = load i32, i32* %13
%127 = icmp ne i32 %126, 0
%128 = zext i1 %127 to i64
%129 = select i1 %127, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0)
%130 = load i8*, i8** %11
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i64 0, i64 0), i8* %129, i8* %130)
%132 = load i32, i32* @stderr
%133 = load i32, i32* %10
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.25, i64 0, i64 0), i32 %133)
br label %135
135: ; preds = %124, %87
%136 = load i8*, i8** %9
%137 = load i32, i32* @O_RDWR
%138 = call i32 (i8*, i32, ...) @open(i8* %136, i32 %137)
store i32 %138, i32* %8
%139 = icmp slt i32 %138, 0
br i1 %139, label %140, label %147
140: ; preds = %135
%141 = load i32, i32* @stderr
%142 = load i8*, i8** %9
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.26, i64 0, i64 0), i8* %142)
%144 = load i8*, i8** %9
%145 = call i32 @perror(i8* %144)
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %135
%148 = load i32, i32* @stderr
%149 = load i8*, i8** %9
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.27, i64 0, i64 0), i8* %149)
%151 = load i32, i32* @stderr
%152 = load i32, i32* %8
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.28, i64 0, i64 0), i32 %152)
%154 = load i32, i32* %13
%155 = icmp ne i32 %154, 0
br i1 %155, label %156, label %215
156: ; preds = %147
%157 = load i32, i32* %15
%158 = icmp ne i32 %157, 0
br i1 %158, label %215, label %159
159: ; preds = %156
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.29, i64 0, i64 0))
%162 = load i32, i32* @stderr
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.30, i64 0, i64 0))
%164 = load i32, i32* @stderr
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.31, i64 0, i64 0))
%166 = load i32, i32* @stderr
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.32, i64 0, i64 0))
%168 = load i32, i32* @stderr
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.33, i64 0, i64 0))
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i64 0, i64 0))
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.35, i64 0, i64 0))
%174 = load i32, i32* @stderr
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.36, i64 0, i64 0))
%176 = load i32, i32* @stderr
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.37, i64 0, i64 0))
%178 = load i32, i32* @stderr
%179 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.38, i64 0, i64 0))
%180 = load i32, i32* @stderr
%181 = load i8*, i8** %9
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.39, i64 0, i64 0), i8* %181)
%183 = load i32, i32* @stderr
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %183, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.40, i64 0, i64 0))
%185 = load i32, i32* @stderr
%186 = call i32 (i32, i8*, ...) @fprintf(i32 %185, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.41, i64 0, i64 0))
%187 = load i32, i32* @stderr
%188 = load i32, i32* %12
%189 = load i32, i32* %12
%190 = load i32, i32* %14
%191 = add i32 %189, %190
%192 = sub i32 %191, 1
%193 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.42, i64 0, i64 0), i32 %188, i32 %192)
%194 = load i32, i32* @stderr
%195 = call i32 (i32, i8*, ...) @fprintf(i32 %194, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.43, i64 0, i64 0))
%196 = load i32, i32* @stderr
%197 = call i32 @fflush(i32 %196)
%198 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%199 = load i32, i32* @stdin
%200 = call i32 @fgets(i8* %198, i32 4, i32 %199)
%201 = icmp ne i32 %200, 0
br i1 %201, label %206, label %202
202: ; preds = %159
%203 = load i32, i32* @stderr
%204 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.44, i64 0, i64 0))
%205 = call i32 @exit(i32 1)
unreachable
206: ; preds = %159
%207 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%208 = call i64 @strncmp(i8* %207, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.45, i64 0, i64 0), i32 3)
%209 = icmp ne i64 %208, 0
br i1 %209, label %210, label %214
210: ; preds = %206
%211 = load i32, i32* @stderr
%212 = call i32 (i32, i8*, ...) @fprintf(i32 %211, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.46, i64 0, i64 0))
%213 = call i32 @exit(i32 1)
unreachable
214: ; preds = %206
br label %215
215: ; preds = %214, %156, %147
store i32 0, i32* %6
br label %216
216: ; preds = %343, %215
%217 = load i32, i32* %6
%218 = load i32, i32* %14
%219 = icmp slt i32 %217, %218
br i1 %219, label %220, label %346
220: ; preds = %216
%221 = load i32, i32* %13
%222 = icmp ne i32 %221, 0
br i1 %222, label %223, label %296
223: ; preds = %220
%224 = load i32, i32* %10
%225 = icmp sge i32 %224, 0
br i1 %225, label %226, label %258
226: ; preds = %223
%227 = load i32, i32* %10
%228 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%229 = call i32 @read(i32 %227, i8* %228, i32 256)
store i32 %229, i32* %7
%230 = load i32, i32* %7
%231 = icmp slt i32 %230, 0
br i1 %231, label %232, label %239
232: ; preds = %226
%233 = load i32, i32* @stderr
%234 = load i8*, i8** %11
%235 = call i32 (i32, i8*, ...) @fprintf(i32 %233, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.47, i64 0, i64 0), i8* %234)
%236 = load i8*, i8** %11
%237 = call i32 @perror(i8* %236)
%238 = call i32 @exit(i32 1)
unreachable
239: ; preds = %226
%240 = load i32, i32* %7
%241 = sext i32 %240 to i64
%242 = icmp ne i64 %241, 256
br i1 %242, label %243, label %257
243: ; preds = %239
%244 = load i32, i32* @stderr
%245 = load i8*, i8** %11
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %244, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.48, i64 0, i64 0), i8* %245)
br label %247
247: ; preds = %251, %243
%248 = load i32, i32* %7
%249 = sext i32 %248 to i64
%250 = icmp ult i64 %249, 256
br i1 %250, label %251, label %256
251: ; preds = %247
%252 = load i32, i32* %7
%253 = add nsw i32 %252, 1
store i32 %253, i32* %7
%254 = sext i32 %252 to i64
%255 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 %254
store i8 0, i8* %255
br label %247
256: ; preds = %247
br label %257
257: ; preds = %256, %239
br label %271
258: ; preds = %223
store i32 0, i32* %7
br label %259
259: ; preds = %267, %258
%260 = load i32, i32* %7
%261 = sext i32 %260 to i64
%262 = icmp ult i64 %261, 256
br i1 %262, label %263, label %270
263: ; preds = %259
%264 = load i32, i32* %7
%265 = sext i32 %264 to i64
%266 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 %265
store i8 0, i8* %266
br label %267
267: ; preds = %263
%268 = load i32, i32* %7
%269 = add nsw i32 %268, 1
store i32 %269, i32* %7
br label %259
270: ; preds = %259
br label %271
271: ; preds = %270, %257
store i32 0, i32* %7
br label %272
272: ; preds = %292, %271
%273 = load i32, i32* %7
%274 = icmp slt i32 %273, 32
br i1 %274, label %275, label %295
275: ; preds = %272
%276 = load i32, i32* %8
%277 = load i32, i32* %12
%278 = load i32, i32* %6
%279 = add i32 %277, %278
%280 = load i32, i32* %7
%281 = mul nsw i32 %280, 8
%282 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%283 = load i32, i32* %7
%284 = mul nsw i32 %283, 8
%285 = sext i32 %284 to i64
%286 = getelementptr inbounds i8, i8* %282, i64 %285
%287 = call i64 @eeprom_write(i32 %276, i32 %279, i32 %281, i8* %286, i32 8)
%288 = icmp slt i64 %287, 0
br i1 %288, label %289, label %291
289: ; preds = %275
%290 = call i32 @exit(i32 1)
unreachable
291: ; preds = %275
br label %292
292: ; preds = %291
%293 = load i32, i32* %7
%294 = add nsw i32 %293, 1
store i32 %294, i32* %7
br label %272
295: ; preds = %272
br label %321
296: ; preds = %220
store i32 0, i32* %7
br label %297
297: ; preds = %317, %296
%298 = load i32, i32* %7
%299 = icmp slt i32 %298, 32
br i1 %299, label %300, label %320
300: ; preds = %297
%301 = load i32, i32* %8
%302 = load i32, i32* %12
%303 = load i32, i32* %6
%304 = add i32 %302, %303
%305 = load i32, i32* %7
%306 = mul nsw i32 %305, 8
%307 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%308 = load i32, i32* %7
%309 = mul nsw i32 %308, 8
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds i8, i8* %307, i64 %310
%312 = call i64 @eeprom_read(i32 %301, i32 %304, i32 %306, i8* %311, i32 8)
%313 = icmp slt i64 %312, 0
br i1 %313, label %314, label %316
314: ; preds = %300
%315 = call i32 @exit(i32 1)
unreachable
316: ; preds = %300
br label %317
317: ; preds = %316
%318 = load i32, i32* %7
%319 = add nsw i32 %318, 1
store i32 %319, i32* %7
br label %297
320: ; preds = %297
br label %321
321: ; preds = %320, %295
%322 = load i32, i32* %13
%323 = icmp ne i32 %322, 0
br i1 %323, label %342, label %324
324: ; preds = %321
%325 = load i32, i32* %10
%326 = icmp sge i32 %325, 0
br i1 %326, label %327, label %342
327: ; preds = %324
%328 = load i32, i32* %10
%329 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%330 = call i32 @write(i32 %328, i8* %329, i32 256)
store i32 %330, i32* %7
%331 = load i32, i32* %7
%332 = sext i32 %331 to i64
%333 = icmp ne i64 %332, 256
br i1 %333, label %334, label %341
334: ; preds = %327
%335 = load i32, i32* @stderr
%336 = load i8*, i8** %11
%337 = call i32 (i32, i8*, ...) @fprintf(i32 %335, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.49, i64 0, i64 0), i8* %336)
%338 = load i8*, i8** %11
%339 = call i32 @perror(i8* %338)
%340 = call i32 @exit(i32 1)
unreachable
341: ; preds = %327
br label %342
342: ; preds = %341, %324, %321
br label %343
343: ; preds = %342
%344 = load i32, i32* %6
%345 = add nsw i32 %344, 1
store i32 %345, i32* %6
br label %216
346: ; preds = %216
%347 = load i32, i32* %10
%348 = icmp sge i32 %347, 0
br i1 %348, label %349, label %352
349: ; preds = %346
%350 = load i32, i32* %10
%351 = call i32 @close(i32 %350)
br label %352
352: ; preds = %349, %346
%353 = load i32, i32* %8
%354 = call i32 @close(i32 %353)
%355 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-0\00"
@.str.1 = [12 x i8] c"d:a:p:wyf:h\00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"%s [-d dev] [-a adr] [-p pgs] [-w] [-y] [-f file]\0A\00"
@.str.3 = [40 x i8] c"\09dev: device, e.g. /dev/i2c-0 (def)\0A\00"
@.str.4 = [45 x i8] c"\09adr: base address of eeprom, eg 0xA0 (def)\0A\00"
@.str.5 = [43 x i8] c"\09pgs: number of pages to read, eg 8 (def)\0A\00"
@.str.6 = [45 x i8] c"\09-w : write to eeprom (default is reading!)\0A\00"
@.str.7 = [59 x i8] c"\09-y : suppress warning when writing (default is to warn!)\0A\00"
@.str.8 = [45 x i8] c"\09-f file: copy eeprom contents to/from file\0A\00"
@.str.9 = [67 x i8] c"\09 (default for read is test only; for write is all zeros)\0A\00"
@.str.10 = [26 x i8] c"Note on pages/addresses:\0A\00"
@.str.11 = [52 x i8] c"\09eeproms with more than 256 byte appear as if they\0A\00"
@.str.12 = [61 x i8] c"\09were several eeproms with consecutive addresses on the bus\0A\00"
@.str.13 = [60 x i8] c"\09so we might as well address several seperate eeproms with\0A\00"
@.str.14 = [28 x i8] c"\09increasing addresses....\0A\0A\00"
@optarg = global i8* null
@.str.15 = [5 x i8] c"0x%x\00"
@.str.16 = [44 x i8] c"Cannot parse '%s' as addrs., example: 0xa0\0A\00"
@.str.17 = [3 x i8] c"%d\00"
@.str.18 = [50 x i8] c"Cannot parse '%s' as number of pages, example: 8\0A\00"
@.str.19 = [40 x i8] c"base-address of eeproms : 0x%02x\0A\00"
@.str.20 = [55 x i8] c"number of pages to read : %d (0x%02x .. 0x%02x)\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.21 = [52 x i8] c"Could not open data-file %s for reading or writing\0A\00"
@.str.22 = [32 x i8] c"file opened for %7s : %s\0A\00"
@.str.23 = [8 x i8] c"reading\00"
@.str.24 = [8 x i8] c"writing\00"
@.str.25 = [36 x i8] c" on filedescriptor : %d\0A\00"
@O_RDWR = global i32 0
@.str.26 = [26 x i8] c"Could not open i2c at %s\0A\00"
@.str.27 = [36 x i8] c"i2c-devicenode is : %s\0A\00"
@.str.28 = [37 x i8] c" on filedescriptor : %d\0A\0A\00"
@.str.29 = [13 x i8] c"**WARNING**\0A\00"
@.str.30 = [46 x i8] c" - \09You have chosen to WRITE to this eeprom.\0A\00"
@.str.31 = [54 x i8] c"\09Make sure that this tiny chip is *NOT* vital to the\0A\00"
@.str.32 = [55 x i8] c"\09operation of your computer as you can easily corrupt\0A\00"
@.str.33 = [56 x i8] c"\09the configuration memory of your SDRAM-memory-module,\0A\00"
@.str.34 = [62 x i8] c"\09your IBM ThinkPad or whatnot...! Fixing these errors can be\0A\00"
@.str.35 = [45 x i8] c"\09a time-consuming and very costly process!\0A\0A\00"
@.str.36 = [21 x i8] c"Things to consider:\0A\00"
@.str.37 = [64 x i8] c" - \09You can have more than one i2c-bus, check in /proc/bus/i2c\0A\00"
@.str.38 = [38 x i8] c"\09and specify the correct one with -d\0A\00"
@.str.39 = [40 x i8] c"\09right now you have chosen to use '%s'\0A\00"
@.str.40 = [62 x i8] c" - \09A eeprom can occupy several i2c-addresses (one per page)\0A\00"
@.str.41 = [69 x i8] c"\09so please make sure that there is no vital eeprom in your computer\0A\00"
@.str.42 = [49 x i8] c"\09sitting at addresses between 0x%02x and 0x%02x\0A\00"
@.str.43 = [25 x i8] c"Enter 'yes' to continue:\00"
@stdin = global i32 0
@.str.44 = [42 x i8] c"\0ACould not read confirmation from stdin!\0A\00"
@.str.45 = [4 x i8] c"yes\00"
@.str.46 = [50 x i8] c"\0A** ABORTING WRITE! **, you did not answer 'yes'\0A\00"
@.str.47 = [28 x i8] c"Cannot read from file '%s'\0A\00"
@.str.48 = [52 x i8] c"File '%s' is too small, padding eeprom with zeroes\0A\00"
@.str.49 = [27 x i8] c"Cannot write to file '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = bitcast i32* %3 to i8*
store i32 80, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 8, i32* %4
%10 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %82
12: ; preds = %2, %73
%13 = phi i32 [ %78, %73 ], [ %10, %2 ]
%14 = phi i32 [ %77, %73 ], [ 0, %2 ]
%15 = phi i32 [ %76, %73 ], [ 0, %2 ]
%16 = phi i8* [ %75, %73 ], [ null, %2 ]
%17 = phi i8* [ %74, %73 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %2 ]
switch i32 %13, label %73 [
i32 104, label %18
i32 100, label %47
i32 97, label %49
i32 112, label %58
i32 119, label %67
i32 102, label %69
i32 121, label %71
]
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.9, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.11, i64 0, i64 0))
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.12, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %12
%48 = load i8*, i8** @optarg
br label %73
49: ; preds = %12
%50 = load i8*, i8** @optarg
%51 = call i32 (i8*, i8*, ...) @sscanf(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32* %3)
%52 = icmp eq i32 %51, 1
br i1 %52, label %73, label %53
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = load i8*, i8** @optarg
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.16, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %12
%59 = load i8*, i8** @optarg
%60 = call i32 (i8*, i8*, ...) @sscanf(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32* %4)
%61 = icmp eq i32 %60, 1
br i1 %61, label %73, label %62
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i8*, i8** @optarg
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.18, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %12
%68 = add nsw i32 %15, 1
br label %73
69: ; preds = %12
%70 = load i8*, i8** @optarg
br label %73
71: ; preds = %12
%72 = add nsw i32 %14, 1
br label %73
73: ; preds = %58, %49, %12, %71, %69, %67, %47
%74 = phi i8* [ %17, %12 ], [ %17, %71 ], [ %17, %69 ], [ %17, %67 ], [ %17, %58 ], [ %17, %49 ], [ %48, %47 ]
%75 = phi i8* [ %16, %12 ], [ %16, %71 ], [ %70, %69 ], [ %16, %67 ], [ %16, %58 ], [ %16, %49 ], [ %16, %47 ]
%76 = phi i32 [ %15, %12 ], [ %15, %71 ], [ %15, %69 ], [ %68, %67 ], [ %15, %58 ], [ %15, %49 ], [ %15, %47 ]
%77 = phi i32 [ %14, %12 ], [ %72, %71 ], [ %14, %69 ], [ %14, %67 ], [ %14, %58 ], [ %14, %49 ], [ %14, %47 ]
%78 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%79 = icmp sgt i32 %78, -1
br i1 %79, label %12, label %80
80: ; preds = %73
%81 = load i32, i32* %3
br label %82
82: ; preds = %80, %2
%83 = phi i32 [ 80, %2 ], [ %81, %80 ]
%84 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %2 ], [ %74, %80 ]
%85 = phi i8* [ null, %2 ], [ %75, %80 ]
%86 = phi i32 [ 0, %2 ], [ %76, %80 ]
%87 = phi i32 [ 0, %2 ], [ %77, %80 ]
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %83)
%90 = load i32, i32* @stderr
%91 = load i32, i32* %4
%92 = load i32, i32* %3
%93 = add i32 %91, -1
%94 = add i32 %93, %92
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.20, i64 0, i64 0), i32 %91, i32 %92, i32 %94)
%96 = icmp eq i8* %85, null
br i1 %96, label %120, label %97
97: ; preds = %82
%98 = icmp eq i32 %86, 0
br i1 %98, label %99, label %104
99: ; preds = %97
%100 = load i32, i32* @O_WRONLY
%101 = load i32, i32* @O_CREAT
%102 = or i32 %101, %100
%103 = call i32 (i8*, i32, ...) @open(i8* %85, i32 %102, i32 438)
br label %107
104: ; preds = %97
%105 = load i32, i32* @O_RDONLY
%106 = call i32 (i8*, i32, ...) @open(i8* %85, i32 %105)
br label %107
107: ; preds = %104, %99
%108 = phi i32 [ %106, %104 ], [ %103, %99 ]
%109 = icmp slt i32 %108, 0
%110 = load i32, i32* @stderr
br i1 %109, label %111, label %115
111: ; preds = %107
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0), i8* %85)
%113 = call i32 @perror(i8* %85)
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %107
%116 = select i1 %98, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0)
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i64 0, i64 0), i8* %116, i8* %85)
%118 = load i32, i32* @stderr
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.25, i64 0, i64 0), i32 %108)
br label %120
120: ; preds = %115, %82
%121 = phi i32 [ %108, %115 ], [ -1, %82 ]
%122 = load i32, i32* @O_RDWR
%123 = call i32 (i8*, i32, ...) @open(i8* %84, i32 %122)
%124 = icmp slt i32 %123, 0
%125 = load i32, i32* @stderr
br i1 %124, label %126, label %130
126: ; preds = %120
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.26, i64 0, i64 0), i8* %84)
%128 = call i32 @perror(i8* %84)
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %120
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.27, i64 0, i64 0), i8* %84)
%132 = load i32, i32* @stderr
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.28, i64 0, i64 0), i32 %123)
%134 = icmp eq i32 %86, 0
%135 = icmp ne i32 %87, 0
%136 = select i1 %134, i1 true, i1 %135
br i1 %136, label %190, label %137
137: ; preds = %130
%138 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%139 = load i32, i32* @stderr
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.29, i64 0, i64 0))
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.30, i64 0, i64 0))
%143 = load i32, i32* @stderr
%144 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.31, i64 0, i64 0))
%145 = load i32, i32* @stderr
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.32, i64 0, i64 0))
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.33, i64 0, i64 0))
%149 = load i32, i32* @stderr
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i64 0, i64 0))
%151 = load i32, i32* @stderr
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.35, i64 0, i64 0))
%153 = load i32, i32* @stderr
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.36, i64 0, i64 0))
%155 = load i32, i32* @stderr
%156 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.37, i64 0, i64 0))
%157 = load i32, i32* @stderr
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %157, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.38, i64 0, i64 0))
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.39, i64 0, i64 0), i8* %84)
%161 = load i32, i32* @stderr
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.40, i64 0, i64 0))
%163 = load i32, i32* @stderr
%164 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.41, i64 0, i64 0))
%165 = load i32, i32* @stderr
%166 = load i32, i32* %3
%167 = load i32, i32* %4
%168 = add i32 %166, -1
%169 = add i32 %168, %167
%170 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.42, i64 0, i64 0), i32 %166, i32 %169)
%171 = load i32, i32* @stderr
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %171, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.43, i64 0, i64 0))
%173 = load i32, i32* @stderr
%174 = call i32 @fflush(i32 %173)
%175 = load i32, i32* @stdin
%176 = call i32 @fgets(i8* %138, i32 4, i32 %175)
%177 = icmp eq i32 %176, 0
br i1 %177, label %178, label %182
178: ; preds = %137
%179 = load i32, i32* @stderr
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %179, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.44, i64 0, i64 0))
%181 = call i32 @exit(i32 1)
unreachable
182: ; preds = %137
%183 = call i64 @strncmp(i8* %138, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.45, i64 0, i64 0), i32 3)
%184 = icmp eq i64 %183, 0
br i1 %184, label %189, label %185
185: ; preds = %182
%186 = load i32, i32* @stderr
%187 = call i32 (i32, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.46, i64 0, i64 0))
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %182
br label %190
190: ; preds = %189, %130
%191 = load i32, i32* %4
%192 = icmp sgt i32 %191, 0
br i1 %192, label %193, label %263
193: ; preds = %190
%194 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%195 = icmp sgt i32 %121, -1
%196 = and i1 %134, %195
br label %197
197: ; preds = %193, %259
%198 = phi i32 [ 0, %193 ], [ %260, %259 ]
br i1 %134, label %239, label %199
199: ; preds = %197
br i1 %195, label %201, label %200
200: ; preds = %199
br label %221
201: ; preds = %199
%202 = call i32 @read(i32 %121, i8* %194, i32 256)
%203 = icmp slt i32 %202, 0
br i1 %203, label %204, label %209
204: ; preds = %201
%205 = load i32, i32* @stderr
%206 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.47, i64 0, i64 0), i8* %85)
%207 = call i32 @perror(i8* %85)
%208 = call i32 @exit(i32 1)
unreachable
209: ; preds = %201
%210 = icmp eq i32 %202, 256
br i1 %210, label %221, label %211
211: ; preds = %209
%212 = load i32, i32* @stderr
%213 = call i32 (i32, i8*, ...) @fprintf(i32 %212, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.48, i64 0, i64 0), i8* %85)
%214 = icmp ult i32 %202, 256
br i1 %214, label %215, label %221
215: ; preds = %211
%216 = zext i32 %202 to i64
%217 = getelementptr [256 x i8], [256 x i8]* %6, i64 0, i64 %216
%218 = sub nuw nsw i32 255, %202
%219 = zext i32 %218 to i64
%220 = add nuw nsw i64 %219, 1
br label %221
221: ; preds = %200, %215, %211, %209
br label %225
222: ; preds = %225
%223 = add nuw nsw i64 %226, 1
%224 = icmp eq i64 %223, 32
br i1 %224, label %250, label %225
225: ; preds = %221, %222
%226 = phi i64 [ %223, %222 ], [ 0, %221 ]
%227 = load i32, i32* %3
%228 = add i32 %227, %198
%229 = shl nuw nsw i64 %226, 3
%230 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %229
%231 = trunc i64 %229 to i32
%232 = call i64 @eeprom_write(i32 %123, i32 %228, i32 %231, i8* %230, i32 8)
%233 = icmp slt i64 %232, 0
br i1 %233, label %234, label %222
234: ; preds = %225
%235 = call i32 @exit(i32 1)
unreachable
236: ; preds = %239
%237 = add nuw nsw i64 %240, 1
%238 = icmp eq i64 %237, 32
br i1 %238, label %250, label %239
239: ; preds = %197, %236
%240 = phi i64 [ %237, %236 ], [ 0, %197 ]
%241 = load i32, i32* %3
%242 = add i32 %241, %198
%243 = shl nuw nsw i64 %240, 3
%244 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %243
%245 = trunc i64 %243 to i32
%246 = call i64 @eeprom_read(i32 %123, i32 %242, i32 %245, i8* %244, i32 8)
%247 = icmp slt i64 %246, 0
br i1 %247, label %248, label %236
248: ; preds = %239
%249 = call i32 @exit(i32 1)
unreachable
250: ; preds = %222, %236
br i1 %196, label %251, label %259
251: ; preds = %250
%252 = call i32 @write(i32 %121, i8* %194, i32 256)
%253 = icmp eq i32 %252, 256
br i1 %253, label %259, label %254
254: ; preds = %251
%255 = load i32, i32* @stderr
%256 = call i32 (i32, i8*, ...) @fprintf(i32 %255, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.49, i64 0, i64 0), i8* %85)
%257 = call i32 @perror(i8* %85)
%258 = call i32 @exit(i32 1)
unreachable
259: ; preds = %251, %250
%260 = add nuw nsw i32 %198, 1
%261 = load i32, i32* %4
%262 = icmp slt i32 %260, %261
br i1 %262, label %197, label %263
263: ; preds = %259, %190
%264 = icmp sgt i32 %121, -1
br i1 %264, label %265, label %267
265: ; preds = %263
%266 = call i32 @close(i32 %121)
br label %267
267: ; preds = %265, %263
%268 = call i32 @close(i32 %123)
%269 = call i32 @exit(i32 0)
unreachable
}