#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 */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ help();
scalar_t__ ioctl(int, int, long *);
int open_i2c_dev(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_i2c_busses(int);
int scan_i2c_bus(int, int, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strerror(int /*<<< orphan*/);
int strtol(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *end;
  int i2cbus, file, res;
  char filename[20];
  long funcs;
  int mode = 0;
  int first = 0x03, last = 0x77;
  int flags = 0;
  int yes = 0, version = 0, list = 0;
  while (1 + flags < argc && argv[1 + flags][0] == '-') {
    switch (argv[1 + flags][1]) {
    case 'V':
      version = 1;
      break;
    case 'y':
      yes = 1;
      break;
    case 'l':
      list = 1;
      break;
    case 'r':
      if (mode == 1) {
        fprintf(stderr, "Error: Different modes "
                        "specified!\n");
        exit(1);
      }
      mode = 2;
      break;
    case 'q':
      if (mode == 2) {
        fprintf(stderr, "Error: Different modes "
                        "specified!\n");
        exit(1);
      }
      mode = 1;
      break;
    case 'a':
      first = 0x00;
      last = 0x7F;
      break;
    default:
      fprintf(stderr,
              "Warning: Unsupported flag "
              "\"-%c\"!\n",
              argv[1 + flags][1]);
      help();
      exit(1);
    }
    flags++;
  }
  if (version) {
    fprintf(stderr, "i2cdetect version %s\n", "2.10.0");
    exit(0);
  }
  if (list) {
    print_i2c_busses(1);
    exit(0);
  }
  if (argc < flags + 2) {
    fprintf(stderr, "Error: No i2c-bus specified!\n");
    help();
    exit(1);
  }
  i2cbus = strtol(argv[flags + 1], &end, 0);
  if (*end) {
    fprintf(stderr, "Error: I2CBUS argument not a number!\n");
    help();
    exit(1);
  }
  if ((i2cbus < 0) || (i2cbus > 0xff)) {
    fprintf(stderr, "Error: I2CBUS argument out of range "
                    "(0-255)!\n");
    help();
    exit(1);
  }
  if (argc == flags + 4) {
    int tmp;
    tmp = strtol(argv[flags + 2], &end, 0);
    if (*end) {
      fprintf(stderr, "Error: FIRST argment not a "
                      "number!\n");
      help();
      exit(1);
    }
    if (tmp < first || tmp > last) {
      fprintf(stderr,
              "Error: FIRST argument out of range "
              "(0x%02x-0x%02x)!\n",
              first, last);
      help();
      exit(1);
    }
    first = tmp;
    tmp = strtol(argv[flags + 3], &end, 0);
    if (*end) {
      fprintf(stderr, "Error: LAST argment not a "
                      "number!\n");
      help();
      exit(1);
    }
    if (tmp < first || tmp > last) {
      fprintf(stderr,
              "Error: LAST argument out of range "
              "(0x%02x-0x%02x)!\n",
              first, last);
      help();
      exit(1);
    }
    last = tmp;
  } else if (argc != flags + 2) {
    help();
    exit(1);
  }
  file = open_i2c_dev(i2cbus, filename, 0);
  if (file < 0) {
    exit(1);
  }
  if (ioctl(file, 0x0705, &funcs) < 0) {
    fprintf(stderr,
            "Error: Could not get the adapter "
            "functionality matrix: %s\n",
            strerror(errno));
    close(file);
    exit(1);
  }
  if (mode != 2 && !(funcs & 0x00010000)) {
    fprintf(stderr, "Error: Can't use SMBus Quick Write command "
                    "on this bus (ISA bus?)\n");
    close(file);
    exit(1);
  }
  if (mode != 1 && !(funcs & 0x00020000)) {
    fprintf(stderr, "Error: Can't use SMBus Read Byte command "
                    "on this bus (ISA bus?)\n");
    close(file);
    exit(1);
  }
  if (!yes) {
    char s[2];
    fprintf(stderr, "WARNING! This program can confuse your I2C "
                    "bus, cause data loss and worse!\n");
    fprintf(stderr, "I will probe file %s%s.\n", filename,
            mode == 1   ? " using quick write commands"
            : mode == 2 ? " using read byte commands"
                        : "");
    fprintf(stderr, "I will probe address range 0x%02x-0x%02x.\n", first, last);
    fprintf(stderr, "Continue? [Y/n] ");
    fflush(stderr);
    fgets(s, 2, stdin);
    if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
      fprintf(stderr, "Aborting on user request.\n");
      exit(0);
    }
  }
  res = scan_i2c_bus(file, mode, first, last);
  close(file);
  exit(res ? 1 : 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x3,-0x50(%rbp)
movl   $0x77,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x6b(%rbp)
jge    123b <main+0x7b>
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,-0x6b(%rbp)
mov    -0x6b(%rbp),%al
test   $0x1,%al
jne    124b <main+0x8b>
jmp    1372 <main+0x1b2>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    0x8(%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffaa,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x23,%eax
ja     1327 <main+0x167>
mov    -0x78(%rbp),%rax
lea    0xd87(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x60(%rbp)
jmp    1364 <main+0x1a4>
movl   $0x1,-0x5c(%rbp)
jmp    1364 <main+0x1a4>
movl   $0x1,-0x64(%rbp)
jmp    1364 <main+0x1a4>
cmpl   $0x1,-0x4c(%rbp)
jne    12d1 <main+0x111>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x2,-0x4c(%rbp)
jmp    1364 <main+0x1a4>
cmpl   $0x2,-0x4c(%rbp)
jne    1308 <main+0x148>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x1,-0x4c(%rbp)
jmp    1364 <main+0x1a4>
movl   $0x0,-0x50(%rbp)
movl   $0x7f,-0x54(%rbp)
jmp    1364 <main+0x1a4>
mov    0x2caa(%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    0xd67(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    120a <main+0x4a>
cmpl   $0x0,-0x60(%rbp)
je     13a1 <main+0x1e1>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
lea    0xd58(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x64(%rbp)
je     13bc <main+0x1fc>
mov    $0x1,%edi
call   1030 <print_i2c_busses@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    -0x58(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    13f5 <main+0x235>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@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   1080 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1449 <main+0x289>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
jl     1460 <main+0x2a0>
cmpl   $0xff,-0x1c(%rbp)
jle    1488 <main+0x2c8>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    -0x58(%rbp),%ecx
add    $0x4,%ecx
cmp    %ecx,%eax
jne    15de <main+0x41e>
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   1080 <strtol@plt>
mov    %eax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     14ed <main+0x32d>
mov    0x2b0c(%rip),%rax
mov    (%rax),%edi
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x68(%rbp),%eax
cmp    -0x50(%rbp),%eax
jl     1505 <main+0x345>
mov    -0x68(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    1533 <main+0x373>
mov    0x2acc(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%ecx
lea    0xc6d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x50(%rbp)
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   1080 <strtol@plt>
mov    %eax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     158d <main+0x3cd>
mov    0x2a6c(%rip),%rax
mov    (%rax),%edi
lea    0xc48(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x68(%rbp),%eax
cmp    -0x50(%rbp),%eax
jl     15a5 <main+0x3e5>
mov    -0x68(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    15d3 <main+0x413>
mov    0x2a2c(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%ecx
lea    0xc25(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    1605 <main+0x445>
mov    -0x8(%rbp),%eax
mov    -0x58(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
je     1600 <main+0x440>
mov    $0x0,%al
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1605 <main+0x445>
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   10a0 <open_i2c_dev@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    162a <main+0x46a>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%edi
mov    $0x705,%esi
lea    -0x48(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
jge    1685 <main+0x4c5>
mov    0x298c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2978(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rdx
lea    0xba8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x4c(%rbp)
je     16cc <main+0x50c>
mov    -0x48(%rbp),%rax
and    $0x10000,%rax
cmp    $0x0,%rax
jne    16cc <main+0x50c>
mov    0x292e(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x1,-0x4c(%rbp)
je     1713 <main+0x553>
mov    -0x48(%rbp),%rax
and    $0x20000,%rax
cmp    $0x0,%rax
jne    1713 <main+0x553>
mov    0x28e7(%rip),%rax
mov    (%rax),%edi
lea    0xb98(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x5c(%rbp)
jne    184f <main+0x68f>
mov    0x28b4(%rip),%rax
mov    (%rax),%edi
lea    0xba6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x289d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
cmpl   $0x1,-0x4c(%rbp)
jne    176b <main+0x5ab>
lea    0xbd9(%rip),%rax
mov    %rax,-0x98(%rbp)
jmp    178a <main+0x5ca>
mov    -0x4c(%rbp),%edx
lea    0x95f(%rip),%rax
lea    0xbd8(%rip),%rcx
cmp    $0x2,%edx
cmove  %rcx,%rax
mov    %rax,-0x98(%rbp)
mov    -0x88(%rbp),%rdx
mov    -0x8c(%rbp),%edi
mov    -0x98(%rbp),%rcx
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2825(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%ecx
lea    0xbac(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2808(%rip),%rax
mov    (%rax),%edi
lea    0xbc0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x27f1(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x6a(%rbp),%rdi
mov    0x27ef(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1060 <fgets@plt>
movsbl -0x6a(%rbp),%eax
cmp    $0xa,%eax
je     184a <main+0x68a>
movsbl -0x6a(%rbp),%eax
cmp    $0x79,%eax
je     184a <main+0x68a>
movsbl -0x6a(%rbp),%eax
cmp    $0x59,%eax
je     184a <main+0x68a>
mov    0x27a5(%rip),%rax
mov    (%rax),%edi
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    184f <main+0x68f>
mov    -0x20(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%ecx
call   10e0 <scan_i2c_bus@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    -0x24(%rbp),%ecx
xor    %edi,%edi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jl     12ad <main+0xed>
mov    0x8(%r14),%rdx
cmpb   $0x2d,(%rdx)
jne    132c <main+0x16c>
mov    %edi,%r8d
lea    -0x1(%rdi),%eax
mov    %rax,0x10(%rsp)
mov    %r8,%r11
add    $0xfffffffffffffffe,%r11
mov    $0x77,%r10d
mov    $0x3,%r15d
xor    %esi,%esi
lea    0xdf2(%rip),%rax
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %ecx,%ecx
xor    %r9d,%r9d
nopl   0x0(%rax)
movsbl 0x1(%rdx),%edx
lea    -0x56(%rdx),%ebx
cmp    $0x23,%ebx
ja     149b <main+0x2db>
mov    $0x1,%ebp
movslq (%rax,%rbx,4),%rbx
add    %rax,%rbx
jmp    *%rbx
mov    $0x7f,%r10d
xor    %r15d,%r15d
jmp    126a <main+0xaa>
mov    $0x1,%r9d
jmp    126a <main+0xaa>
mov    %ecx,%ebp
cmp    $0x1,%r12d
mov    $0x2,%r12d
jne    1280 <main+0xc0>
jmp    1465 <main+0x2a5>
mov    $0x1,%r13d
mov    %ecx,%ebp
jmp    1280 <main+0xc0>
mov    %ecx,%ebp
cmp    $0x2,%r12d
mov    $0x1,%r12d
je     1465 <main+0x2a5>
cmp    %rsi,%r11
je     1391 <main+0x1d1>
mov    0x10(%r14,%rsi,8),%rdx
add    $0x1,%rsi
cmpb   $0x2d,(%rdx)
mov    %ebp,%ecx
je     1220 <main+0x60>
mov    %rsi,%r8
add    $0x1,%r8
test   %ebp,%ebp
je     134f <main+0x18f>
jmp    139a <main+0x1da>
xor    %r12d,%r12d
mov    $0x1,%r8d
mov    $0x77,%r10d
mov    $0x3,%r15d
xor    %esi,%esi
xor    %r13d,%r13d
lea    0x2(%rsi),%ebp
cmp    %edi,%ebp
jle    12e3 <main+0x123>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
jmp    1379 <main+0x1b9>
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
mov    %r10d,(%rsp)
mov    %r8d,%eax
mov    (%r14,%rax,8),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,%edi
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1369 <main+0x1a9>
cmp    $0x100,%edi
jb     13bf <main+0x1ff>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
jmp    1379 <main+0x1b9>
mov    $0x3,%r15d
mov    $0x77,%r10d
xor    %r9d,%r9d
mov    $0x1,%r8d
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %esi,%esi
xor    %r12d,%r12d
test   %ebp,%ebp
jne    139a <main+0x1da>
test   %r9d,%r9d
je     12c7 <main+0x107>
mov    $0x1,%edi
call   1030 <print_i2c_busses@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   10b0 <help@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x10(%rsp),%rsi
test   %ebp,%ebp
je     134f <main+0x18f>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xd2b(%rip),%rsi
lea    0xd3a(%rip),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    0x10(%rsp),%rax
add    $0x4,%eax
cmp    %ebx,%eax
jne    1443 <main+0x283>
mov    %edi,%ebx
mov    %ebp,%eax
mov    (%r14,%rax,8),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1486 <main+0x2c6>
cmp    %r15d,%ebp
mov    (%rsp),%ecx
jl     14fe <main+0x33e>
cmp    %ecx,%ebp
jg     14fe <main+0x33e>
mov    0x10(%rsp),%eax
mov    0x18(%r14,%rax,8),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1620 <main+0x460>
cmp    %ebp,%eax
mov    (%rsp),%ecx
jl     1651 <main+0x491>
cmp    %ecx,%eax
jg     1651 <main+0x491>
mov    %ebp,%r15d
mov    %eax,(%rsp)
mov    %ebx,%edi
jmp    144b <main+0x28b>
cmp    %ebx,%ebp
jne    1380 <main+0x1c0>
lea    0x20(%rsp),%rsi
xor    %edx,%edx
call   10a0 <open_i2c_dev@plt>
test   %eax,%eax
jns    14b7 <main+0x2f7>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b6c(%rip),%rax
mov    (%rax),%edi
lea    0xc1b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b4b(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
jmp    1379 <main+0x1b9>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
lea    0xc08(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1380 <main+0x1c0>
mov    %eax,%ebp
lea    0x18(%rsp),%rdx
mov    %eax,%edi
mov    $0x705,%esi
call   1040 <ioctl@plt>
test   %rax,%rax
jns    151d <main+0x35d>
mov    0x2b02(%rip),%rax
mov    (%rax),%ebx
mov    0x2af1(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd27(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1697 <main+0x4d7>
mov    0x2ad3(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1380 <main+0x1c0>
mov    0x18(%rsp),%rax
cmp    $0x2,%r12d
jne    1635 <main+0x475>
test   $0x20000,%eax
mov    (%rsp),%ecx
je     1680 <main+0x4c0>
test   %r13d,%r13d
jne    15fd <main+0x43d>
mov    0x2a8e(%rip),%r13
mov    0x0(%r13),%edi
lea    0xd7e(%rip),%rsi
xor    %eax,%eax
mov    %ecx,%r14d
call   1070 <fprintf@plt>
cmp    $0x2,%r12d
mov    0x0(%r13),%edi
lea    0xde6(%rip),%rax
lea    0xb5f(%rip),%rdx
cmove  %rax,%rdx
cmp    $0x1,%r12d
lea    0xdb4(%rip),%rcx
cmovne %rdx,%rcx
lea    0xd90(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xdc8(%rip),%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xddb(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
call   1090 <fflush@plt>
mov    0x2a13(%rip),%rax
mov    (%rax),%edx
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1060 <fgets@plt>
mov    0x6(%rsp),%al
cmp    $0xa,%al
je     15fa <main+0x43a>
cmp    $0x59,%al
je     15fa <main+0x43a>
cmp    $0x79,%al
jne    16a8 <main+0x4e8>
mov    (%rsp),%ecx
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   10e0 <scan_i2c_bus@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1050 <close@plt>
xor    %edi,%edi
test   %ebx,%ebx
setne  %dil
call   10c0 <exit@plt>
mov    0x29b1(%rip),%rax
mov    (%rax),%edi
lea    0xb8d(%rip),%rsi
jmp    1379 <main+0x1b9>
test   $0x10000,%eax
mov    (%rsp),%ecx
jne    1668 <main+0x4a8>
mov    0x2992(%rip),%rax
mov    (%rax),%edi
lea    0xc00(%rip),%rsi
jmp    1690 <main+0x4d0>
mov    0x2980(%rip),%rax
mov    (%rax),%edi
lea    0xb7f(%rip),%rsi
mov    %ebp,%edx
jmp    1511 <main+0x351>
cmp    $0x1,%r12d
je     153a <main+0x37a>
and    $0x20000,%eax
test   %rax,%rax
jne    153a <main+0x37a>
mov    0x2951(%rip),%rax
mov    (%rax),%edi
lea    0xc02(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x0(%r13),%edi
lea    0xcf7(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Error: Different modes specified!\0A\00"
@.str.1 = [34 x i8] c"Warning: Unsupported flag \22-%c\22!\0A\00"
@.str.2 = [22 x i8] c"i2cdetect version %s\0A\00"
@.str.3 = [7 x i8] c"2.10.0\00"
@.str.4 = [30 x i8] c"Error: No i2c-bus specified!\0A\00"
@.str.5 = [38 x i8] c"Error: I2CBUS argument not a number!\0A\00"
@.str.6 = [46 x i8] c"Error: I2CBUS argument out of range (0-255)!\0A\00"
@.str.7 = [36 x i8] c"Error: FIRST argment not a number!\0A\00"
@.str.8 = [53 x i8] c"Error: FIRST argument out of range (0x%02x-0x%02x)!\0A\00"
@.str.9 = [35 x i8] c"Error: LAST argment not a number!\0A\00"
@.str.10 = [52 x i8] c"Error: LAST argument out of range (0x%02x-0x%02x)!\0A\00"
@.str.11 = [59 x i8] c"Error: Could not get the adapter functionality matrix: %s\0A\00"
@errno = global i32 0
@.str.12 = [67 x i8] c"Error: Can't use SMBus Quick Write command on this bus (ISA bus?)\0A\00"
@.str.13 = [65 x i8] c"Error: Can't use SMBus Read Byte command on this bus (ISA bus?)\0A\00"
@.str.14 = [76 x i8] c"WARNING! This program can confuse your I2C bus, cause data loss and worse!\0A\00"
@.str.15 = [25 x i8] c"I will probe file %s%s.\0A\00"
@.str.16 = [28 x i8] c" using quick write commands\00"
@.str.17 = [26 x i8] c" using read byte commands\00"
@.str.18 = [1 x i8] zeroinitializer
@.str.19 = [43 x i8] c"I will probe address range 0x%02x-0x%02x.\0A\00"
@.str.20 = [17 x i8] c"Continue? [Y/n] \00"
@stdin = global i32 0
@.str.21 = [27 x i8] c"Aborting on user request.\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 [20 x i8]
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca [2 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i32 3, i32* %13
store i32 119, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %21
21: ; preds = %83, %2
%22 = load i32, i32* %15
%23 = add nsw i32 1, %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i8**, i8*** %5
%28 = load i32, i32* %15
%29 = add nsw i32 1, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 45
br label %37
37: ; preds = %26, %21
%38 = phi i1 [ false, %21 ], [ %36, %26 ]
br i1 %38, label %39, label %86
39: ; preds = %37
%40 = load i8**, i8*** %5
%41 = load i32, i32* %15
%42 = add nsw i32 1, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
switch i32 %48, label %69 [
i32 86, label %49
i32 121, label %50
i32 108, label %51
i32 114, label %52
i32 113, label %60
i32 97, label %68
]
49: ; preds = %39
store i32 1, i32* %17
br label %83
50: ; preds = %39
store i32 1, i32* %16
br label %83
51: ; preds = %39
store i32 1, i32* %18
br label %83
52: ; preds = %39
%53 = load i32, i32* %12
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %52
store i32 2, i32* %12
br label %83
60: ; preds = %39
%61 = load i32, i32* %12
%62 = icmp eq i32 %61, 2
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %60
store i32 1, i32* %12
br label %83
68: ; preds = %39
store i32 0, i32* %13
store i32 127, i32* %14
br label %83
69: ; preds = %39
%70 = load i32, i32* @stderr
%71 = load i8**, i8*** %5
%72 = load i32, i32* %15
%73 = add nsw i32 1, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %71, i64 %74
%76 = load i8*, i8** %75
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %79)
%81 = call i32 (...) @help()
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %68, %67, %59, %51, %50, %49
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 1
store i32 %85, i32* %15
br label %21
86: ; preds = %37
%87 = load i32, i32* %17
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%92 = call i32 @exit(i32 0)
unreachable
93: ; preds = %86
%94 = load i32, i32* %18
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = call i32 @print_i2c_busses(i32 1)
%98 = call i32 @exit(i32 0)
unreachable
99: ; preds = %93
%100 = load i32, i32* %4
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 2
%103 = icmp slt i32 %100, %102
br i1 %103, label %104, label %109
104: ; preds = %99
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%107 = call i32 (...) @help()
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %99
%110 = load i8**, i8*** %5
%111 = load i32, i32* %15
%112 = add nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8*, i8** %110, i64 %113
%115 = load i8*, i8** %114
%116 = call i32 @strtol(i8* %115, i8** %6, i32 0)
store i32 %116, i32* %7
%117 = load i8*, i8** %6
%118 = load i8, i8* %117
%119 = icmp ne i8 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %109
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%123 = call i32 (...) @help()
%124 = call i32 @exit(i32 1)
unreachable
125: ; preds = %109
%126 = load i32, i32* %7
%127 = icmp slt i32 %126, 0
br i1 %127, label %131, label %128
128: ; preds = %125
%129 = load i32, i32* %7
%130 = icmp sgt i32 %129, 255
br i1 %130, label %131, label %136
131: ; preds = %128, %125
%132 = load i32, i32* @stderr
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%134 = call i32 (...) @help()
%135 = call i32 @exit(i32 1)
unreachable
136: ; preds = %128
%137 = load i32, i32* %4
%138 = load i32, i32* %15
%139 = add nsw i32 %138, 4
%140 = icmp eq i32 %137, %139
br i1 %140, label %141, label %206
141: ; preds = %136
%142 = load i8**, i8*** %5
%143 = load i32, i32* %15
%144 = add nsw i32 %143, 2
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8*, i8** %142, i64 %145
%147 = load i8*, i8** %146
%148 = call i32 @strtol(i8* %147, i8** %6, i32 0)
store i32 %148, i32* %19
%149 = load i8*, i8** %6
%150 = load i8, i8* %149
%151 = icmp ne i8 %150, 0
br i1 %151, label %152, label %157
152: ; preds = %141
%153 = load i32, i32* @stderr
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%155 = call i32 (...) @help()
%156 = call i32 @exit(i32 1)
unreachable
157: ; preds = %141
%158 = load i32, i32* %19
%159 = load i32, i32* %13
%160 = icmp slt i32 %158, %159
br i1 %160, label %165, label %161
161: ; preds = %157
%162 = load i32, i32* %19
%163 = load i32, i32* %14
%164 = icmp sgt i32 %162, %163
br i1 %164, label %165, label %172
165: ; preds = %161, %157
%166 = load i32, i32* @stderr
%167 = load i32, i32* %13
%168 = load i32, i32* %14
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i32 %167, i32 %168)
%170 = call i32 (...) @help()
%171 = call i32 @exit(i32 1)
unreachable
172: ; preds = %161
%173 = load i32, i32* %19
store i32 %173, i32* %13
%174 = load i8**, i8*** %5
%175 = load i32, i32* %15
%176 = add nsw i32 %175, 3
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8*, i8** %174, i64 %177
%179 = load i8*, i8** %178
%180 = call i32 @strtol(i8* %179, i8** %6, i32 0)
store i32 %180, i32* %19
%181 = load i8*, i8** %6
%182 = load i8, i8* %181
%183 = icmp ne i8 %182, 0
br i1 %183, label %184, label %189
184: ; preds = %172
%185 = load i32, i32* @stderr
%186 = call i32 (i32, i8*, ...) @fprintf(i32 %185, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%187 = call i32 (...) @help()
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %172
%190 = load i32, i32* %19
%191 = load i32, i32* %13
%192 = icmp slt i32 %190, %191
br i1 %192, label %197, label %193
193: ; preds = %189
%194 = load i32, i32* %19
%195 = load i32, i32* %14
%196 = icmp sgt i32 %194, %195
br i1 %196, label %197, label %204
197: ; preds = %193, %189
%198 = load i32, i32* @stderr
%199 = load i32, i32* %13
%200 = load i32, i32* %14
%201 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0), i32 %199, i32 %200)
%202 = call i32 (...) @help()
%203 = call i32 @exit(i32 1)
unreachable
204: ; preds = %193
%205 = load i32, i32* %19
store i32 %205, i32* %14
br label %215
206: ; preds = %136
%207 = load i32, i32* %4
%208 = load i32, i32* %15
%209 = add nsw i32 %208, 2
%210 = icmp ne i32 %207, %209
br i1 %210, label %211, label %214
211: ; preds = %206
%212 = call i32 (...) @help()
%213 = call i32 @exit(i32 1)
unreachable
214: ; preds = %206
br label %215
215: ; preds = %214, %204
%216 = load i32, i32* %7
%217 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%218 = call i32 @open_i2c_dev(i32 %216, i8* %217, i32 0)
store i32 %218, i32* %8
%219 = load i32, i32* %8
%220 = icmp slt i32 %219, 0
br i1 %220, label %221, label %223
221: ; preds = %215
%222 = call i32 @exit(i32 1)
unreachable
223: ; preds = %215
%224 = load i32, i32* %8
%225 = call i64 @ioctl(i32 %224, i32 1797, i64* %11)
%226 = icmp slt i64 %225, 0
br i1 %226, label %227, label %235
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 ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0), i8* %230)
%232 = load i32, i32* %8
%233 = call i32 @close(i32 %232)
%234 = call i32 @exit(i32 1)
unreachable
235: ; preds = %223
%236 = load i32, i32* %12
%237 = icmp ne i32 %236, 2
br i1 %237, label %238, label %248
238: ; preds = %235
%239 = load i64, i64* %11
%240 = and i64 %239, 65536
%241 = icmp ne i64 %240, 0
br i1 %241, label %248, label %242
242: ; preds = %238
%243 = load i32, i32* @stderr
%244 = call i32 (i32, i8*, ...) @fprintf(i32 %243, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.12, i64 0, i64 0))
%245 = load i32, i32* %8
%246 = call i32 @close(i32 %245)
%247 = call i32 @exit(i32 1)
unreachable
248: ; preds = %238, %235
%249 = load i32, i32* %12
%250 = icmp ne i32 %249, 1
br i1 %250, label %251, label %261
251: ; preds = %248
%252 = load i64, i64* %11
%253 = and i64 %252, 131072
%254 = icmp ne i64 %253, 0
br i1 %254, label %261, label %255
255: ; preds = %251
%256 = load i32, i32* @stderr
%257 = call i32 (i32, i8*, ...) @fprintf(i32 %256, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0))
%258 = load i32, i32* %8
%259 = call i32 @close(i32 %258)
%260 = call i32 @exit(i32 1)
unreachable
261: ; preds = %251, %248
%262 = load i32, i32* %16
%263 = icmp ne i32 %262, 0
br i1 %263, label %310, label %264
264: ; preds = %261
%265 = load i32, i32* @stderr
%266 = call i32 (i32, i8*, ...) @fprintf(i32 %265, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.14, i64 0, i64 0))
%267 = load i32, i32* @stderr
%268 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%269 = load i32, i32* %12
%270 = icmp eq i32 %269, 1
br i1 %270, label %271, label %272
271: ; preds = %264
br label %277
272: ; preds = %264
%273 = load i32, i32* %12
%274 = icmp eq i32 %273, 2
%275 = zext i1 %274 to i64
%276 = select i1 %274, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.18, i64 0, i64 0)
br label %277
277: ; preds = %272, %271
%278 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), %271 ], [ %276, %272 ]
%279 = call i32 (i32, i8*, ...) @fprintf(i32 %267, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), i8* %268, i8* %278)
%280 = load i32, i32* @stderr
%281 = load i32, i32* %13
%282 = load i32, i32* %14
%283 = call i32 (i32, i8*, ...) @fprintf(i32 %280, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0), i32 %281, i32 %282)
%284 = load i32, i32* @stderr
%285 = call i32 (i32, i8*, ...) @fprintf(i32 %284, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0))
%286 = load i32, i32* @stderr
%287 = call i32 @fflush(i32 %286)
%288 = getelementptr inbounds [2 x i8], [2 x i8]* %20, i64 0, i64 0
%289 = load i32, i32* @stdin
%290 = call i32 @fgets(i8* %288, i32 2, i32 %289)
%291 = getelementptr inbounds [2 x i8], [2 x i8]* %20, i64 0, i64 0
%292 = load i8, i8* %291
%293 = sext i8 %292 to i32
%294 = icmp ne i32 %293, 10
br i1 %294, label %295, label %309
295: ; preds = %277
%296 = getelementptr inbounds [2 x i8], [2 x i8]* %20, i64 0, i64 0
%297 = load i8, i8* %296
%298 = sext i8 %297 to i32
%299 = icmp ne i32 %298, 121
br i1 %299, label %300, label %309
300: ; preds = %295
%301 = getelementptr inbounds [2 x i8], [2 x i8]* %20, i64 0, i64 0
%302 = load i8, i8* %301
%303 = sext i8 %302 to i32
%304 = icmp ne i32 %303, 89
br i1 %304, label %305, label %309
305: ; preds = %300
%306 = load i32, i32* @stderr
%307 = call i32 (i32, i8*, ...) @fprintf(i32 %306, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%308 = call i32 @exit(i32 0)
unreachable
309: ; preds = %300, %295, %277
br label %310
310: ; preds = %309, %261
%311 = load i32, i32* %8
%312 = load i32, i32* %12
%313 = load i32, i32* %13
%314 = load i32, i32* %14
%315 = call i32 @scan_i2c_bus(i32 %311, i32 %312, i32 %313, i32 %314)
store i32 %315, i32* %9
%316 = load i32, i32* %8
%317 = call i32 @close(i32 %316)
%318 = load i32, i32* %9
%319 = icmp ne i32 %318, 0
%320 = zext i1 %319 to i64
%321 = select i1 %319, i32 1, i32 0
%322 = call i32 @exit(i32 %321)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Error: Different modes specified!\0A\00"
@.str.1 = [34 x i8] c"Warning: Unsupported flag \22-%c\22!\0A\00"
@.str.2 = [22 x i8] c"i2cdetect version %s\0A\00"
@.str.3 = [7 x i8] c"2.10.0\00"
@.str.4 = [30 x i8] c"Error: No i2c-bus specified!\0A\00"
@.str.5 = [38 x i8] c"Error: I2CBUS argument not a number!\0A\00"
@.str.6 = [46 x i8] c"Error: I2CBUS argument out of range (0-255)!\0A\00"
@.str.7 = [36 x i8] c"Error: FIRST argment not a number!\0A\00"
@.str.8 = [53 x i8] c"Error: FIRST argument out of range (0x%02x-0x%02x)!\0A\00"
@.str.9 = [35 x i8] c"Error: LAST argment not a number!\0A\00"
@.str.10 = [52 x i8] c"Error: LAST argument out of range (0x%02x-0x%02x)!\0A\00"
@.str.11 = [59 x i8] c"Error: Could not get the adapter functionality matrix: %s\0A\00"
@errno = global i32 0
@.str.12 = [67 x i8] c"Error: Can't use SMBus Quick Write command on this bus (ISA bus?)\0A\00"
@.str.13 = [65 x i8] c"Error: Can't use SMBus Read Byte command on this bus (ISA bus?)\0A\00"
@.str.14 = [76 x i8] c"WARNING! This program can confuse your I2C bus, cause data loss and worse!\0A\00"
@.str.15 = [25 x i8] c"I will probe file %s%s.\0A\00"
@.str.16 = [28 x i8] c" using quick write commands\00"
@.str.17 = [26 x i8] c" using read byte commands\00"
@.str.18 = [1 x i8] zeroinitializer
@.str.19 = [43 x i8] c"I will probe address range 0x%02x-0x%02x.\0A\00"
@.str.20 = [17 x i8] c"Continue? [Y/n] \00"
@stdin = global i32 0
@.str.21 = [27 x i8] c"Aborting on user request.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [20 x i8]
%5 = alloca i64
%6 = alloca [2 x i8]
%7 = bitcast i8** %3 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = bitcast i64* %5 to i8*
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %96
11: ; preds = %2
%12 = add nsw i32 %0, -1
%13 = zext i32 %0 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %24, label %67
18: ; preds = %58
%19 = trunc i64 %65 to i32
%20 = getelementptr inbounds i8*, i8** %1, i64 %65
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 45
br i1 %23, label %24, label %67
24: ; preds = %11, %18
%25 = phi i8* [ %21, %18 ], [ %15, %11 ]
%26 = phi i32 [ %19, %18 ], [ 1, %11 ]
%27 = phi i32 [ %59, %18 ], [ 0, %11 ]
%28 = phi i32 [ %60, %18 ], [ 3, %11 ]
%29 = phi i32 [ %61, %18 ], [ 119, %11 ]
%30 = phi i32 [ %62, %18 ], [ 0, %11 ]
%31 = phi i32 [ %63, %18 ], [ 0, %11 ]
%32 = phi i32 [ %64, %18 ], [ 0, %11 ]
%33 = phi i64 [ %65, %18 ], [ 1, %11 ]
%34 = getelementptr inbounds i8, i8* %25, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
switch i32 %36, label %52 [
i32 86, label %58
i32 121, label %37
i32 108, label %38
i32 114, label %39
i32 113, label %45
i32 97, label %51
]
37: ; preds = %24
br label %58
38: ; preds = %24
br label %58
39: ; preds = %24
%40 = icmp eq i32 %27, 1
br i1 %40, label %41, label %58
41: ; preds = %39
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %24
%46 = icmp eq i32 %27, 2
br i1 %46, label %47, label %58
47: ; preds = %45
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %24
br label %58
52: ; preds = %24
%53 = sext i8 %35 to i32
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%56 = tail call i32 (...) @help()
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %45, %39, %24, %51, %38, %37
%59 = phi i32 [ %27, %51 ], [ %27, %38 ], [ %27, %37 ], [ %27, %24 ], [ 2, %39 ], [ 1, %45 ]
%60 = phi i32 [ 0, %51 ], [ %28, %38 ], [ %28, %37 ], [ %28, %24 ], [ %28, %39 ], [ %28, %45 ]
%61 = phi i32 [ 127, %51 ], [ %29, %38 ], [ %29, %37 ], [ %29, %24 ], [ %29, %39 ], [ %29, %45 ]
%62 = phi i32 [ %30, %51 ], [ %30, %38 ], [ 1, %37 ], [ %30, %24 ], [ %30, %39 ], [ %30, %45 ]
%63 = phi i32 [ %31, %51 ], [ %31, %38 ], [ %31, %37 ], [ 1, %24 ], [ %31, %39 ], [ %31, %45 ]
%64 = phi i32 [ %32, %51 ], [ 1, %38 ], [ %32, %37 ], [ %32, %24 ], [ %32, %39 ], [ %32, %45 ]
%65 = add nuw nsw i64 %33, 1
%66 = icmp eq i64 %65, %13
br i1 %66, label %77, label %18
67: ; preds = %18, %11
%68 = phi i64 [ 1, %11 ], [ %65, %18 ]
%69 = phi i32 [ 0, %11 ], [ %64, %18 ]
%70 = phi i32 [ 0, %11 ], [ %63, %18 ]
%71 = phi i32 [ 0, %11 ], [ %62, %18 ]
%72 = phi i32 [ 0, %11 ], [ %26, %18 ]
%73 = phi i32 [ 119, %11 ], [ %61, %18 ]
%74 = phi i32 [ 3, %11 ], [ %60, %18 ]
%75 = phi i32 [ 0, %11 ], [ %59, %18 ]
%76 = trunc i64 %68 to i32
br label %77
77: ; preds = %58, %67
%78 = phi i32 [ %75, %67 ], [ %59, %58 ]
%79 = phi i32 [ %74, %67 ], [ %60, %58 ]
%80 = phi i32 [ %73, %67 ], [ %61, %58 ]
%81 = phi i32 [ %72, %67 ], [ %12, %58 ]
%82 = phi i32 [ %71, %67 ], [ %62, %58 ]
%83 = phi i32 [ %70, %67 ], [ %63, %58 ]
%84 = phi i32 [ %69, %67 ], [ %64, %58 ]
%85 = phi i32 [ %76, %67 ], [ %0, %58 ]
%86 = icmp eq i32 %83, 0
br i1 %86, label %91, label %87
87: ; preds = %77
%88 = load i32, i32* @stderr
%89 = tail call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%90 = tail call i32 @exit(i32 0)
unreachable
91: ; preds = %77
%92 = icmp eq i32 %84, 0
br i1 %92, label %96, label %93
93: ; preds = %91
%94 = tail call i32 @print_i2c_busses(i32 1)
%95 = tail call i32 @exit(i32 0)
unreachable
96: ; preds = %2, %91
%97 = phi i32 [ %78, %91 ], [ 0, %2 ]
%98 = phi i32 [ %79, %91 ], [ 3, %2 ]
%99 = phi i32 [ %80, %91 ], [ 119, %2 ]
%100 = phi i32 [ %81, %91 ], [ 0, %2 ]
%101 = phi i32 [ %82, %91 ], [ 0, %2 ]
%102 = phi i32 [ %85, %91 ], [ 1, %2 ]
%103 = add nuw nsw i32 %100, 2
%104 = icmp sgt i32 %103, %0
br i1 %104, label %105, label %110
105: ; preds = %96
%106 = load i32, i32* @stderr
%107 = tail call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%108 = tail call i32 (...) @help()
%109 = tail call i32 @exit(i32 1)
unreachable
110: ; preds = %96
%111 = zext i32 %102 to i64
%112 = getelementptr inbounds i8*, i8** %1, i64 %111
%113 = load i8*, i8** %112
%114 = call i32 @strtol(i8* %113, i8** %3, i32 0)
%115 = load i8*, i8** %3
%116 = load i8, i8* %115
%117 = icmp eq i8 %116, 0
br i1 %117, label %123, label %118
118: ; preds = %110
%119 = load i32, i32* @stderr
%120 = tail call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%121 = tail call i32 (...) @help()
%122 = tail call i32 @exit(i32 1)
unreachable
123: ; preds = %110
%124 = icmp ugt i32 %114, 255
br i1 %124, label %125, label %130
125: ; preds = %123
%126 = load i32, i32* @stderr
%127 = tail call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%128 = tail call i32 (...) @help()
%129 = tail call i32 @exit(i32 1)
unreachable
130: ; preds = %123
%131 = add nuw nsw i32 %100, 4
%132 = icmp eq i32 %131, %0
br i1 %132, label %133, label %178
133: ; preds = %130
%134 = zext i32 %103 to i64
%135 = getelementptr inbounds i8*, i8** %1, i64 %134
%136 = load i8*, i8** %135
%137 = call i32 @strtol(i8* %136, i8** %3, i32 0)
%138 = load i8*, i8** %3
%139 = load i8, i8* %138
%140 = icmp eq i8 %139, 0
br i1 %140, label %146, label %141
141: ; preds = %133
%142 = load i32, i32* @stderr
%143 = tail call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%144 = tail call i32 (...) @help()
%145 = tail call i32 @exit(i32 1)
unreachable
146: ; preds = %133
%147 = icmp slt i32 %137, %98
%148 = icmp sgt i32 %137, %99
%149 = select i1 %147, i1 true, i1 %148
br i1 %149, label %150, label %155
150: ; preds = %146
%151 = load i32, i32* @stderr
%152 = tail call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i32 %98, i32 %99)
%153 = tail call i32 (...) @help()
%154 = tail call i32 @exit(i32 1)
unreachable
155: ; preds = %146
%156 = add nuw nsw i32 %100, 3
%157 = zext i32 %156 to i64
%158 = getelementptr inbounds i8*, i8** %1, i64 %157
%159 = load i8*, i8** %158
%160 = call i32 @strtol(i8* %159, i8** %3, i32 0)
%161 = load i8*, i8** %3
%162 = load i8, i8* %161
%163 = icmp eq i8 %162, 0
br i1 %163, label %169, label %164
164: ; preds = %155
%165 = load i32, i32* @stderr
%166 = tail call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%167 = tail call i32 (...) @help()
%168 = tail call i32 @exit(i32 1)
unreachable
169: ; preds = %155
%170 = icmp slt i32 %160, %137
%171 = icmp sgt i32 %160, %99
%172 = select i1 %170, i1 true, i1 %171
br i1 %172, label %173, label %183
173: ; preds = %169
%174 = load i32, i32* @stderr
%175 = tail call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0), i32 %137, i32 %99)
%176 = tail call i32 (...) @help()
%177 = tail call i32 @exit(i32 1)
unreachable
178: ; preds = %130
%179 = icmp eq i32 %103, %0
br i1 %179, label %183, label %180
180: ; preds = %178
%181 = tail call i32 (...) @help()
%182 = tail call i32 @exit(i32 1)
unreachable
183: ; preds = %169, %178
%184 = phi i32 [ %98, %178 ], [ %137, %169 ]
%185 = phi i32 [ %99, %178 ], [ %160, %169 ]
%186 = call i32 @open_i2c_dev(i32 %114, i8* %8, i32 0)
%187 = icmp slt i32 %186, 0
br i1 %187, label %188, label %190
188: ; preds = %183
%189 = call i32 @exit(i32 1)
unreachable
190: ; preds = %183
%191 = call i64 @ioctl(i32 %186, i32 1797, i64* %5)
%192 = icmp slt i64 %191, 0
br i1 %192, label %193, label %200
193: ; preds = %190
%194 = load i32, i32* @stderr
%195 = load i32, i32* @errno
%196 = call i8* @strerror(i32 %195)
%197 = call i32 (i32, i8*, ...) @fprintf(i32 %194, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0), i8* %196)
%198 = call i32 @close(i32 %186)
%199 = call i32 @exit(i32 1)
unreachable
200: ; preds = %190
%201 = icmp eq i32 %97, 2
%202 = load i64, i64* %5
br i1 %201, label %216, label %203
203: ; preds = %200
%204 = and i64 %202, 65536
%205 = icmp eq i64 %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 ([67 x i8], [67 x i8]* @.str.12, i64 0, i64 0))
%209 = call i32 @close(i32 %186)
%210 = call i32 @exit(i32 1)
unreachable
211: ; preds = %203
%212 = icmp ne i32 %97, 1
%213 = and i64 %202, 131072
%214 = icmp eq i64 %213, 0
%215 = select i1 %212, i1 %214, i1 false
br i1 %215, label %219, label %224
216: ; preds = %200
%217 = and i64 %202, 131072
%218 = icmp eq i64 %217, 0
br i1 %218, label %219, label %224
219: ; preds = %211, %216
%220 = load i32, i32* @stderr
%221 = call i32 (i32, i8*, ...) @fprintf(i32 %220, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0))
%222 = call i32 @close(i32 %186)
%223 = call i32 @exit(i32 1)
unreachable
224: ; preds = %216, %211
%225 = icmp eq i32 %101, 0
br i1 %225, label %226, label %249
226: ; preds = %224
%227 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%228 = load i32, i32* @stderr
%229 = call i32 (i32, i8*, ...) @fprintf(i32 %228, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.14, i64 0, i64 0))
%230 = load i32, i32* @stderr
%231 = icmp eq i32 %97, 1
%232 = select i1 %201, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.18, i64 0, i64 0)
%233 = select i1 %231, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %232
%234 = call i32 (i32, i8*, ...) @fprintf(i32 %230, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), i8* %8, i8* %233)
%235 = load i32, i32* @stderr
%236 = call i32 (i32, i8*, ...) @fprintf(i32 %235, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0), i32 %184, i32 %185)
%237 = load i32, i32* @stderr
%238 = call i32 (i32, i8*, ...) @fprintf(i32 %237, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0))
%239 = load i32, i32* @stderr
%240 = call i32 @fflush(i32 %239)
%241 = load i32, i32* @stdin
%242 = call i32 @fgets(i8* %227, i32 2, i32 %241)
%243 = load i8, i8* %227
switch i8 %243, label %244 [
i8 121, label %248
i8 89, label %248
i8 10, label %248
]
244: ; preds = %226
%245 = load i32, i32* @stderr
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %245, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%247 = call i32 @exit(i32 0)
unreachable
248: ; preds = %226, %226, %226
br label %249
249: ; preds = %248, %224
%250 = call i32 @scan_i2c_bus(i32 %186, i32 %97, i32 %184, i32 %185)
%251 = call i32 @close(i32 %186)
%252 = icmp ne i32 %250, 0
%253 = zext i1 %252 to i32
%254 = call i32 @exit(i32 %253)
unreachable
}