#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;
typedef int /*<<< orphan*/ int16_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);
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ print_help(char *);
int read_int(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int tmp007_print_all(int);
double tmp007_reg_to_temp(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int file = -1;
  int res;
  if (argc < 2) {
    print_help(argv[0]);
    return 0;
  }
  int c;
  int ad = (0x40);
  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 = tmp007_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;
      }
      int16_t tdie;
      if ((res = i2c_read_word(file, (0x01), (uint16_t *)&tdie)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout, "Local Temperature: %.2f C\n", tmp007_reg_to_temp(tdie));
      break;
    }
    case 'o': {
      if (file < 0) {
        fprintf(stderr, "ERROR: bus number not set prior to operation.\n\n");
        print_help(argv[0]);
        return -EINVAL;
      }
      int16_t tobj;
      if ((res = i2c_read_word(file, (0x03), (uint16_t *)&tobj)) < 0) {
        close(file);
        return res;
      }
      fprintf(stdout, "Remote Temperature: %.2f C\n", tmp007_reg_to_temp(tobj));
      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    $0x40,%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   10c0 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    1675 <main+0x4b5>
movl   $0x40,-0x20(%rbp)
mov    0x2dc3(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     165c <main+0x49c>
mov    -0x1c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x30,%eax
ja     1636 <main+0x476>
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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2d36(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x2d55(%rip),%rax
mov    (%rax),%rdi
call   1090 <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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2cdb(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2c87(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
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   1060 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1657 <main+0x497>
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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2bfe(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    -0x14(%rbp),%edi
call   1070 <tmp007_print_all@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13fb <main+0x23b>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
jmp    1657 <main+0x497>
cmpl   $0x0,-0x14(%rbp)
jl     1419 <main+0x259>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    0x2bd8(%rip),%rax
mov    (%rax),%rdi
call   1090 <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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2b5e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    -0x24(%rbp),%edi
call   1050 <i2c_open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1493 <main+0x2d3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
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   1060 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xca3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1657 <main+0x497>
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   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2ab6(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
lea    -0x28(%rbp),%rdx
call   10a0 <i2c_read_word@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    154c <main+0x38c>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x2a6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%edi
call   10d0 <tmp007_reg_to_temp@plt>
mov    -0x3c(%rbp),%edi
lea    0xc72(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
jmp    1657 <main+0x497>
cmpl   $0x0,-0x14(%rbp)
jge    15b6 <main+0x3f6>
mov    0x2a51(%rip),%rax
mov    (%rax),%edi
lea    0xbfa(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x2a1c(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
lea    -0x2c(%rbp),%rdx
call   10a0 <i2c_read_word@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    15e6 <main+0x426>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x29d3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
call   10d0 <tmp007_reg_to_temp@plt>
mov    -0x40(%rbp),%edi
lea    0xbf3(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
jmp    1657 <main+0x497>
mov    $0x0,%al
call   1040 <handle_bad_opts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <print_help@plt>
xor    %eax,%eax
mov    0x299c(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1675 <main+0x4b5>
mov    0x299b(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xbca(%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     166e <main+0x4ae>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%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   10c0 <print_help@plt>
xor    %ebx,%ebx
jmp    13e2 <main+0x222>
mov    %edi,%r15d
mov    0x2de1(%rip),%rax
movq   $0x0,(%rax)
mov    $0x40,%eax
mov    %rax,0x8(%rsp)
mov    $0xffffffff,%ebp
lea    0xeb8(%rip),%r12
lea    0xded(%rip),%r13
jmp    1242 <main+0x82>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2d99(%rip),%rax
mov    (%rax),%ebx
mov    0x14(%rsp),%edi
call   10d0 <tmp007_reg_to_temp@plt>
mov    %ebx,%edi
lea    0xfa1(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   10b0 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x30,%ecx
ja     13b7 <main+0x1f7>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
test   %ebp,%ebp
js     1391 <main+0x1d1>
mov    %ebp,%edi
call   1070 <tmp007_print_all@plt>
test   %eax,%eax
jns    1242 <main+0x82>
jmp    13ac <main+0x1ec>
xchg   %ax,%ax
test   %ebp,%ebp
js     1391 <main+0x1d1>
mov    %ebp,%edi
mov    $0x1,%esi
lea    0x14(%rsp),%rdx
call   10a0 <i2c_read_word@plt>
test   %eax,%eax
jns    1220 <main+0x60>
jmp    13ac <main+0x1ec>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebp,%ebp
js     1391 <main+0x1d1>
mov    %ebp,%edi
mov    $0x3,%esi
lea    0x10(%rsp),%rdx
call   10a0 <i2c_read_word@plt>
test   %eax,%eax
js     13ac <main+0x1ec>
mov    0x2ce8(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%edi
call   10d0 <tmp007_reg_to_temp@plt>
mov    %ebx,%edi
lea    0xf0b(%rip),%rsi
jmp    123b <main+0x7b>
test   %ebp,%ebp
js     13f3 <main+0x233>
mov    0x2cf8(%rip),%rax
mov    (%rax),%rdi
call   1090 <read_int@plt>
test   %eax,%eax
js     1421 <main+0x261>
lea    -0x80(%rax),%ecx
cmp    $0xffffff82,%ecx
jbe    1441 <main+0x281>
mov    %ebp,%edi
mov    %rax,%rsi
mov    %rax,0x8(%rsp)
jmp    1367 <main+0x1a7>
test   %ebp,%ebp
js     1333 <main+0x173>
mov    %ebp,%edi
call   1060 <close@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%rdi
call   1090 <read_int@plt>
test   %eax,%eax
js     1405 <main+0x245>
mov    %eax,%edi
call   1050 <i2c_open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     143d <main+0x27d>
mov    %ebp,%edi
mov    0x8(%rsp),%rsi
mov    %rsi,0x8(%rsp)
call   10e0 <i2c_select@plt>
test   %eax,%eax
js     13ac <main+0x1ec>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1242 <main+0x82>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13d1 <main+0x211>
mov    %eax,%ebx
mov    %ebp,%edi
call   1060 <close@plt>
jmp    13e2 <main+0x222>
cmp    $0xffffffff,%eax
jne    1469 <main+0x2a9>
xor    %ebx,%ebx
test   %ebp,%ebp
jns    13ae <main+0x1ee>
jmp    13e2 <main+0x222>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <handle_bad_opts@plt>
mov    (%r14),%rdi
call   10c0 <print_help@plt>
mov    0x2be8(%rip),%rax
sub    (%rax),%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
jmp    13a1 <main+0x1e1>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
mov    0x2be3(%rip),%rax
mov    (%rax),%rdx
lea    0xd9b(%rip),%rsi
jmp    145b <main+0x29b>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
mov    0x2bc7(%rip),%rax
mov    (%rax),%rdx
lea    0xcc9(%rip),%rsi
jmp    145b <main+0x29b>
mov    %ebp,%ebx
jmp    13e2 <main+0x222>
mov    0x2b90(%rip),%rax
mov    (%rax),%edi
mov    0x2ba7(%rip),%rax
mov    (%rax),%rdx
lea    0xcce(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13d1 <main+0x211>
mov    0x2b68(%rip),%rcx
mov    (%rcx),%edi
lea    0xd9a(%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 = [27 x i8] c"Local Temperature: %.2f C\0A\00"
@.str.8 = [28 x i8] c"Remote Temperature: %.2f 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @print_help(i8* %18)
store i32 0, i32* %3
br label %214
20: ; preds = %2
store i32 64, i32* %9
store i64 0, i64* @opterr
br label %21
21: ; preds = %206, %20
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %24, i32* %8
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %207
26: ; preds = %21
%27 = load i32, i32* %8
switch i32 %27, label %201 [
i32 97, label %28
i32 65, label %83
i32 98, label %104
i32 108, label %143
i32 111, label %168
i32 63, label %193
]
28: ; preds = %26
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @print_help(i8* %36)
%38 = load i32, i32* @EINVAL
%39 = sub nsw i32 0, %38
store i32 %39, i32* %3
br label %214
40: ; preds = %28
%41 = load i8*, i8** @optarg
%42 = call i32 @read_int(i8* %41)
store i32 %42, i32* %9
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = load i8*, i8** @optarg
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = call i32 @print_help(i8* %50)
%52 = load i32, i32* @EINVAL
%53 = sub nsw i32 0, %52
store i32 %53, i32* %3
br label %214
54: ; preds = %40
%55 = load i32, i32* %9
%56 = icmp slt i32 %55, 3
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* %9
%59 = icmp sgt i32 %58, 127
br i1 %59, label %60, label %70
60: ; preds = %57, %54
%61 = load i32, i32* @stderr
%62 = load i8*, i8** @optarg
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 0
%66 = load i8*, i8** %65
%67 = call i32 @print_help(i8* %66)
%68 = load i32, i32* @EINVAL
%69 = sub nsw i32 0, %68
store i32 %69, i32* %3
br label %214
70: ; preds = %57
%71 = load i32, i32* %6
%72 = load i32, i32* %9
%73 = call i32 @i2c_select(i32 %71, i32 %72)
store i32 %73, i32* %7
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %70
%76 = load i32, i32* %6
%77 = call i32 @close(i32 %76)
%78 = load i32, i32* %7
store i32 %78, i32* %3
br label %214
79: ; preds = %70
%80 = load i32, i32* @stdout
%81 = load i32, i32* %9
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %81)
br label %206
83: ; preds = %26
%84 = load i32, i32* %6
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %83
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 0
%91 = load i8*, i8** %90
%92 = call i32 @print_help(i8* %91)
%93 = load i32, i32* @EINVAL
%94 = sub nsw i32 0, %93
store i32 %94, i32* %3
br label %214
95: ; preds = %83
%96 = load i32, i32* %6
%97 = call i32 @tmp007_print_all(i32 %96)
store i32 %97, i32* %7
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %95
%100 = load i32, i32* %6
%101 = call i32 @close(i32 %100)
%102 = load i32, i32* %7
store i32 %102, i32* %3
br label %214
103: ; preds = %95
br label %206
104: ; preds = %26
%105 = load i32, i32* %6
%106 = icmp sge i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %104
%108 = load i32, i32* %6
%109 = call i32 @close(i32 %108)
store i32 -1, i32* %6
br label %110
110: ; preds = %107, %104
%111 = load i8*, i8** @optarg
%112 = call i32 @read_int(i8* %111)
store i32 %112, i32* %10
%113 = icmp slt i32 %112, 0
br i1 %113, label %114, label %124
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = load i8*, i8** @optarg
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %116)
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 0
%120 = load i8*, i8** %119
%121 = call i32 @print_help(i8* %120)
%122 = load i32, i32* @EINVAL
%123 = sub nsw i32 0, %122
store i32 %123, i32* %3
br label %214
124: ; preds = %110
%125 = load i32, i32* %10
%126 = call i32 @i2c_open(i32 %125)
store i32 %126, i32* %6
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %130
128: ; preds = %124
%129 = load i32, i32* %6
store i32 %129, i32* %3
br label %214
130: ; preds = %124
%131 = load i32, i32* %6
%132 = load i32, i32* %9
%133 = call i32 @i2c_select(i32 %131, i32 %132)
store i32 %133, i32* %7
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %139
135: ; preds = %130
%136 = load i32, i32* %6
%137 = call i32 @close(i32 %136)
%138 = load i32, i32* %7
store i32 %138, i32* %3
br label %214
139: ; preds = %130
%140 = load i32, i32* @stdout
%141 = load i32, i32* %9
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %141)
br label %206
143: ; preds = %26
%144 = load i32, i32* %6
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %155
146: ; preds = %143
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%149 = load i8**, i8*** %5
%150 = getelementptr inbounds i8*, i8** %149, i64 0
%151 = load i8*, i8** %150
%152 = call i32 @print_help(i8* %151)
%153 = load i32, i32* @EINVAL
%154 = sub nsw i32 0, %153
store i32 %154, i32* %3
br label %214
155: ; preds = %143
%156 = load i32, i32* %6
%157 = call i32 @i2c_read_word(i32 %156, i32 1, i32* %11)
store i32 %157, i32* %7
%158 = icmp slt i32 %157, 0
br i1 %158, label %159, label %163
159: ; preds = %155
%160 = load i32, i32* %6
%161 = call i32 @close(i32 %160)
%162 = load i32, i32* %7
store i32 %162, i32* %3
br label %214
163: ; preds = %155
%164 = load i32, i32* @stdout
%165 = load i32, i32* %11
%166 = call double @tmp007_reg_to_temp(i32 %165)
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %166)
br label %206
168: ; preds = %26
%169 = load i32, i32* %6
%170 = icmp slt i32 %169, 0
br i1 %170, label %171, label %180
171: ; preds = %168
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%174 = load i8**, i8*** %5
%175 = getelementptr inbounds i8*, i8** %174, i64 0
%176 = load i8*, i8** %175
%177 = call i32 @print_help(i8* %176)
%178 = load i32, i32* @EINVAL
%179 = sub nsw i32 0, %178
store i32 %179, i32* %3
br label %214
180: ; preds = %168
%181 = load i32, i32* %6
%182 = call i32 @i2c_read_word(i32 %181, i32 3, i32* %12)
store i32 %182, i32* %7
%183 = icmp slt i32 %182, 0
br i1 %183, label %184, label %188
184: ; preds = %180
%185 = load i32, i32* %6
%186 = call i32 @close(i32 %185)
%187 = load i32, i32* %7
store i32 %187, i32* %3
br label %214
188: ; preds = %180
%189 = load i32, i32* @stdout
%190 = load i32, i32* %12
%191 = call double @tmp007_reg_to_temp(i32 %190)
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), double %191)
br label %206
193: ; preds = %26
%194 = call i32 (...) @handle_bad_opts()
%195 = load i8**, i8*** %5
%196 = getelementptr inbounds i8*, i8** %195, i64 0
%197 = load i8*, i8** %196
%198 = call i32 @print_help(i8* %197)
%199 = load i32, i32* @EINVAL
%200 = sub nsw i32 0, %199
store i32 %200, i32* %3
br label %214
201: ; preds = %26
%202 = load i32, i32* @stderr
%203 = load i32, i32* %8
%204 = call i32 (i32, i8*, ...) @fprintf(i32 %202, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %203)
%205 = call i32 (...) @abort()
unreachable
206: ; preds = %188, %163, %139, %103, %79
br label %21
207: ; preds = %21
%208 = load i32, i32* %6
%209 = icmp sge i32 %208, 0
br i1 %209, label %210, label %213
210: ; preds = %207
%211 = load i32, i32* %6
%212 = call i32 @close(i32 %211)
br label %213
213: ; preds = %210, %207
store i32 0, i32* %3
br label %214
214: ; preds = %213, %193, %184, %171, %159, %146, %135, %128, %114, %99, %86, %75, %60, %44, %31, %15
%215 = load i32, i32* %3
ret i32 %215
}

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 = [27 x i8] c"Local Temperature: %.2f C\0A\00"
@.str.8 = [28 x i8] c"Remote Temperature: %.2f 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 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @print_help(i8* %7)
br label %153
9: ; preds = %2
store i64 0, i64* @opterr
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %3 to i8*
br label %12
12: ; preds = %99, %9
%13 = phi i32 [ %92, %99 ], [ -1, %9 ]
%14 = phi i32 [ %20, %99 ], [ 64, %9 ]
%15 = icmp slt i32 %13, 0
%16 = icmp slt i32 %13, 0
%17 = icmp slt i32 %13, 0
%18 = icmp slt i32 %13, 0
br label %19
19: ; preds = %12, %59
%20 = phi i32 [ %14, %12 ], [ %33, %59 ]
br label %21
21: ; preds = %138, %19
%22 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %22, label %145 [
i32 -1, label %149
i32 97, label %23
i32 65, label %62
i32 98, label %75
i32 108, label %102
i32 111, label %120
i32 63, label %139
]
23: ; preds = %21
br i1 %18, label %24, label %31
24: ; preds = %23
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %1
%28 = call i32 @print_help(i8* %27)
%29 = load i32, i32* @EINVAL
%30 = sub nsw i32 0, %29
br label %153
31: ; preds = %23
%32 = load i8*, i8** @optarg
%33 = call i32 @read_int(i8* %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = load i8*, i8** @optarg
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %1
%40 = call i32 @print_help(i8* %39)
%41 = load i32, i32* @EINVAL
%42 = sub nsw i32 0, %41
br label %153
43: ; preds = %31
%44 = add nsw i32 %33, -128
%45 = icmp ult i32 %44, -125
br i1 %45, label %46, label %54
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = load i8*, i8** @optarg
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %1
%51 = call i32 @print_help(i8* %50)
%52 = load i32, i32* @EINVAL
%53 = sub nsw i32 0, %52
br label %153
54: ; preds = %43
%55 = call i32 @i2c_select(i32 %13, i32 %33)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @close(i32 %13)
br label %153
59: ; preds = %54
%60 = load i32, i32* @stdout
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %19
62: ; preds = %21
br i1 %17, label %63, label %70
63: ; preds = %62
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%66 = load i8*, i8** %1
%67 = call i32 @print_help(i8* %66)
%68 = load i32, i32* @EINVAL
%69 = sub nsw i32 0, %68
br label %153
70: ; preds = %62
%71 = call i32 @tmp007_print_all(i32 %13)
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %138
73: ; preds = %70
%74 = call i32 @close(i32 %13)
br label %153
75: ; preds = %21
%76 = icmp sgt i32 %13, -1
br i1 %76, label %77, label %79
77: ; preds = %75
%78 = call i32 @close(i32 %13)
br label %79
79: ; preds = %77, %75
%80 = load i8*, i8** @optarg
%81 = call i32 @read_int(i8* %80)
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %91
83: ; preds = %79
%84 = load i32, i32* @stderr
%85 = load i8*, i8** @optarg
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %85)
%87 = load i8*, i8** %1
%88 = call i32 @print_help(i8* %87)
%89 = load i32, i32* @EINVAL
%90 = sub nsw i32 0, %89
br label %153
91: ; preds = %79
%92 = call i32 @i2c_open(i32 %81)
%93 = icmp slt i32 %92, 0
br i1 %93, label %153, label %94
94: ; preds = %91
%95 = call i32 @i2c_select(i32 %92, i32 %20)
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %94
%98 = call i32 @close(i32 %92)
br label %153
99: ; preds = %94
%100 = load i32, i32* @stdout
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %12
102: ; preds = %21
br i1 %16, label %103, label %110
103: ; preds = %102
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%106 = load i8*, i8** %1
%107 = call i32 @print_help(i8* %106)
%108 = load i32, i32* @EINVAL
%109 = sub nsw i32 0, %108
br label %153
110: ; preds = %102
%111 = call i32 @i2c_read_word(i32 %13, i32 1, i32* %3)
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %110
%114 = call i32 @close(i32 %13)
br label %153
115: ; preds = %110
%116 = load i32, i32* @stdout
%117 = load i32, i32* %3
%118 = call double @tmp007_reg_to_temp(i32 %117)
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %118)
br label %138
120: ; preds = %21
br i1 %15, label %121, label %128
121: ; preds = %120
%122 = load i32, i32* @stderr
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%124 = load i8*, i8** %1
%125 = call i32 @print_help(i8* %124)
%126 = load i32, i32* @EINVAL
%127 = sub nsw i32 0, %126
br label %153
128: ; preds = %120
%129 = call i32 @i2c_read_word(i32 %13, i32 3, i32* %4)
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = call i32 @close(i32 %13)
br label %153
133: ; preds = %128
%134 = load i32, i32* @stdout
%135 = load i32, i32* %4
%136 = call double @tmp007_reg_to_temp(i32 %135)
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), double %136)
br label %138
138: ; preds = %133, %115, %70
br label %21
139: ; preds = %21
%140 = call i32 (...) @handle_bad_opts()
%141 = load i8*, i8** %1
%142 = call i32 @print_help(i8* %141)
%143 = load i32, i32* @EINVAL
%144 = sub nsw i32 0, %143
br label %153
145: ; preds = %21
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %22)
%148 = call i32 (...) @abort()
unreachable
149: ; preds = %21
%150 = icmp sgt i32 %13, -1
br i1 %150, label %151, label %153
151: ; preds = %149
%152 = call i32 @close(i32 %13)
br label %153
153: ; preds = %91, %83, %97, %131, %113, %24, %35, %46, %57, %63, %73, %103, %121, %139, %151, %149, %6
%154 = phi i32 [ 0, %6 ], [ %144, %139 ], [ %127, %121 ], [ %109, %103 ], [ %69, %63 ], [ %71, %73 ], [ %30, %24 ], [ %42, %35 ], [ %53, %46 ], [ %55, %57 ], [ 0, %151 ], [ 0, %149 ], [ %111, %113 ], [ %129, %131 ], [ %90, %83 ], [ %95, %97 ], [ %92, %91 ]
ret i32 %154
}