#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>
mov    -0x40(%rbp),%eax
cmpl   $0x0,-0x48(%rbp)
setne  %cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1861 <main+0x681>
mov    0x294d(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2936(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x291f(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2908(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28f1(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28da(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28c3(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x28ac(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2895(%rip),%rax
mov    (%rax),%edi
lea    0xecd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x287e(%rip),%rax
mov    (%rax),%edi
lea    0xef6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2867(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xf01(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x284c(%rip),%rax
mov    (%rax),%edi
lea    0xf12(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2835(%rip),%rax
mov    (%rax),%edi
lea    0xf39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x281e(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
mov    -0x3c(%rbp),%ecx
add    -0x44(%rbp),%ecx
sub    $0x1,%ecx
lea    0xf5b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x27fb(%rip),%rax
mov    (%rax),%edi
lea    0xf75(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x27e4(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x4c(%rbp),%rdi
mov    0x27e2(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1070 <fgets@plt>
cmp    $0x0,%eax
jne    181c <main+0x63c>
mov    0x27b6(%rip),%rax
mov    (%rax),%edi
lea    0xf49(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x4c(%rbp),%rdi
lea    0xf57(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     185c <main+0x67c>
mov    0x2776(%rip),%rax
mov    (%rax),%edi
lea    0xf37(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1861 <main+0x681>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1abf <main+0x8df>
cmpl   $0x0,-0x40(%rbp)
je     19d5 <main+0x7f5>
cmpl   $0x0,-0x2c(%rbp)
jl     1936 <main+0x756>
mov    -0x2c(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x100,%edx
call   1060 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    18d7 <main+0x6f7>
mov    0x2708(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xef7(%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     1931 <main+0x751>
mov    0x26ca(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
jae    192c <main+0x74c>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
cltq
movb   $0x0,-0x150(%rbp,%rax,1)
jmp    1902 <main+0x722>
jmp    1931 <main+0x751>
jmp    196c <main+0x78c>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x100,%rax
jae    1967 <main+0x787>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    193d <main+0x75d>
jmp    196c <main+0x78c>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    19d0 <main+0x7f0>
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    19bd <main+0x7dd>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    19c2 <main+0x7e2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1973 <main+0x793>
jmp    1a3e <main+0x85e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    1a39 <main+0x859>
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    1a26 <main+0x846>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1a2b <main+0x84b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    19dc <main+0x7fc>
jmp    1a3e <main+0x85e>
cmpl   $0x0,-0x40(%rbp)
jne    1aac <main+0x8cc>
cmpl   $0x0,-0x2c(%rbp)
jl     1aac <main+0x8cc>
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     1aa7 <main+0x8c7>
mov    0x2538(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd77(%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    1aac <main+0x8cc>
jmp    1ab1 <main+0x8d1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1868 <main+0x688>
cmpl   $0x0,-0x2c(%rbp)
jl     1ad1 <main+0x8f1>
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     12f5 <main+0x105>
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>
add    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
test   %eax,%eax
js     1311 <main+0x121>
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    1904 <main+0x714>
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
jmp    1270 <main+0x80>
mov    (%r15),%rdi
lea    0x104f(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <main+0x80>
jmp    1919 <main+0x729>
mov    (%r15),%rax
mov    %rax,0x10(%rsp)
jmp    1270 <main+0x80>
addl   $0x1,0x4(%rsp)
jmp    1270 <main+0x80>
xor    %r15d,%r15d
lea    0xd65(%rip),%r13
mov    $0x50,%edx
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
jmp    131f <main+0x12f>
mov    0x8(%rsp),%edx
mov    0x10(%rsp),%r15
mov    0x18(%rsp),%r13
mov    0x2c92(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x101f(%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    0x1026(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%r14d
test   %r15,%r15
je     1400 <main+0x210>
cmpl   $0x0,0x4(%rsp)
jne    1391 <main+0x1a1>
mov    0x2c33(%rip),%rax
mov    0x2c7c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r15,%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   10c0 <open@plt>
jmp    13a4 <main+0x1b4>
mov    0x2c38(%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    13c4 <main+0x1d4>
lea    0xff9(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r15,%rdi
jmp    142e <main+0x23e>
cmpl   $0x0,0x4(%rsp)
lea    0x103a(%rip),%rax
lea    0x102b(%rip),%rdx
cmove  %rax,%rdx
lea    0x1000(%rip),%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x101c(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    0x0(%rbp),%edi
test   %eax,%eax
jns    143d <main+0x24d>
lea    0x1015(%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    0x100a(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x101a(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
test   %r12d,%r12d
sete   %al
test   %eax,0x4(%rsp)
jne    167d <main+0x48d>
mov    %r15,0x10(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    17c0 <main+0x5d0>
cmpl   $0x0,0x4(%rsp)
sete   %al
test   %r14d,%r14d
setns  %r13b
and    %al,%r13b
lea    0x20(%rsp),%r15
xor    %r12d,%r12d
jmp    14bf <main+0x2cf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jge    17c0 <main+0x5d0>
cmpl   $0x0,0x4(%rsp)
je     1540 <main+0x350>
test   %r14d,%r14d
js     1590 <main+0x3a0>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
js     193d <main+0x74d>
mov    %eax,%ebp
cmp    $0x100,%eax
je     1530 <main+0x340>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
lea    0x12d0(%rip),%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
cmp    $0xff,%ebp
ja     1530 <main+0x340>
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    1610 <main+0x420>
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     17db <main+0x5eb>
add    $0x8,%rbp
cmp    $0x100,%rbp
jne    1550 <main+0x360>
jmp    1644 <main+0x454>
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     17db <main+0x5eb>
add    $0x8,%rbp
cmp    $0x100,%rbp
jne    1610 <main+0x420>
test   %r13b,%r13b
je     14b0 <main+0x2c0>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1040 <write@plt>
cmp    $0x100,%eax
je     14b0 <main+0x2c0>
mov    0x2949(%rip),%rax
mov    (%rax),%edi
lea    0x118c(%rip),%rsi
jmp    194d <main+0x75d>
mov    0x0(%rbp),%edi
lea    0xe12(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe0e(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe2b(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe50(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe9d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xeca(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xee6(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xeea(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xf19(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xf2e(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xf42(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xf6f(%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    0xf95(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xfb5(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
call   10a0 <fflush@plt>
mov    0x282c(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
call   1080 <fgets@plt>
test   %eax,%eax
jne    17e5 <main+0x5f5>
mov    0x0(%rbp),%edi
lea    0xf99(%rip),%rsi
jmp    18f3 <main+0x703>
test   %r14d,%r14d
js     17cd <main+0x5dd>
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>
lea    0xf92(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1475 <main+0x285>
mov    0x0(%rbp),%edi
lea    0xf74(%rip),%rsi
jmp    18f3 <main+0x703>
mov    0x279e(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0x854(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x876(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x88d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8a9(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8c3(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8df(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x909(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x925(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x957(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x960(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x983(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9af(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9da(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x26ad(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0x9d7(%rip),%rsi
jmp    192c <main+0x73c>
mov    0x2698(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0x9f1(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2674(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
jmp    142e <main+0x23e>

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 = load i32, i32* %15
%156 = icmp ne i32 %155, 0
%157 = xor i1 %156, true
%158 = zext i1 %157 to i32
%159 = and i32 %154, %158
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %217
161: ; preds = %147
%162 = load i32, i32* @stderr
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.29, i64 0, i64 0))
%164 = load i32, i32* @stderr
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.30, i64 0, i64 0))
%166 = load i32, i32* @stderr
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.31, i64 0, i64 0))
%168 = load i32, i32* @stderr
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.32, i64 0, i64 0))
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.33, i64 0, i64 0))
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i64 0, i64 0))
%174 = load i32, i32* @stderr
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.35, i64 0, i64 0))
%176 = load i32, i32* @stderr
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.36, i64 0, i64 0))
%178 = load i32, i32* @stderr
%179 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.37, i64 0, i64 0))
%180 = load i32, i32* @stderr
%181 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.38, i64 0, i64 0))
%182 = load i32, i32* @stderr
%183 = load i8*, i8** %9
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %182, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.39, i64 0, i64 0), i8* %183)
%185 = load i32, i32* @stderr
%186 = call i32 (i32, i8*, ...) @fprintf(i32 %185, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.40, i64 0, i64 0))
%187 = load i32, i32* @stderr
%188 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.41, i64 0, i64 0))
%189 = load i32, i32* @stderr
%190 = load i32, i32* %12
%191 = load i32, i32* %12
%192 = load i32, i32* %14
%193 = add i32 %191, %192
%194 = sub i32 %193, 1
%195 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.42, i64 0, i64 0), i32 %190, i32 %194)
%196 = load i32, i32* @stderr
%197 = call i32 (i32, i8*, ...) @fprintf(i32 %196, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.43, i64 0, i64 0))
%198 = load i32, i32* @stderr
%199 = call i32 @fflush(i32 %198)
%200 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%201 = load i32, i32* @stdin
%202 = call i32 @fgets(i8* %200, i32 4, i32 %201)
%203 = icmp ne i32 %202, 0
br i1 %203, label %208, label %204
204: ; preds = %161
%205 = load i32, i32* @stderr
%206 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.44, i64 0, i64 0))
%207 = call i32 @exit(i32 1)
unreachable
208: ; preds = %161
%209 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%210 = call i64 @strncmp(i8* %209, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.45, i64 0, i64 0), i32 3)
%211 = icmp ne i64 %210, 0
br i1 %211, label %212, label %216
212: ; preds = %208
%213 = load i32, i32* @stderr
%214 = call i32 (i32, i8*, ...) @fprintf(i32 %213, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.46, i64 0, i64 0))
%215 = call i32 @exit(i32 1)
unreachable
216: ; preds = %208
br label %217
217: ; preds = %216, %147
store i32 0, i32* %6
br label %218
218: ; preds = %345, %217
%219 = load i32, i32* %6
%220 = load i32, i32* %14
%221 = icmp slt i32 %219, %220
br i1 %221, label %222, label %348
222: ; preds = %218
%223 = load i32, i32* %13
%224 = icmp ne i32 %223, 0
br i1 %224, label %225, label %298
225: ; preds = %222
%226 = load i32, i32* %10
%227 = icmp sge i32 %226, 0
br i1 %227, label %228, label %260
228: ; preds = %225
%229 = load i32, i32* %10
%230 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%231 = call i32 @read(i32 %229, i8* %230, i32 256)
store i32 %231, i32* %7
%232 = load i32, i32* %7
%233 = icmp slt i32 %232, 0
br i1 %233, label %234, label %241
234: ; preds = %228
%235 = load i32, i32* @stderr
%236 = load i8*, i8** %11
%237 = call i32 (i32, i8*, ...) @fprintf(i32 %235, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.47, i64 0, i64 0), i8* %236)
%238 = load i8*, i8** %11
%239 = call i32 @perror(i8* %238)
%240 = call i32 @exit(i32 1)
unreachable
241: ; preds = %228
%242 = load i32, i32* %7
%243 = sext i32 %242 to i64
%244 = icmp ne i64 %243, 256
br i1 %244, label %245, label %259
245: ; preds = %241
%246 = load i32, i32* @stderr
%247 = load i8*, i8** %11
%248 = call i32 (i32, i8*, ...) @fprintf(i32 %246, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.48, i64 0, i64 0), i8* %247)
br label %249
249: ; preds = %253, %245
%250 = load i32, i32* %7
%251 = sext i32 %250 to i64
%252 = icmp ult i64 %251, 256
br i1 %252, label %253, label %258
253: ; preds = %249
%254 = load i32, i32* %7
%255 = add nsw i32 %254, 1
store i32 %255, i32* %7
%256 = sext i32 %254 to i64
%257 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 %256
store i8 0, i8* %257
br label %249
258: ; preds = %249
br label %259
259: ; preds = %258, %241
br label %273
260: ; preds = %225
store i32 0, i32* %7
br label %261
261: ; preds = %269, %260
%262 = load i32, i32* %7
%263 = sext i32 %262 to i64
%264 = icmp ult i64 %263, 256
br i1 %264, label %265, label %272
265: ; preds = %261
%266 = load i32, i32* %7
%267 = sext i32 %266 to i64
%268 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 %267
store i8 0, i8* %268
br label %269
269: ; preds = %265
%270 = load i32, i32* %7
%271 = add nsw i32 %270, 1
store i32 %271, i32* %7
br label %261
272: ; preds = %261
br label %273
273: ; preds = %272, %259
store i32 0, i32* %7
br label %274
274: ; preds = %294, %273
%275 = load i32, i32* %7
%276 = icmp slt i32 %275, 32
br i1 %276, label %277, label %297
277: ; preds = %274
%278 = load i32, i32* %8
%279 = load i32, i32* %12
%280 = load i32, i32* %6
%281 = add i32 %279, %280
%282 = load i32, i32* %7
%283 = mul nsw i32 %282, 8
%284 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%285 = load i32, i32* %7
%286 = mul nsw i32 %285, 8
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i8, i8* %284, i64 %287
%289 = call i64 @eeprom_write(i32 %278, i32 %281, i32 %283, i8* %288, i32 8)
%290 = icmp slt i64 %289, 0
br i1 %290, label %291, label %293
291: ; preds = %277
%292 = call i32 @exit(i32 1)
unreachable
293: ; preds = %277
br label %294
294: ; preds = %293
%295 = load i32, i32* %7
%296 = add nsw i32 %295, 1
store i32 %296, i32* %7
br label %274
297: ; preds = %274
br label %323
298: ; preds = %222
store i32 0, i32* %7
br label %299
299: ; preds = %319, %298
%300 = load i32, i32* %7
%301 = icmp slt i32 %300, 32
br i1 %301, label %302, label %322
302: ; preds = %299
%303 = load i32, i32* %8
%304 = load i32, i32* %12
%305 = load i32, i32* %6
%306 = add i32 %304, %305
%307 = load i32, i32* %7
%308 = mul nsw i32 %307, 8
%309 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%310 = load i32, i32* %7
%311 = mul nsw i32 %310, 8
%312 = sext i32 %311 to i64
%313 = getelementptr inbounds i8, i8* %309, i64 %312
%314 = call i64 @eeprom_read(i32 %303, i32 %306, i32 %308, i8* %313, i32 8)
%315 = icmp slt i64 %314, 0
br i1 %315, label %316, label %318
316: ; preds = %302
%317 = call i32 @exit(i32 1)
unreachable
318: ; preds = %302
br label %319
319: ; preds = %318
%320 = load i32, i32* %7
%321 = add nsw i32 %320, 1
store i32 %321, i32* %7
br label %299
322: ; preds = %299
br label %323
323: ; preds = %322, %297
%324 = load i32, i32* %13
%325 = icmp ne i32 %324, 0
br i1 %325, label %344, label %326
326: ; preds = %323
%327 = load i32, i32* %10
%328 = icmp sge i32 %327, 0
br i1 %328, label %329, label %344
329: ; preds = %326
%330 = load i32, i32* %10
%331 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%332 = call i32 @write(i32 %330, i8* %331, i32 256)
store i32 %332, i32* %7
%333 = load i32, i32* %7
%334 = sext i32 %333 to i64
%335 = icmp ne i64 %334, 256
br i1 %335, label %336, label %343
336: ; preds = %329
%337 = load i32, i32* @stderr
%338 = load i8*, i8** %11
%339 = call i32 (i32, i8*, ...) @fprintf(i32 %337, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.49, i64 0, i64 0), i8* %338)
%340 = load i8*, i8** %11
%341 = call i32 @perror(i8* %340)
%342 = call i32 @exit(i32 1)
unreachable
343: ; preds = %329
br label %344
344: ; preds = %343, %326, %323
br label %345
345: ; preds = %344
%346 = load i32, i32* %6
%347 = add nsw i32 %346, 1
store i32 %347, i32* %6
br label %218
348: ; preds = %218
%349 = load i32, i32* %10
%350 = icmp sge i32 %349, 0
br i1 %350, label %351, label %354
351: ; preds = %348
%352 = load i32, i32* %10
%353 = call i32 @close(i32 %352)
br label %354
354: ; preds = %351, %348
%355 = load i32, i32* %8
%356 = call i32 @close(i32 %355)
%357 = 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 %87, 0
%135 = zext i1 %134 to i32
%136 = and i32 %86, %135
%137 = icmp eq i32 %136, 0
br i1 %137, label %191, label %138
138: ; preds = %130
%139 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%140 = load i32, i32* @stderr
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.29, i64 0, i64 0))
%142 = load i32, i32* @stderr
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.30, i64 0, i64 0))
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.31, i64 0, i64 0))
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.32, i64 0, i64 0))
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.33, i64 0, i64 0))
%150 = load i32, i32* @stderr
%151 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i64 0, i64 0))
%152 = load i32, i32* @stderr
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %152, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.35, i64 0, i64 0))
%154 = load i32, i32* @stderr
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.36, i64 0, i64 0))
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.37, i64 0, i64 0))
%158 = load i32, i32* @stderr
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.38, i64 0, i64 0))
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.39, i64 0, i64 0), i8* %84)
%162 = load i32, i32* @stderr
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.40, i64 0, i64 0))
%164 = load i32, i32* @stderr
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.41, i64 0, i64 0))
%166 = load i32, i32* @stderr
%167 = load i32, i32* %3
%168 = load i32, i32* %4
%169 = add i32 %167, -1
%170 = add i32 %169, %168
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.42, i64 0, i64 0), i32 %167, i32 %170)
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.43, i64 0, i64 0))
%174 = load i32, i32* @stderr
%175 = call i32 @fflush(i32 %174)
%176 = load i32, i32* @stdin
%177 = call i32 @fgets(i8* %139, i32 4, i32 %176)
%178 = icmp eq i32 %177, 0
br i1 %178, label %179, label %183
179: ; preds = %138
%180 = load i32, i32* @stderr
%181 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.44, i64 0, i64 0))
%182 = call i32 @exit(i32 1)
unreachable
183: ; preds = %138
%184 = call i64 @strncmp(i8* %139, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.45, i64 0, i64 0), i32 3)
%185 = icmp eq i64 %184, 0
br i1 %185, label %190, label %186
186: ; preds = %183
%187 = load i32, i32* @stderr
%188 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.46, i64 0, i64 0))
%189 = call i32 @exit(i32 1)
unreachable
190: ; preds = %183
br label %191
191: ; preds = %190, %130
%192 = load i32, i32* %4
%193 = icmp sgt i32 %192, 0
br i1 %193, label %194, label %265
194: ; preds = %191
%195 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%196 = icmp eq i32 %86, 0
%197 = icmp sgt i32 %121, -1
%198 = and i1 %196, %197
br label %199
199: ; preds = %194, %261
%200 = phi i32 [ 0, %194 ], [ %262, %261 ]
br i1 %196, label %241, label %201
201: ; preds = %199
br i1 %197, label %203, label %202
202: ; preds = %201
br label %223
203: ; preds = %201
%204 = call i32 @read(i32 %121, i8* %195, i32 256)
%205 = icmp slt i32 %204, 0
br i1 %205, label %206, label %211
206: ; preds = %203
%207 = load i32, i32* @stderr
%208 = call i32 (i32, i8*, ...) @fprintf(i32 %207, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.47, i64 0, i64 0), i8* %85)
%209 = call i32 @perror(i8* %85)
%210 = call i32 @exit(i32 1)
unreachable
211: ; preds = %203
%212 = icmp eq i32 %204, 256
br i1 %212, label %223, label %213
213: ; preds = %211
%214 = load i32, i32* @stderr
%215 = call i32 (i32, i8*, ...) @fprintf(i32 %214, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.48, i64 0, i64 0), i8* %85)
%216 = icmp ult i32 %204, 256
br i1 %216, label %217, label %223
217: ; preds = %213
%218 = zext i32 %204 to i64
%219 = getelementptr [256 x i8], [256 x i8]* %6, i64 0, i64 %218
%220 = sub nuw nsw i32 255, %204
%221 = zext i32 %220 to i64
%222 = add nuw nsw i64 %221, 1
br label %223
223: ; preds = %202, %217, %213, %211
br label %227
224: ; preds = %227
%225 = add nuw nsw i64 %228, 1
%226 = icmp eq i64 %225, 32
br i1 %226, label %252, label %227
227: ; preds = %223, %224
%228 = phi i64 [ %225, %224 ], [ 0, %223 ]
%229 = load i32, i32* %3
%230 = add i32 %229, %200
%231 = shl nuw nsw i64 %228, 3
%232 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %231
%233 = trunc i64 %231 to i32
%234 = call i64 @eeprom_write(i32 %123, i32 %230, i32 %233, i8* %232, i32 8)
%235 = icmp slt i64 %234, 0
br i1 %235, label %236, label %224
236: ; preds = %227
%237 = call i32 @exit(i32 1)
unreachable
238: ; preds = %241
%239 = add nuw nsw i64 %242, 1
%240 = icmp eq i64 %239, 32
br i1 %240, label %252, label %241
241: ; preds = %199, %238
%242 = phi i64 [ %239, %238 ], [ 0, %199 ]
%243 = load i32, i32* %3
%244 = add i32 %243, %200
%245 = shl nuw nsw i64 %242, 3
%246 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %245
%247 = trunc i64 %245 to i32
%248 = call i64 @eeprom_read(i32 %123, i32 %244, i32 %247, i8* %246, i32 8)
%249 = icmp slt i64 %248, 0
br i1 %249, label %250, label %238
250: ; preds = %241
%251 = call i32 @exit(i32 1)
unreachable
252: ; preds = %224, %238
br i1 %198, label %253, label %261
253: ; preds = %252
%254 = call i32 @write(i32 %121, i8* %195, i32 256)
%255 = icmp eq i32 %254, 256
br i1 %255, label %261, label %256
256: ; preds = %253
%257 = load i32, i32* @stderr
%258 = call i32 (i32, i8*, ...) @fprintf(i32 %257, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.49, i64 0, i64 0), i8* %85)
%259 = call i32 @perror(i8* %85)
%260 = call i32 @exit(i32 1)
unreachable
261: ; preds = %253, %252
%262 = add nuw nsw i32 %200, 1
%263 = load i32, i32* %4
%264 = icmp slt i32 %262, %263
br i1 %264, label %199, label %265
265: ; preds = %261, %191
%266 = icmp sgt i32 %121, -1
br i1 %266, label %267, label %269
267: ; preds = %265
%268 = call i32 @close(i32 %121)
br label %269
269: ; preds = %267, %265
%270 = call i32 @close(i32 %123)
%271 = call i32 @exit(i32 0)
unreachable
}