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

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ handle_bad_opts();
int i2c_open(int);
int i2c_read_word(int, int, int /*<<< orphan*/ *);
int i2c_select(int, int);
int mlx90614_print_all(int);
int mlx90614_reg_to_temp(int /*<<< orphan*/);
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ print_help(char *);
int read_int(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int file = -1;
  int res;
  if (argc < 2) {
    print_help(argv[0]);
    return 0;
  }
  int c;
  int ad = (0x5a);
  opterr = 0;
  while ((c = getopt(argc, argv, "a:Ab:lo")) != -1) {
    switch (c) {
    case 'a': {
      if (file < 0) {
        fprintf(stderr,
                "ERROR: bus number not set prior to address selection.\n\n");
        print_help(argv[0]);
        return -EINVAL;
      }
      if ((ad = read_int(optarg)) < 0) {
        fprintf(stderr, "ERROR: invalid slave address `%s'.\n\n", optarg);
        print_help(argv[0]);
        return -EINVAL;
      }
      if ((ad < 0x03) || (ad > 0x7f)) {
        fprintf(stderr,
                "ERROR: invalid slave address `%s' (out of valid range of 0x03 "
                "to 0x7f).\n\n",
                optarg);
        print_help(argv[0]);
        return -EINVAL;
      }
      if ((res = i2c_select(file, ad)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout, "Address set to 0x%02x\n", ad);
      break;
    }
    case 'A': {
      if (file < 0) {
        fprintf(stderr, "ERROR: bus number not set prior to operation.\n\n");
        print_help(argv[0]);
        return -EINVAL;
      }
      if ((res = mlx90614_print_all(file)) < 0) {
        close(file);
        return res;
      }
      break;
    }
    case 'b': {
      if (file >= 0) {
        close(file);
        file = -1;
      }
      int bn;
      if ((bn = read_int(optarg)) < 0) {
        fprintf(stderr, "ERROR: invalid bus number `%s'.\n\n", optarg);
        print_help(argv[0]);
        return -EINVAL;
      }
      if ((file = i2c_open(bn)) < 0) {
        return file;
      }
      if ((res = i2c_select(file, ad)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout, "Address set to 0x%02x\n", ad);
      break;
    }
    case 'l': {
      if (file < 0) {
        fprintf(stderr, "ERROR: bus number not set prior to operation.\n\n");
        print_help(argv[0]);
        return -EINVAL;
      }
      uint16_t ta;
      if ((res = i2c_read_word(file, (0x06), &ta)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout, "Local Temperature: %.2lf C\n", mlx90614_reg_to_temp(ta));
      break;
    }
    case 'o': {
      if (file < 0) {
        fprintf(stderr, "ERROR: bus number not set prior to operation.\n\n");
        print_help(argv[0]);
        return -EINVAL;
      }
      uint16_t tobj1, tobj2;
      if ((res = i2c_read_word(file, (0x07), &tobj1)) < 0) {
        close(file);
        return res;
      }
      if ((res = i2c_read_word(file, (0x08), &tobj2)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout,
              "Remote Temperature 1: %.2lf C\nRemote Temperature 2: %.2lf C\n",
              mlx90614_reg_to_temp(tobj1), mlx90614_reg_to_temp(tobj2));
      break;
    }
    case '?': {
      handle_bad_opts();
      print_help(argv[0]);
      return -EINVAL;
    }
    default: {
      fprintf(stderr, "BUG: switch fall-through on `%c'!\n", c);
      abort();
    }
    }
  }
  if (file >= 0) {
    close(file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ff <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
movl   $0x5a,-0x20(%rbp)
mov    0x2dc3(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     169e <main+0x4de>
mov    -0x1c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x30,%eax
ja     1678 <main+0x4b8>
mov    -0x38(%rbp),%rax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x14(%rbp)
jge    129c <main+0xdc>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2d36(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x2d55(%rip),%rax
mov    (%rax),%rdi
call   10a0 <read_int@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    12f7 <main+0x137>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2cdb(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
cmpl   $0x3,-0x20(%rbp)
jl     130b <main+0x14b>
cmpl   $0x7f,-0x20(%rbp)
jle    134b <main+0x18b>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    0x2cdd(%rip),%rax
mov    (%rax),%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2c87(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10e0 <i2c_select@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1375 <main+0x1b5>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1699 <main+0x4d9>
cmpl   $0x0,-0x14(%rbp)
jge    13d4 <main+0x214>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2bfe(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
call   1040 <mlx90614_print_all@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13fb <main+0x23b>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
jmp    1699 <main+0x4d9>
cmpl   $0x0,-0x14(%rbp)
jl     1419 <main+0x259>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    0x2bd8(%rip),%rax
mov    (%rax),%rdi
call   10a0 <read_int@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1474 <main+0x2b4>
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
mov    0x2bb4(%rip),%rax
mov    (%rax),%rdx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2b5e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x24(%rbp),%edi
call   1060 <i2c_open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1493 <main+0x2d3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10e0 <i2c_select@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    14bd <main+0x2fd>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xca3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1699 <main+0x4d9>
cmpl   $0x0,-0x14(%rbp)
jge    151c <main+0x35c>
mov    0x2aeb(%rip),%rax
mov    (%rax),%edi
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2ab6(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
mov    $0x6,%esi
lea    -0x28(%rbp),%rdx
call   10b0 <i2c_read_word@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    154c <main+0x38c>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x2a6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%edx
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1699 <main+0x4d9>
cmpl   $0x0,-0x14(%rbp)
jge    15b8 <main+0x3f8>
mov    0x2a4f(%rip),%rax
mov    (%rax),%edi
lea    0xbf8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2a1a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
mov    $0x7,%esi
lea    -0x2c(%rbp),%rdx
call   10b0 <i2c_read_word@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    15e8 <main+0x428>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
lea    -0x30(%rbp),%rdx
call   10b0 <i2c_read_word@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1618 <main+0x458>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x29a1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
lea    0xbb2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1699 <main+0x4d9>
mov    $0x0,%al
call   1050 <handle_bad_opts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x295a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16b7 <main+0x4f7>
mov    0x2959(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xbaa(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1214 <main+0x54>
cmpl   $0x0,-0x14(%rbp)
jl     16b0 <main+0x4f0>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jg     11e5 <main+0x25>
mov    (%r14),%rdi
call   10d0 <print_help@plt>
xor    %ebp,%ebp
jmp    1425 <main+0x265>
mov    %edi,%r15d
mov    0x2de1(%rip),%rax
movq   $0x0,(%rax)
mov    $0x5a,%eax
mov    %rax,(%rsp)
mov    $0xffffffff,%r13d
lea    0xeb8(%rip),%r12
lea    0xded(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x30,%ecx
ja     13f9 <main+0x239>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
test   %r13d,%r13d
js     13de <main+0x21e>
mov    %r13d,%edi
call   1040 <mlx90614_print_all@plt>
test   %eax,%eax
jns    1220 <main+0x60>
jmp    13d2 <main+0x212>
nopl   (%rax)
test   %r13d,%r13d
js     13de <main+0x21e>
mov    %r13d,%edi
mov    $0x6,%esi
lea    0x14(%rsp),%rdx
call   10b0 <i2c_read_word@plt>
test   %eax,%eax
js     13d2 <main+0x212>
mov    0x2d36(%rip),%rax
mov    (%rax),%ebp
mov    0x14(%rsp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    %ebp,%edi
lea    0xf3e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1220 <main+0x60>
nopl   0x0(%rax)
test   %r13d,%r13d
js     13de <main+0x21e>
mov    %r13d,%edi
mov    $0x7,%esi
lea    0x10(%rsp),%rdx
call   10b0 <i2c_read_word@plt>
test   %eax,%eax
js     13d2 <main+0x212>
mov    %r13d,%edi
mov    $0x8,%esi
lea    0xc(%rsp),%rdx
call   10b0 <i2c_read_word@plt>
test   %eax,%eax
js     13d2 <main+0x212>
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x10(%rsp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    %r14,%rbp
mov    %r12,%r14
mov    %eax,%r12d
mov    0xc(%rsp),%edi
call   1090 <mlx90614_reg_to_temp@plt>
mov    0x8(%rsp),%edi
lea    0xed8(%rip),%rsi
mov    %r12d,%edx
mov    %r14,%r12
mov    %rbp,%r14
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1220 <main+0x60>
test   %r13d,%r13d
js     1436 <main+0x276>
mov    0x2cb1(%rip),%rax
mov    (%rax),%rdi
call   10a0 <read_int@plt>
test   %eax,%eax
js     1464 <main+0x2a4>
lea    -0x80(%rax),%ecx
cmp    $0xffffff82,%ecx
jbe    1485 <main+0x2c5>
mov    %r13d,%edi
mov    %rax,%rsi
mov    %rax,(%rsp)
jmp    13b0 <main+0x1f0>
test   %r13d,%r13d
js     137c <main+0x1bc>
mov    %r13d,%edi
call   1070 <close@plt>
mov    0x2c75(%rip),%rax
mov    (%rax),%rdi
call   10a0 <read_int@plt>
test   %eax,%eax
js     1448 <main+0x288>
mov    %eax,%edi
call   1060 <i2c_open@plt>
mov    %eax,%r13d
test   %eax,%eax
js     1480 <main+0x2c0>
mov    %r13d,%edi
mov    (%rsp),%rsi
mov    %rsi,(%rsp)
call   10e0 <i2c_select@plt>
test   %eax,%eax
js     13d2 <main+0x212>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    (%rsp),%rdx
jmp    12a0 <main+0xe0>
mov    %eax,%ebp
mov    %r13d,%edi
call   1070 <close@plt>
jmp    1425 <main+0x265>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1414 <main+0x254>
cmp    $0xffffffff,%eax
jne    14ad <main+0x2ed>
xor    %ebp,%ebp
test   %r13d,%r13d
jns    13d4 <main+0x214>
jmp    1425 <main+0x265>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <handle_bad_opts@plt>
mov    (%r14),%rdi
call   10d0 <print_help@plt>
mov    0x2ba5(%rip),%rax
sub    (%rax),%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
lea    0xc86(%rip),%rsi
jmp    13ee <main+0x22e>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
mov    0x2ba0(%rip),%rax
mov    (%rax),%rdx
lea    0xd58(%rip),%rsi
jmp    149f <main+0x2df>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
mov    0x2b84(%rip),%rax
mov    (%rax),%rdx
lea    0xc86(%rip),%rsi
jmp    149f <main+0x2df>
mov    %r13d,%ebp
jmp    1425 <main+0x265>
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
mov    0x2b63(%rip),%rax
mov    (%rax),%rdx
lea    0xc8a(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1414 <main+0x254>
mov    0x2b24(%rip),%rcx
mov    (%rcx),%edi
lea    0xd78(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [8 x i8] c"a:Ab:lo\00"
@stderr = global i32 0
@.str.1 = [56 x i8] c"ERROR: bus number not set prior to address selection.\0A\0A\00"
@EINVAL = global i32 0
@optarg = global i8* null
@.str.2 = [37 x i8] c"ERROR: invalid slave address `%s'.\0A\0A\00"
@.str.3 = [74 x i8] c"ERROR: invalid slave address `%s' (out of valid range of 0x03 to 0x7f).\0A\0A\00"
@stdout = global i32 0
@.str.4 = [23 x i8] c"Address set to 0x%02x\0A\00"
@.str.5 = [48 x i8] c"ERROR: bus number not set prior to operation.\0A\0A\00"
@.str.6 = [34 x i8] c"ERROR: invalid bus number `%s'.\0A\0A\00"
@.str.7 = [28 x i8] c"Local Temperature: %.2lf C\0A\00"
@.str.8 = [61 x i8] c"Remote Temperature 1: %.2lf C\0ARemote Temperature 2: %.2lf C\0A\00"
@.str.9 = [35 x i8] c"BUG: switch fall-through on `%c'!\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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @print_help(i8* %19)
store i32 0, i32* %3
br label %225
21: ; preds = %2
store i32 90, i32* %9
store i64 0, i64* @opterr
br label %22
22: ; preds = %217, %21
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i32 @getopt(i32 %23, i8** %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %25, i32* %8
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %218
27: ; preds = %22
%28 = load i32, i32* %8
switch i32 %28, label %212 [
i32 97, label %29
i32 65, label %84
i32 98, label %105
i32 108, label %144
i32 111, label %169
i32 63, label %204
]
29: ; preds = %27
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @print_help(i8* %37)
%39 = load i32, i32* @EINVAL
%40 = sub nsw i32 0, %39
store i32 %40, i32* %3
br label %225
41: ; preds = %29
%42 = load i8*, i8** @optarg
%43 = call i32 @read_int(i8* %42)
store i32 %43, i32* %9
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = load i8*, i8** @optarg
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @print_help(i8* %51)
%53 = load i32, i32* @EINVAL
%54 = sub nsw i32 0, %53
store i32 %54, i32* %3
br label %225
55: ; preds = %41
%56 = load i32, i32* %9
%57 = icmp slt i32 %56, 3
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = load i32, i32* %9
%60 = icmp sgt i32 %59, 127
br i1 %60, label %61, label %71
61: ; preds = %58, %55
%62 = load i32, i32* @stderr
%63 = load i8*, i8** @optarg
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %63)
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = call i32 @print_help(i8* %67)
%69 = load i32, i32* @EINVAL
%70 = sub nsw i32 0, %69
store i32 %70, i32* %3
br label %225
71: ; preds = %58
%72 = load i32, i32* %6
%73 = load i32, i32* %9
%74 = call i32 @i2c_select(i32 %72, i32 %73)
store i32 %74, i32* %7
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = load i32, i32* %6
%78 = call i32 @close(i32 %77)
%79 = load i32, i32* %7
store i32 %79, i32* %3
br label %225
80: ; preds = %71
%81 = load i32, i32* @stdout
%82 = load i32, i32* %9
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %82)
br label %217
84: ; preds = %27
%85 = load i32, i32* %6
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %96
87: ; preds = %84
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = call i32 @print_help(i8* %92)
%94 = load i32, i32* @EINVAL
%95 = sub nsw i32 0, %94
store i32 %95, i32* %3
br label %225
96: ; preds = %84
%97 = load i32, i32* %6
%98 = call i32 @mlx90614_print_all(i32 %97)
store i32 %98, i32* %7
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %96
%101 = load i32, i32* %6
%102 = call i32 @close(i32 %101)
%103 = load i32, i32* %7
store i32 %103, i32* %3
br label %225
104: ; preds = %96
br label %217
105: ; preds = %27
%106 = load i32, i32* %6
%107 = icmp sge i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i32, i32* %6
%110 = call i32 @close(i32 %109)
store i32 -1, i32* %6
br label %111
111: ; preds = %108, %105
%112 = load i8*, i8** @optarg
%113 = call i32 @read_int(i8* %112)
store i32 %113, i32* %10
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %125
115: ; preds = %111
%116 = load i32, i32* @stderr
%117 = load i8*, i8** @optarg
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %117)
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 0
%121 = load i8*, i8** %120
%122 = call i32 @print_help(i8* %121)
%123 = load i32, i32* @EINVAL
%124 = sub nsw i32 0, %123
store i32 %124, i32* %3
br label %225
125: ; preds = %111
%126 = load i32, i32* %10
%127 = call i32 @i2c_open(i32 %126)
store i32 %127, i32* %6
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = load i32, i32* %6
store i32 %130, i32* %3
br label %225
131: ; preds = %125
%132 = load i32, i32* %6
%133 = load i32, i32* %9
%134 = call i32 @i2c_select(i32 %132, i32 %133)
store i32 %134, i32* %7
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %140
136: ; preds = %131
%137 = load i32, i32* %6
%138 = call i32 @close(i32 %137)
%139 = load i32, i32* %7
store i32 %139, i32* %3
br label %225
140: ; preds = %131
%141 = load i32, i32* @stdout
%142 = load i32, i32* %9
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %142)
br label %217
144: ; preds = %27
%145 = load i32, i32* %6
%146 = icmp slt i32 %145, 0
br i1 %146, label %147, label %156
147: ; preds = %144
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%150 = load i8**, i8*** %5
%151 = getelementptr inbounds i8*, i8** %150, i64 0
%152 = load i8*, i8** %151
%153 = call i32 @print_help(i8* %152)
%154 = load i32, i32* @EINVAL
%155 = sub nsw i32 0, %154
store i32 %155, i32* %3
br label %225
156: ; preds = %144
%157 = load i32, i32* %6
%158 = call i32 @i2c_read_word(i32 %157, i32 6, i32* %11)
store i32 %158, i32* %7
%159 = icmp slt i32 %158, 0
br i1 %159, label %160, label %164
160: ; preds = %156
%161 = load i32, i32* %6
%162 = call i32 @close(i32 %161)
%163 = load i32, i32* %7
store i32 %163, i32* %3
br label %225
164: ; preds = %156
%165 = load i32, i32* @stdout
%166 = load i32, i32* %11
%167 = call i32 @mlx90614_reg_to_temp(i32 %166)
%168 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %167)
br label %217
169: ; preds = %27
%170 = load i32, i32* %6
%171 = icmp slt i32 %170, 0
br i1 %171, label %172, label %181
172: ; preds = %169
%173 = load i32, i32* @stderr
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%175 = load i8**, i8*** %5
%176 = getelementptr inbounds i8*, i8** %175, i64 0
%177 = load i8*, i8** %176
%178 = call i32 @print_help(i8* %177)
%179 = load i32, i32* @EINVAL
%180 = sub nsw i32 0, %179
store i32 %180, i32* %3
br label %225
181: ; preds = %169
%182 = load i32, i32* %6
%183 = call i32 @i2c_read_word(i32 %182, i32 7, i32* %12)
store i32 %183, i32* %7
%184 = icmp slt i32 %183, 0
br i1 %184, label %185, label %189
185: ; preds = %181
%186 = load i32, i32* %6
%187 = call i32 @close(i32 %186)
%188 = load i32, i32* %7
store i32 %188, i32* %3
br label %225
189: ; preds = %181
%190 = load i32, i32* %6
%191 = call i32 @i2c_read_word(i32 %190, i32 8, i32* %13)
store i32 %191, i32* %7
%192 = icmp slt i32 %191, 0
br i1 %192, label %193, label %197
193: ; preds = %189
%194 = load i32, i32* %6
%195 = call i32 @close(i32 %194)
%196 = load i32, i32* %7
store i32 %196, i32* %3
br label %225
197: ; preds = %189
%198 = load i32, i32* @stdout
%199 = load i32, i32* %12
%200 = call i32 @mlx90614_reg_to_temp(i32 %199)
%201 = load i32, i32* %13
%202 = call i32 @mlx90614_reg_to_temp(i32 %201)
%203 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %200, i32 %202)
br label %217
204: ; preds = %27
%205 = call i32 (...) @handle_bad_opts()
%206 = load i8**, i8*** %5
%207 = getelementptr inbounds i8*, i8** %206, i64 0
%208 = load i8*, i8** %207
%209 = call i32 @print_help(i8* %208)
%210 = load i32, i32* @EINVAL
%211 = sub nsw i32 0, %210
store i32 %211, i32* %3
br label %225
212: ; preds = %27
%213 = load i32, i32* @stderr
%214 = load i32, i32* %8
%215 = call i32 (i32, i8*, ...) @fprintf(i32 %213, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %214)
%216 = call i32 (...) @abort()
unreachable
217: ; preds = %197, %164, %140, %104, %80
br label %22
218: ; preds = %22
%219 = load i32, i32* %6
%220 = icmp sge i32 %219, 0
br i1 %220, label %221, label %224
221: ; preds = %218
%222 = load i32, i32* %6
%223 = call i32 @close(i32 %222)
br label %224
224: ; preds = %221, %218
store i32 0, i32* %3
br label %225
225: ; preds = %224, %204, %193, %185, %172, %160, %147, %136, %129, %115, %100, %87, %76, %61, %45, %32, %16
%226 = load i32, i32* %3
ret i32 %226
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [8 x i8] c"a:Ab:lo\00"
@stderr = global i32 0
@.str.1 = [56 x i8] c"ERROR: bus number not set prior to address selection.\0A\0A\00"
@EINVAL = global i32 0
@optarg = global i8* null
@.str.2 = [37 x i8] c"ERROR: invalid slave address `%s'.\0A\0A\00"
@.str.3 = [74 x i8] c"ERROR: invalid slave address `%s' (out of valid range of 0x03 to 0x7f).\0A\0A\00"
@stdout = global i32 0
@.str.4 = [23 x i8] c"Address set to 0x%02x\0A\00"
@.str.5 = [48 x i8] c"ERROR: bus number not set prior to operation.\0A\0A\00"
@.str.6 = [34 x i8] c"ERROR: invalid bus number `%s'.\0A\0A\00"
@.str.7 = [28 x i8] c"Local Temperature: %.2lf C\0A\00"
@.str.8 = [61 x i8] c"Remote Temperature 1: %.2lf C\0ARemote Temperature 2: %.2lf C\0A\00"
@.str.9 = [35 x i8] c"BUG: switch fall-through on `%c'!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @print_help(i8* %8)
br label %161
10: ; preds = %2
store i64 0, i64* @opterr
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %3 to i8*
br label %14
14: ; preds = %101, %10
%15 = phi i32 [ %94, %101 ], [ -1, %10 ]
%16 = phi i32 [ %22, %101 ], [ 90, %10 ]
%17 = icmp slt i32 %15, 0
%18 = icmp slt i32 %15, 0
%19 = icmp slt i32 %15, 0
%20 = icmp slt i32 %15, 0
br label %21
21: ; preds = %14, %61
%22 = phi i32 [ %16, %14 ], [ %35, %61 ]
br label %23
23: ; preds = %146, %21
%24 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %24, label %153 [
i32 -1, label %157
i32 97, label %25
i32 65, label %64
i32 98, label %77
i32 108, label %104
i32 111, label %122
i32 63, label %147
]
25: ; preds = %23
br i1 %20, label %26, label %33
26: ; preds = %25
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %1
%30 = call i32 @print_help(i8* %29)
%31 = load i32, i32* @EINVAL
%32 = sub nsw i32 0, %31
br label %161
33: ; preds = %25
%34 = load i8*, i8** @optarg
%35 = call i32 @read_int(i8* %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %33
%38 = load i32, i32* @stderr
%39 = load i8*, i8** @optarg
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %1
%42 = call i32 @print_help(i8* %41)
%43 = load i32, i32* @EINVAL
%44 = sub nsw i32 0, %43
br label %161
45: ; preds = %33
%46 = add nsw i32 %35, -128
%47 = icmp ult i32 %46, -125
br i1 %47, label %48, label %56
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = load i8*, i8** @optarg
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %50)
%52 = load i8*, i8** %1
%53 = call i32 @print_help(i8* %52)
%54 = load i32, i32* @EINVAL
%55 = sub nsw i32 0, %54
br label %161
56: ; preds = %45
%57 = call i32 @i2c_select(i32 %15, i32 %35)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @close(i32 %15)
br label %161
61: ; preds = %56
%62 = load i32, i32* @stdout
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %21
64: ; preds = %23
br i1 %19, label %65, label %72
65: ; preds = %64
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%68 = load i8*, i8** %1
%69 = call i32 @print_help(i8* %68)
%70 = load i32, i32* @EINVAL
%71 = sub nsw i32 0, %70
br label %161
72: ; preds = %64
%73 = call i32 @mlx90614_print_all(i32 %15)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %146
75: ; preds = %72
%76 = call i32 @close(i32 %15)
br label %161
77: ; preds = %23
%78 = icmp sgt i32 %15, -1
br i1 %78, label %79, label %81
79: ; preds = %77
%80 = call i32 @close(i32 %15)
br label %81
81: ; preds = %79, %77
%82 = load i8*, i8** @optarg
%83 = call i32 @read_int(i8* %82)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %93
85: ; preds = %81
%86 = load i32, i32* @stderr
%87 = load i8*, i8** @optarg
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %87)
%89 = load i8*, i8** %1
%90 = call i32 @print_help(i8* %89)
%91 = load i32, i32* @EINVAL
%92 = sub nsw i32 0, %91
br label %161
93: ; preds = %81
%94 = call i32 @i2c_open(i32 %83)
%95 = icmp slt i32 %94, 0
br i1 %95, label %161, label %96
96: ; preds = %93
%97 = call i32 @i2c_select(i32 %94, i32 %22)
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = call i32 @close(i32 %94)
br label %161
101: ; preds = %96
%102 = load i32, i32* @stdout
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %14
104: ; preds = %23
br i1 %18, label %105, label %112
105: ; preds = %104
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%108 = load i8*, i8** %1
%109 = call i32 @print_help(i8* %108)
%110 = load i32, i32* @EINVAL
%111 = sub nsw i32 0, %110
br label %161
112: ; preds = %104
%113 = call i32 @i2c_read_word(i32 %15, i32 6, i32* %3)
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %112
%116 = call i32 @close(i32 %15)
br label %161
117: ; preds = %112
%118 = load i32, i32* @stdout
%119 = load i32, i32* %3
%120 = call i32 @mlx90614_reg_to_temp(i32 %119)
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %120)
br label %146
122: ; preds = %23
br i1 %17, label %123, label %130
123: ; preds = %122
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%126 = load i8*, i8** %1
%127 = call i32 @print_help(i8* %126)
%128 = load i32, i32* @EINVAL
%129 = sub nsw i32 0, %128
br label %161
130: ; preds = %122
%131 = call i32 @i2c_read_word(i32 %15, i32 7, i32* %4)
%132 = icmp slt i32 %131, 0
br i1 %132, label %136, label %133
133: ; preds = %130
%134 = call i32 @i2c_read_word(i32 %15, i32 8, i32* %5)
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %139
136: ; preds = %133, %130
%137 = phi i32 [ %131, %130 ], [ %134, %133 ]
%138 = call i32 @close(i32 %15)
br label %161
139: ; preds = %133
%140 = load i32, i32* @stdout
%141 = load i32, i32* %4
%142 = call i32 @mlx90614_reg_to_temp(i32 %141)
%143 = load i32, i32* %5
%144 = call i32 @mlx90614_reg_to_temp(i32 %143)
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %142, i32 %144)
br label %146
146: ; preds = %139, %117, %72
br label %23
147: ; preds = %23
%148 = call i32 (...) @handle_bad_opts()
%149 = load i8*, i8** %1
%150 = call i32 @print_help(i8* %149)
%151 = load i32, i32* @EINVAL
%152 = sub nsw i32 0, %151
br label %161
153: ; preds = %23
%154 = load i32, i32* @stderr
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %24)
%156 = call i32 (...) @abort()
unreachable
157: ; preds = %23
%158 = icmp sgt i32 %15, -1
br i1 %158, label %159, label %161
159: ; preds = %157
%160 = call i32 @close(i32 %15)
br label %161
161: ; preds = %93, %85, %99, %136, %115, %26, %37, %48, %59, %65, %75, %105, %123, %147, %159, %157, %7
%162 = phi i32 [ 0, %7 ], [ %152, %147 ], [ %129, %123 ], [ %111, %105 ], [ %71, %65 ], [ %73, %75 ], [ %32, %26 ], [ %44, %37 ], [ %55, %48 ], [ %57, %59 ], [ 0, %159 ], [ 0, %157 ], [ %113, %115 ], [ %137, %136 ], [ %92, %85 ], [ %97, %99 ], [ %94, %93 ]
ret i32 %162
}