#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 */

/* Variables and functions */
scalar_t__ check_funcs(int, int, int, int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ confirm(char *, int, int, int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ help();
int i2c_smbus_read_byte(int);
int i2c_smbus_read_byte_data(int, int);
int i2c_smbus_read_word_data(int, int);
int i2c_smbus_write_byte(int, int);
scalar_t__ ioctl(int, int, int);
int open_i2c_dev(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ set_slave(int, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strtol(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *end;
  int res, i2cbus, address, file;
  int size = 2;
  int daddress;
  char filename[20];
  int pec = 0;
  int flags = 0;
  int yes = 0, version = 0;
  while (1 + flags < argc && argv[1 + flags][0] == '-') {
    switch (argv[1 + flags][1]) {
    case 'V':
      version = 1;
      break;
    case 'y':
      yes = 1;
      break;
    default:
      fprintf(stderr,
              "Warning: Unsupported flag "
              "\"-%c\"!\n",
              argv[1 + flags][1]);
      help();
      exit(1);
    }
    flags++;
  }
  if (version) {
    fprintf(stderr, "i2cget version %s\n", "2.10.0");
    exit(0);
  }
  if (argc - flags < 3)
    help();
  i2cbus = strtol(argv[flags + 1], &end, 0);
  if (*end || i2cbus < 0 || i2cbus > 0x3f) {
    fprintf(stderr, "Error: I2CBUS argument invalid!\n");
    help();
  }
  address = strtol(argv[flags + 2], &end, 0);
  if (*end || address < 3 || address > 0x77) {
    fprintf(stderr, "Error: Chip address invalid!\n");
    help();
  }
  if (!(flags + 3 < argc)) {
    size = 1;
    daddress = -1;
  } else {
    daddress = strtol(argv[flags + 3], &end, 0);
    if (*end || daddress < 0 || daddress > 0xff) {
      fprintf(stderr, "Error: Data address invalid!\n");
      help();
    }
  }
  if (flags + 4 < argc) {
    switch (argv[flags + 4][0]) {
    case 'b':
      size = 2;
      break;
    case 'w':
      size = 3;
      break;
    case 'c':
      size = 1;
      break;
    default:
      fprintf(stderr, "Error: Invalid mode!\n");
      help();
    }
    pec = argv[flags + 4][1] == 'p';
  }
  file = open_i2c_dev(i2cbus, filename, 0);
  if (file < 0 || check_funcs(file, i2cbus, size, daddress, pec) ||
      set_slave(file, address))
    exit(1);
  if (!yes && !confirm(filename, address, size, daddress, pec))
    exit(0);
  if (pec && ioctl(file, 0x0708, 1) < 0) {
    fprintf(stderr, "Error: Could not set PEC: %s\n", strerror(errno));
    exit(1);
  }
  switch (size) {
  case 1:
    if (daddress >= 0) {
      res = i2c_smbus_write_byte(file, daddress);
      if (res < 0)
        fprintf(stderr, "Warning - write failed\n");
    }
    res = i2c_smbus_read_byte(file);
    break;
  case 3:
    res = i2c_smbus_read_word_data(file, daddress);
    break;
  default:
    res = i2c_smbus_read_byte_data(file, daddress);
  }
  close(file);
  if (res < 0) {
    fprintf(stderr, "Error: Read failed\n");
    exit(2);
  }
  printf("0x%0*x\n", size == 3 ? 4 : 2, res);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x2c(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x61(%rbp)
jge    126d <main+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    127d <main+0x7d>
jmp    1313 <main+0x113>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    0x8(%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x68(%rbp)
sub    $0x56,%eax
je     12b0 <main+0xb0>
jmp    129f <main+0x9f>
mov    -0x68(%rbp),%eax
sub    $0x79,%eax
je     12bc <main+0xbc>
jmp    12c8 <main+0xc8>
movl   $0x1,-0x60(%rbp)
jmp    1305 <main+0x105>
movl   $0x1,-0x5c(%rbp)
jmp    1305 <main+0x105>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%edx
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    123c <main+0x3c>
cmpl   $0x0,-0x60(%rbp)
je     1342 <main+0x142>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xcf5(%rip),%rsi
lea    0xd01(%rip),%rdx
mov    $0x0,%al
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x8(%rbp),%eax
sub    -0x58(%rbp),%eax
cmp    $0x3,%eax
jge    1358 <main+0x158>
mov    $0x0,%al
call   1100 <help@plt>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    139b <main+0x19b>
cmpl   $0x0,-0x20(%rbp)
jl     139b <main+0x19b>
cmpl   $0x3f,-0x20(%rbp)
jle    13b9 <main+0x1b9>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xc91(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    13fc <main+0x1fc>
cmpl   $0x3,-0x24(%rbp)
jl     13fc <main+0x1fc>
cmpl   $0x77,-0x24(%rbp)
jle    141a <main+0x21a>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
lea    0xc51(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    -0x58(%rbp),%eax
add    $0x3,%eax
cmp    -0x8(%rbp),%eax
jl     143c <main+0x23c>
movl   $0x1,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
jmp    14a5 <main+0x2a5>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1482 <main+0x282>
cmpl   $0x0,-0x30(%rbp)
jl     1482 <main+0x282>
cmpl   $0xff,-0x30(%rbp)
jle    14a0 <main+0x2a0>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
lea    0xbe9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1100 <help@plt>
jmp    14a5 <main+0x2a5>
mov    -0x58(%rbp),%eax
add    $0x4,%eax
cmp    -0x8(%rbp),%eax
jge    155c <main+0x35c>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    0x20(%rax,%rcx,8),%rax
movsbl (%rax),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x62,%eax
je     14f7 <main+0x2f7>
jmp    14d5 <main+0x2d5>
mov    -0x6c(%rbp),%eax
sub    $0x63,%eax
je     150f <main+0x30f>
jmp    14e6 <main+0x2e6>
mov    -0x6c(%rbp),%eax
sub    $0x77,%eax
je     1503 <main+0x303>
jmp    151b <main+0x31b>
movl   $0x2,-0x2c(%rbp)
jmp    1539 <main+0x339>
movl   $0x3,-0x2c(%rbp)
jmp    1539 <main+0x339>
movl   $0x1,-0x2c(%rbp)
jmp    1539 <main+0x339>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1100 <help@plt>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x70,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
xor    %edx,%edx
call   10d0 <open_i2c_dev@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     15ab <main+0x3ab>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x54(%rbp),%r8d
call   1030 <check_funcs@plt>
cmp    $0x0,%rax
jne    15ab <main+0x3ab>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <set_slave@plt>
cmp    $0x0,%rax
je     15b5 <main+0x3b5>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x5c(%rbp)
jne    15e5 <main+0x3e5>
lea    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x54(%rbp),%r8d
call   1080 <confirm@plt>
cmp    $0x0,%eax
jne    15e5 <main+0x3e5>
xor    %edi,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x54(%rbp)
je     1643 <main+0x443>
mov    -0x28(%rbp),%edi
mov    $0x708,%esi
mov    $0x1,%edx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1643 <main+0x443>
mov    0x29ce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x29ba(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x70(%rbp),%edi
mov    %rax,%rdx
lea    0xa7d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x1,%eax
je     1668 <main+0x468>
jmp    1657 <main+0x457>
mov    -0x74(%rbp),%eax
sub    $0x3,%eax
je     16b6 <main+0x4b6>
jmp    16c9 <main+0x4c9>
cmpl   $0x0,-0x30(%rbp)
jl     16a6 <main+0x4a6>
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1090 <i2c_smbus_write_byte@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    16a1 <main+0x4a1>
mov    0x294f(%rip),%rax
mov    (%rax),%edi
lea    0xa33(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    16a6 <main+0x4a6>
mov    -0x28(%rbp),%edi
call   10c0 <i2c_smbus_read_byte@plt>
mov    %eax,-0x1c(%rbp)
jmp    16d7 <main+0x4d7>
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   10e0 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x1c(%rbp)
jmp    16d7 <main+0x4d7>
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   10f0 <i2c_smbus_read_byte_data@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    170a <main+0x50a>
mov    0x28f0(%rip),%rax
mov    (%rax),%edi
lea    0x9ec(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    -0x2c(%rbp),%ecx
mov    $0x2,%esi
mov    $0x4,%eax
cmp    $0x3,%ecx
cmove  %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0x9d2(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
cmp    $0x2,%edi
jl     1287 <main+0x87>
mov    0x8(%rbx),%rdx
cmpb   $0x2d,(%rdx)
jne    13d4 <main+0x1d4>
mov    %r14d,%ebp
lea    -0x1(%r14),%r13d
mov    %rbp,%rsi
add    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
xor    %r12d,%r12d
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rdx),%edx
mov    $0x1,%eax
cmp    $0x56,%edx
je     125f <main+0x5f>
cmp    $0x79,%edx
jne    154b <main+0x34b>
mov    $0x1,%r12d
mov    %edi,%eax
cmp    %rcx,%rsi
je     127e <main+0x7e>
mov    0x10(%rbx,%rcx,8),%rdx
add    $0x1,%rcx
cmpb   $0x2d,(%rdx)
mov    %eax,%edi
je     1240 <main+0x40>
mov    %rcx,%rbp
add    $0x1,%rbp
mov    %ecx,%r13d
test   %eax,%eax
je     1292 <main+0x92>
jmp    13e9 <main+0x1e9>
xor    %r12d,%r12d
mov    $0x1,%ebp
xor    %r13d,%r13d
mov    %r14d,%eax
sub    %r13d,%eax
cmp    $0x2,%eax
jg     12a4 <main+0xa4>
xor    %eax,%eax
call   1100 <help@plt>
mov    %ebp,%eax
mov    (%rbx,%rax,8),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,%r15d
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    12cb <main+0xcb>
test   %r15d,%r15d
js     12cb <main+0xcb>
cmp    $0x40,%r15d
jl     12e9 <main+0xe9>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1100 <help@plt>
mov    %r13d,%eax
mov    0x10(%rbx,%rax,8),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    1310 <main+0x110>
cmp    $0x3,%ebp
jl     1310 <main+0x110>
cmp    $0x78,%ebp
jl     132e <main+0x12e>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1100 <help@plt>
lea    0x3(%r13),%eax
cmp    %r14d,%eax
mov    %r15d,0x14(%rsp)
mov    %ebp,0xc(%rsp)
mov    %r14,0x18(%rsp)
jge    1392 <main+0x192>
mov    %eax,%eax
mov    (%rbx,%rax,8),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
mov    $0x2,%r14d
jne    1372 <main+0x172>
test   %ebp,%ebp
js     1372 <main+0x172>
cmp    $0x100,%ebp
jl     139d <main+0x19d>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
lea    0xcf9(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1100 <help@plt>
jmp    139d <main+0x19d>
mov    $0xffffffff,%ebp
mov    $0x1,%r14d
add    $0x4,%r13d
xor    %r15d,%r15d
cmp    0x18(%rsp),%r13d
mov    %ebp,0x10(%rsp)
jge    144b <main+0x24b>
mov    %r13d,%ebp
mov    (%rbx,%rbp,8),%rax
movsbl (%rax),%ecx
cmp    $0x62,%ecx
je     140e <main+0x20e>
cmp    $0x63,%ecx
je     1416 <main+0x216>
cmp    $0x77,%ecx
jne    141e <main+0x21e>
mov    $0x3,%r14d
jmp    1440 <main+0x240>
xor    %eax,%eax
mov    $0x1,%ebp
xor    %r12d,%r12d
xor    %r13d,%r13d
test   %eax,%eax
je     1292 <main+0x92>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    0xc29(%rip),%rsi
lea    0xc35(%rip),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    $0x2,%r14d
jmp    1440 <main+0x240>
mov    $0x1,%r14d
jmp    1440 <main+0x240>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
lea    0xc6b(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1100 <help@plt>
mov    (%rbx,%rbp,8),%rax
xor    %r15d,%r15d
cmpb   $0x70,0x1(%rax)
sete   %r15b
lea    0x20(%rsp),%rsi
mov    0x14(%rsp),%ebp
mov    %ebp,%edi
xor    %edx,%edx
call   10d0 <open_i2c_dev@plt>
test   %eax,%eax
js     14b5 <main+0x2b5>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    0x10(%rsp),%ecx
mov    %r15d,%r8d
call   1030 <check_funcs@plt>
test   %rax,%rax
jne    14b5 <main+0x2b5>
mov    %ebx,%edi
mov    0xc(%rsp),%esi
call   1040 <set_slave@plt>
test   %rax,%rax
jne    14b5 <main+0x2b5>
test   %r12d,%r12d
mov    0x10(%rsp),%ebp
jne    14bf <main+0x2bf>
lea    0x20(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1080 <confirm@plt>
test   %eax,%eax
jne    14bf <main+0x2bf>
xor    %edi,%edi
call   1110 <exit@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
test   %r15d,%r15d
je     150e <main+0x30e>
mov    %ebx,%edi
mov    $0x708,%esi
mov    $0x1,%edx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    150e <main+0x30e>
mov    0x2aff(%rip),%rax
mov    (%rax),%ebx
mov    0x2aee(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xbb7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmp    $0x3,%r14d
je     1573 <main+0x373>
cmp    $0x1,%r14d
jne    157e <main+0x37e>
test   %ebp,%ebp
js     1542 <main+0x342>
mov    %ebx,%edi
mov    %ebp,%esi
call   1090 <i2c_smbus_write_byte@plt>
test   %eax,%eax
jns    1542 <main+0x342>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
lea    0xb92(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebx,%edi
call   10c0 <i2c_smbus_read_byte@plt>
jmp    1587 <main+0x387>
mov    0x2a8e(%rip),%rax
mov    (%rax),%edi
lea    0xaa5(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1100 <help@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   10e0 <i2c_smbus_read_word_data@plt>
jmp    1587 <main+0x387>
mov    %ebx,%edi
mov    %ebp,%esi
call   10f0 <i2c_smbus_read_byte_data@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1070 <close@plt>
test   %ebp,%ebp
jns    15b5 <main+0x3b5>
mov    0x2a45(%rip),%rax
mov    (%rax),%edi
lea    0xb41(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
xor    %eax,%eax
cmp    $0x3,%r14d
sete   %al
lea    (%rax,%rax,1),%esi
add    $0x2,%esi
lea    0xb2e(%rip),%rdi
mov    %ebp,%edx
call   1050 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Warning: Unsupported flag \22-%c\22!\0A\00"
@.str.1 = [19 x i8] c"i2cget version %s\0A\00"
@.str.2 = [7 x i8] c"2.10.0\00"
@.str.3 = [33 x i8] c"Error: I2CBUS argument invalid!\0A\00"
@.str.4 = [30 x i8] c"Error: Chip address invalid!\0A\00"
@.str.5 = [30 x i8] c"Error: Data address invalid!\0A\00"
@.str.6 = [22 x i8] c"Error: Invalid mode!\0A\00"
@.str.7 = [30 x i8] c"Error: Could not set PEC: %s\0A\00"
@errno = global i32 0
@.str.8 = [24 x i8] c"Warning - write failed\0A\00"
@.str.9 = [20 x i8] c"Error: Read failed\0A\00"
@.str.10 = [8 x i8] c"0x%0*x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [20 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2, i32* %11
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
br label %18
18: ; preds = %62, %2
%19 = load i32, i32* %15
%20 = add nsw i32 1, %19
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %34
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = load i32, i32* %15
%26 = add nsw i32 1, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 45
br label %34
34: ; preds = %23, %18
%35 = phi i1 [ false, %18 ], [ %33, %23 ]
br i1 %35, label %36, label %65
36: ; preds = %34
%37 = load i8**, i8*** %5
%38 = load i32, i32* %15
%39 = add nsw i32 1, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
switch i32 %45, label %48 [
i32 86, label %46
i32 121, label %47
]
46: ; preds = %36
store i32 1, i32* %17
br label %62
47: ; preds = %36
store i32 1, i32* %16
br label %62
48: ; preds = %36
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = load i32, i32* %15
%52 = add nsw i32 1, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %50, i64 %53
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = call i32 (...) @help()
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %47, %46
%63 = load i32, i32* %15
%64 = add nsw i32 %63, 1
store i32 %64, i32* %15
br label %18
65: ; preds = %34
%66 = load i32, i32* %17
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%71 = call i32 @exit(i32 0)
unreachable
72: ; preds = %65
%73 = load i32, i32* %4
%74 = load i32, i32* %15
%75 = sub nsw i32 %73, %74
%76 = icmp slt i32 %75, 3
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = call i32 (...) @help()
br label %79
79: ; preds = %77, %72
%80 = load i8**, i8*** %5
%81 = load i32, i32* %15
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %80, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 @strtol(i8* %85, i8** %6, i32 0)
store i32 %86, i32* %8
%87 = load i8*, i8** %6
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 0
br i1 %90, label %97, label %91
91: ; preds = %79
%92 = load i32, i32* %8
%93 = icmp slt i32 %92, 0
br i1 %93, label %97, label %94
94: ; preds = %91
%95 = load i32, i32* %8
%96 = icmp sgt i32 %95, 63
br i1 %96, label %97, label %101
97: ; preds = %94, %91, %79
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%100 = call i32 (...) @help()
br label %101
101: ; preds = %97, %94
%102 = load i8**, i8*** %5
%103 = load i32, i32* %15
%104 = add nsw i32 %103, 2
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %102, i64 %105
%107 = load i8*, i8** %106
%108 = call i32 @strtol(i8* %107, i8** %6, i32 0)
store i32 %108, i32* %9
%109 = load i8*, i8** %6
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp ne i32 %111, 0
br i1 %112, label %119, label %113
113: ; preds = %101
%114 = load i32, i32* %9
%115 = icmp slt i32 %114, 3
br i1 %115, label %119, label %116
116: ; preds = %113
%117 = load i32, i32* %9
%118 = icmp sgt i32 %117, 119
br i1 %118, label %119, label %123
119: ; preds = %116, %113, %101
%120 = load i32, i32* @stderr
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%122 = call i32 (...) @help()
br label %123
123: ; preds = %119, %116
%124 = load i32, i32* %15
%125 = add nsw i32 %124, 3
%126 = load i32, i32* %4
%127 = icmp slt i32 %125, %126
br i1 %127, label %129, label %128
128: ; preds = %123
store i32 1, i32* %11
store i32 -1, i32* %12
br label %152
129: ; preds = %123
%130 = load i8**, i8*** %5
%131 = load i32, i32* %15
%132 = add nsw i32 %131, 3
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8*, i8** %130, i64 %133
%135 = load i8*, i8** %134
%136 = call i32 @strtol(i8* %135, i8** %6, i32 0)
store i32 %136, i32* %12
%137 = load i8*, i8** %6
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp ne i32 %139, 0
br i1 %140, label %147, label %141
141: ; preds = %129
%142 = load i32, i32* %12
%143 = icmp slt i32 %142, 0
br i1 %143, label %147, label %144
144: ; preds = %141
%145 = load i32, i32* %12
%146 = icmp sgt i32 %145, 255
br i1 %146, label %147, label %151
147: ; preds = %144, %141, %129
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%150 = call i32 (...) @help()
br label %151
151: ; preds = %147, %144
br label %152
152: ; preds = %151, %128
%153 = load i32, i32* %15
%154 = add nsw i32 %153, 4
%155 = load i32, i32* %4
%156 = icmp slt i32 %154, %155
br i1 %156, label %157, label %186
157: ; preds = %152
%158 = load i8**, i8*** %5
%159 = load i32, i32* %15
%160 = add nsw i32 %159, 4
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i8*, i8** %158, i64 %161
%163 = load i8*, i8** %162
%164 = getelementptr inbounds i8, i8* %163, i64 0
%165 = load i8, i8* %164
%166 = sext i8 %165 to i32
switch i32 %166, label %170 [
i32 98, label %167
i32 119, label %168
i32 99, label %169
]
167: ; preds = %157
store i32 2, i32* %11
br label %174
168: ; preds = %157
store i32 3, i32* %11
br label %174
169: ; preds = %157
store i32 1, i32* %11
br label %174
170: ; preds = %157
%171 = load i32, i32* @stderr
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %171, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%173 = call i32 (...) @help()
br label %174
174: ; preds = %170, %169, %168, %167
%175 = load i8**, i8*** %5
%176 = load i32, i32* %15
%177 = add nsw i32 %176, 4
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds i8*, i8** %175, i64 %178
%180 = load i8*, i8** %179
%181 = getelementptr inbounds i8, i8* %180, i64 1
%182 = load i8, i8* %181
%183 = sext i8 %182 to i32
%184 = icmp eq i32 %183, 112
%185 = zext i1 %184 to i32
store i32 %185, i32* %14
br label %186
186: ; preds = %174, %152
%187 = load i32, i32* %8
%188 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%189 = call i32 @open_i2c_dev(i32 %187, i8* %188, i32 0)
store i32 %189, i32* %10
%190 = load i32, i32* %10
%191 = icmp slt i32 %190, 0
br i1 %191, label %205, label %192
192: ; preds = %186
%193 = load i32, i32* %10
%194 = load i32, i32* %8
%195 = load i32, i32* %11
%196 = load i32, i32* %12
%197 = load i32, i32* %14
%198 = call i64 @check_funcs(i32 %193, i32 %194, i32 %195, i32 %196, i32 %197)
%199 = icmp ne i64 %198, 0
br i1 %199, label %205, label %200
200: ; preds = %192
%201 = load i32, i32* %10
%202 = load i32, i32* %9
%203 = call i64 @set_slave(i32 %201, i32 %202)
%204 = icmp ne i64 %203, 0
br i1 %204, label %205, label %207
205: ; preds = %200, %192, %186
%206 = call i32 @exit(i32 1)
unreachable
207: ; preds = %200
%208 = load i32, i32* %16
%209 = icmp ne i32 %208, 0
br i1 %209, label %220, label %210
210: ; preds = %207
%211 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%212 = load i32, i32* %9
%213 = load i32, i32* %11
%214 = load i32, i32* %12
%215 = load i32, i32* %14
%216 = call i32 @confirm(i8* %211, i32 %212, i32 %213, i32 %214, i32 %215)
%217 = icmp ne i32 %216, 0
br i1 %217, label %220, label %218
218: ; preds = %210
%219 = call i32 @exit(i32 0)
unreachable
220: ; preds = %210, %207
%221 = load i32, i32* %14
%222 = icmp ne i32 %221, 0
br i1 %222, label %223, label %233
223: ; preds = %220
%224 = load i32, i32* %10
%225 = call i64 @ioctl(i32 %224, i32 1800, i32 1)
%226 = icmp slt i64 %225, 0
br i1 %226, label %227, label %233
227: ; preds = %223
%228 = load i32, i32* @stderr
%229 = load i32, i32* @errno
%230 = call i8* @strerror(i32 %229)
%231 = call i32 (i32, i8*, ...) @fprintf(i32 %228, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %230)
%232 = call i32 @exit(i32 1)
unreachable
233: ; preds = %223, %220
%234 = load i32, i32* %11
switch i32 %234, label %255 [
i32 1, label %235
i32 3, label %251
]
235: ; preds = %233
%236 = load i32, i32* %12
%237 = icmp sge i32 %236, 0
br i1 %237, label %238, label %248
238: ; preds = %235
%239 = load i32, i32* %10
%240 = load i32, i32* %12
%241 = call i32 @i2c_smbus_write_byte(i32 %239, i32 %240)
store i32 %241, i32* %7
%242 = load i32, i32* %7
%243 = icmp slt i32 %242, 0
br i1 %243, label %244, label %247
244: ; preds = %238
%245 = load i32, i32* @stderr
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %245, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %247
247: ; preds = %244, %238
br label %248
248: ; preds = %247, %235
%249 = load i32, i32* %10
%250 = call i32 @i2c_smbus_read_byte(i32 %249)
store i32 %250, i32* %7
br label %259
251: ; preds = %233
%252 = load i32, i32* %10
%253 = load i32, i32* %12
%254 = call i32 @i2c_smbus_read_word_data(i32 %252, i32 %253)
store i32 %254, i32* %7
br label %259
255: ; preds = %233
%256 = load i32, i32* %10
%257 = load i32, i32* %12
%258 = call i32 @i2c_smbus_read_byte_data(i32 %256, i32 %257)
store i32 %258, i32* %7
br label %259
259: ; preds = %255, %251, %248
%260 = load i32, i32* %10
%261 = call i32 @close(i32 %260)
%262 = load i32, i32* %7
%263 = icmp slt i32 %262, 0
br i1 %263, label %264, label %268
264: ; preds = %259
%265 = load i32, i32* @stderr
%266 = call i32 (i32, i8*, ...) @fprintf(i32 %265, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%267 = call i32 @exit(i32 2)
unreachable
268: ; preds = %259
%269 = load i32, i32* %11
%270 = icmp eq i32 %269, 3
%271 = zext i1 %270 to i64
%272 = select i1 %270, i32 4, i32 2
%273 = load i32, i32* %7
%274 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %272, i32 %273)
%275 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Warning: Unsupported flag \22-%c\22!\0A\00"
@.str.1 = [19 x i8] c"i2cget version %s\0A\00"
@.str.2 = [7 x i8] c"2.10.0\00"
@.str.3 = [33 x i8] c"Error: I2CBUS argument invalid!\0A\00"
@.str.4 = [30 x i8] c"Error: Chip address invalid!\0A\00"
@.str.5 = [30 x i8] c"Error: Data address invalid!\0A\00"
@.str.6 = [22 x i8] c"Error: Invalid mode!\0A\00"
@.str.7 = [30 x i8] c"Error: Could not set PEC: %s\0A\00"
@errno = global i32 0
@.str.8 = [24 x i8] c"Warning - write failed\0A\00"
@.str.9 = [20 x i8] c"Error: Read failed\0A\00"
@.str.10 = [8 x i8] c"0x%0*x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [20 x i8]
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %58
8: ; preds = %2
%9 = add nsw i32 %0, -1
%10 = zext i32 %0 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 45
br i1 %14, label %21, label %42
15: ; preds = %37
%16 = trunc i64 %40 to i32
%17 = getelementptr inbounds i8*, i8** %1, i64 %40
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 45
br i1 %20, label %21, label %42
21: ; preds = %8, %15
%22 = phi i8* [ %18, %15 ], [ %12, %8 ]
%23 = phi i32 [ %16, %15 ], [ 1, %8 ]
%24 = phi i32 [ %38, %15 ], [ 0, %8 ]
%25 = phi i32 [ %39, %15 ], [ 0, %8 ]
%26 = phi i64 [ %40, %15 ], [ 1, %8 ]
%27 = getelementptr inbounds i8, i8* %22, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
switch i32 %29, label %31 [
i32 86, label %37
i32 121, label %30
]
30: ; preds = %21
br label %37
31: ; preds = %21
%32 = sext i8 %28 to i32
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %32)
%35 = tail call i32 (...) @help()
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %21, %30
%38 = phi i32 [ 1, %30 ], [ %24, %21 ]
%39 = phi i32 [ %25, %30 ], [ 1, %21 ]
%40 = add nuw nsw i64 %26, 1
%41 = icmp eq i64 %40, %10
br i1 %41, label %48, label %15
42: ; preds = %15, %8
%43 = phi i64 [ 1, %8 ], [ %40, %15 ]
%44 = phi i32 [ 0, %8 ], [ %39, %15 ]
%45 = phi i32 [ 0, %8 ], [ %38, %15 ]
%46 = phi i32 [ 0, %8 ], [ %23, %15 ]
%47 = trunc i64 %43 to i32
br label %48
48: ; preds = %37, %42
%49 = phi i32 [ %46, %42 ], [ %9, %37 ]
%50 = phi i32 [ %45, %42 ], [ %38, %37 ]
%51 = phi i32 [ %44, %42 ], [ %39, %37 ]
%52 = phi i32 [ %47, %42 ], [ %0, %37 ]
%53 = icmp eq i32 %51, 0
br i1 %53, label %58, label %54
54: ; preds = %48
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%57 = tail call i32 @exit(i32 0)
unreachable
58: ; preds = %2, %48
%59 = phi i32 [ %52, %48 ], [ 1, %2 ]
%60 = phi i32 [ %50, %48 ], [ 0, %2 ]
%61 = phi i32 [ %49, %48 ], [ 0, %2 ]
%62 = sub nsw i32 %0, %61
%63 = icmp slt i32 %62, 3
br i1 %63, label %64, label %66
64: ; preds = %58
%65 = tail call i32 (...) @help()
br label %66
66: ; preds = %64, %58
%67 = zext i32 %59 to i64
%68 = getelementptr inbounds i8*, i8** %1, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @strtol(i8* %69, i8** %3, i32 0)
%71 = load i8*, i8** %3
%72 = load i8, i8* %71
%73 = icmp ne i8 %72, 0
%74 = icmp slt i32 %70, 0
%75 = select i1 %73, i1 true, i1 %74
%76 = icmp sgt i32 %70, 63
%77 = select i1 %75, i1 true, i1 %76
br i1 %77, label %78, label %82
78: ; preds = %66
%79 = load i32, i32* @stderr
%80 = tail call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%81 = tail call i32 (...) @help()
br label %82
82: ; preds = %66, %78
%83 = add nuw nsw i32 %61, 2
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %1, i64 %84
%86 = load i8*, i8** %85
%87 = call i32 @strtol(i8* %86, i8** %3, i32 0)
%88 = load i8*, i8** %3
%89 = load i8, i8* %88
%90 = icmp ne i8 %89, 0
%91 = icmp slt i32 %87, 3
%92 = select i1 %90, i1 true, i1 %91
%93 = icmp sgt i32 %87, 119
%94 = select i1 %92, i1 true, i1 %93
br i1 %94, label %95, label %99
95: ; preds = %82
%96 = load i32, i32* @stderr
%97 = tail call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%98 = tail call i32 (...) @help()
br label %99
99: ; preds = %82, %95
%100 = add nuw nsw i32 %61, 3
%101 = icmp slt i32 %100, %0
br i1 %101, label %102, label %118
102: ; preds = %99
%103 = zext i32 %100 to i64
%104 = getelementptr inbounds i8*, i8** %1, i64 %103
%105 = load i8*, i8** %104
%106 = call i32 @strtol(i8* %105, i8** %3, i32 0)
%107 = load i8*, i8** %3
%108 = load i8, i8* %107
%109 = icmp ne i8 %108, 0
%110 = icmp slt i32 %106, 0
%111 = select i1 %109, i1 true, i1 %110
%112 = icmp sgt i32 %106, 255
%113 = select i1 %111, i1 true, i1 %112
br i1 %113, label %114, label %118
114: ; preds = %102
%115 = load i32, i32* @stderr
%116 = tail call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%117 = tail call i32 (...) @help()
br label %118
118: ; preds = %99, %114, %102
%119 = phi i32 [ 2, %114 ], [ 2, %102 ], [ 1, %99 ]
%120 = phi i32 [ %106, %114 ], [ %106, %102 ], [ -1, %99 ]
%121 = add nuw nsw i32 %61, 4
%122 = icmp slt i32 %121, %0
br i1 %122, label %123, label %143
123: ; preds = %118
%124 = zext i32 %121 to i64
%125 = getelementptr inbounds i8*, i8** %1, i64 %124
%126 = load i8*, i8** %125
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
switch i32 %128, label %131 [
i32 98, label %136
i32 119, label %129
i32 99, label %130
]
129: ; preds = %123
br label %136
130: ; preds = %123
br label %136
131: ; preds = %123
%132 = load i32, i32* @stderr
%133 = tail call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%134 = tail call i32 (...) @help()
%135 = load i8*, i8** %125
br label %136
136: ; preds = %123, %131, %130, %129
%137 = phi i8* [ %135, %131 ], [ %126, %130 ], [ %126, %129 ], [ %126, %123 ]
%138 = phi i32 [ %119, %131 ], [ 1, %130 ], [ 3, %129 ], [ 2, %123 ]
%139 = getelementptr inbounds i8, i8* %137, i64 1
%140 = load i8, i8* %139
%141 = icmp eq i8 %140, 112
%142 = zext i1 %141 to i32
br label %143
143: ; preds = %136, %118
%144 = phi i32 [ %138, %136 ], [ %119, %118 ]
%145 = phi i32 [ %142, %136 ], [ 0, %118 ]
%146 = call i32 @open_i2c_dev(i32 %70, i8* %6, i32 0)
%147 = icmp slt i32 %146, 0
br i1 %147, label %154, label %148
148: ; preds = %143
%149 = call i64 @check_funcs(i32 %146, i32 %70, i32 %144, i32 %120, i32 %145)
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %148
%152 = call i64 @set_slave(i32 %146, i32 %87)
%153 = icmp eq i64 %152, 0
br i1 %153, label %156, label %154
154: ; preds = %151, %148, %143
%155 = call i32 @exit(i32 1)
unreachable
156: ; preds = %151
%157 = icmp eq i32 %60, 0
br i1 %157, label %158, label %163
158: ; preds = %156
%159 = call i32 @confirm(i8* %6, i32 %87, i32 %144, i32 %120, i32 %145)
%160 = icmp eq i32 %159, 0
br i1 %160, label %161, label %163
161: ; preds = %158
%162 = call i32 @exit(i32 0)
unreachable
163: ; preds = %158, %156
%164 = icmp eq i32 %145, 0
br i1 %164, label %174, label %165
165: ; preds = %163
%166 = call i64 @ioctl(i32 %146, i32 1800, i32 1)
%167 = icmp slt i64 %166, 0
br i1 %167, label %168, label %174
168: ; preds = %165
%169 = load i32, i32* @stderr
%170 = load i32, i32* @errno
%171 = call i8* @strerror(i32 %170)
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %171)
%173 = call i32 @exit(i32 1)
unreachable
174: ; preds = %165, %163
switch i32 %144, label %187 [
i32 1, label %175
i32 3, label %185
]
175: ; preds = %174
%176 = icmp sgt i32 %120, -1
br i1 %176, label %177, label %183
177: ; preds = %175
%178 = call i32 @i2c_smbus_write_byte(i32 %146, i32 %120)
%179 = icmp slt i32 %178, 0
br i1 %179, label %180, label %183
180: ; preds = %177
%181 = load i32, i32* @stderr
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %181, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %183
183: ; preds = %177, %180, %175
%184 = call i32 @i2c_smbus_read_byte(i32 %146)
br label %189
185: ; preds = %174
%186 = call i32 @i2c_smbus_read_word_data(i32 %146, i32 %120)
br label %189
187: ; preds = %174
%188 = call i32 @i2c_smbus_read_byte_data(i32 %146, i32 %120)
br label %189
189: ; preds = %187, %185, %183
%190 = phi i32 [ %188, %187 ], [ %186, %185 ], [ %184, %183 ]
%191 = call i32 @close(i32 %146)
%192 = icmp slt i32 %190, 0
br i1 %192, label %193, label %197
193: ; preds = %189
%194 = load i32, i32* @stderr
%195 = call i32 (i32, i8*, ...) @fprintf(i32 %194, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%196 = call i32 @exit(i32 2)
unreachable
197: ; preds = %189
%198 = icmp eq i32 %144, 3
%199 = select i1 %198, i32 4, i32 2
%200 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %199, i32 %190)
%201 = call i32 @exit(i32 0)
unreachable
}