#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ usage_index;
  scalar_t__ field_index;
  void *report_id;
  void *report_type;
};
struct hiddev_usage_ref_multi {
  float num_applications;
  int busnum;
  int devnum;
  int ifnum;
  int index;
  char *value;
  int num_fields;
  size_t num_values;
  unsigned char *values;
  TYPE_1__ uref;
  void *report_id;
  void *report_type;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ product;
  int /*<<< orphan*/ vendor;
};
struct hiddev_string_descriptor {
  float num_applications;
  int busnum;
  int devnum;
  int ifnum;
  int index;
  char *value;
  int num_fields;
  size_t num_values;
  unsigned char *values;
  TYPE_1__ uref;
  void *report_id;
  void *report_type;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ product;
  int /*<<< orphan*/ vendor;
};
struct hiddev_report_info {
  float num_applications;
  int busnum;
  int devnum;
  int ifnum;
  int index;
  char *value;
  int num_fields;
  size_t num_values;
  unsigned char *values;
  TYPE_1__ uref;
  void *report_id;
  void *report_type;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ product;
  int /*<<< orphan*/ vendor;
};
struct hiddev_devinfo {
  float num_applications;
  int busnum;
  int devnum;
  int ifnum;
  int index;
  char *value;
  int num_fields;
  size_t num_values;
  unsigned char *values;
  TYPE_1__ uref;
  void *report_id;
  void *report_type;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ product;
  int /*<<< orphan*/ vendor;
};

/* Variables and functions */
int /*<<< orphan*/ HIDIOCGDEVINFO;
int /*<<< orphan*/ HIDIOCGREPORT;
int /*<<< orphan*/ HIDIOCGSTRING;
int /*<<< orphan*/ HIDIOCGUSAGES;
void *HID_REPORT_ID_FIRST;
void *HID_REPORT_TYPE_FEATURE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
unsigned char crc8(unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int ioctl(int, int /*<<< orphan*/, struct hiddev_usage_ref_multi *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(void) {
  int fd, rc;
  if ((fd = open("/dev/usb/hiddev0", O_RDONLY)) <= 0) {
    perror("open");
    return 1;
  }
  struct hiddev_devinfo device_info;
  rc = ioctl(fd, HIDIOCGDEVINFO, &device_info);
  if (rc < 0) {
    perror("ioctl");
    do {
      close(fd);
      return 1;
    } while (0);
    ;
  }
  printf("VID: 0x%04hX  PID: 0x%04hX  version: 0x%04hX\n", device_info.vendor,
         device_info.product, device_info.version);
  printf("Applications: %i\n", device_info.num_applications);
  printf("Bus: %d Devnum: %d Ifnum: %d\n", device_info.busnum,
         device_info.devnum, device_info.ifnum);
  struct hiddev_string_descriptor hstring_man, hstring_prod;
  hstring_man.index = 1;
  hstring_man.value[0] = 0;
  hstring_prod.index = 2;
  hstring_prod.value[0] = 0;
  rc = ioctl(fd, HIDIOCGSTRING, &hstring_man);
  if (rc < 0) {
    perror("ioctl");
    do {
      close(fd);
      return 1;
    } while (0);
    ;
  }
  rc = ioctl(fd, HIDIOCGSTRING, &hstring_prod);
  if (rc < 0) {
    perror("ioctl");
    do {
      close(fd);
      return 1;
    } while (0);
    ;
  }
  printf("Manufacturer: %s\nProduct: %s\n", hstring_man.value,
         hstring_prod.value);
  if (strcmp(hstring_man.value, "usb@6bez10.info") != 0 ||
      strcmp(hstring_prod.value, "DS18B20 v1") != 0) {
    fprintf(stderr, "Your device is not supported by this software\n");
    do {
      close(fd);
      return 1;
    } while (0);
    ;
  }
  size_t n = 9;
  unsigned char report[9];
  unsigned char crc;
  struct hiddev_report_info rep_info_i;
  struct hiddev_usage_ref_multi ref_multi_i;
  rep_info_i.report_type = HID_REPORT_TYPE_FEATURE;
  rep_info_i.report_id = HID_REPORT_ID_FIRST;
  rep_info_i.num_fields = 1;
  ref_multi_i.uref.report_type = HID_REPORT_TYPE_FEATURE;
  ref_multi_i.uref.report_id = HID_REPORT_ID_FIRST;
  ref_multi_i.uref.field_index = 0;
  ref_multi_i.uref.usage_index = 0;
  ref_multi_i.num_values = n;
  size_t i;
  short temp;
  while (1) {
    rc = ioctl(fd, HIDIOCGREPORT, &rep_info_i);
    if (rc < 0) {
      perror("ioctl");
      do {
        close(fd);
        return 1;
      } while (0);
      ;
    }
    rc = ioctl(fd, HIDIOCGUSAGES, &ref_multi_i);
    if (rc < 0) {
      perror("ioctl");
      do {
        close(fd);
        return 1;
      } while (0);
      ;
    }
    for (i = 0; i < n; ++i) {
      printf("%02X ", report[i] = ref_multi_i.values[i]);
    }
    crc = crc8(report, 9);
    printf("(CRC %s)\n", (crc == 0) ? "OK" : "ERROR");
    if (crc) {
      do {
        close(fd);
        return 1;
      } while (0);
      ;
    }
    temp = ((short)report[1] << 8) | report[0];
    printf("Temperature: %.04f*C\n", (float)temp / 16);
    sleep(1);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    0xe52(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jg     11db <main+0x4b>
lea    0xe4b(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
mov    -0x8(%rbp),%edi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
lea    -0x88(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1220 <main+0x90>
lea    0xe13(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x84(%rbp),%esi
mov    -0x80(%rbp),%edx
mov    -0x7c(%rbp),%ecx
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xf0(%rbp)
mov    -0xe8(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x2,-0x168(%rbp)
mov    -0x160(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
lea    -0x100(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    12d8 <main+0x148>
lea    0xd5b(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
mov    -0x8(%rbp),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
lea    -0x178(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    131d <main+0x18d>
lea    0xd16(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
mov    -0xe8(%rbp),%rsi
mov    -0x160(%rbp),%rdx
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%rdi
lea    0xd55(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1373 <main+0x1e3>
mov    -0x160(%rbp),%rdi
lea    0xd48(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     139c <main+0x20c>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
movq   $0x9,-0x180(%rbp)
mov    0x2c1a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1a8(%rbp)
mov    0x2c01(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1b0(%rbp)
movl   $0x1,-0x1e8(%rbp)
mov    0x2bee(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x230(%rbp)
mov    0x2bd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x238(%rbp)
movq   $0x0,-0x240(%rbp)
movq   $0x0,-0x248(%rbp)
mov    -0x180(%rbp),%rax
mov    %rax,-0x258(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bb5(%rip),%rax
mov    (%rax),%esi
lea    -0x208(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    145e <main+0x2ce>
lea    0xbd5(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
mov    -0x8(%rbp),%edi
mov    0x2b78(%rip),%rax
mov    (%rax),%esi
lea    -0x280(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    14a3 <main+0x313>
lea    0xb90(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
movq   $0x0,-0x288(%rbp)
mov    -0x288(%rbp),%rax
cmp    -0x180(%rbp),%rax
jae    1509 <main+0x379>
mov    -0x250(%rbp),%rax
mov    -0x288(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x288(%rbp),%rcx
mov    %al,-0x189(%rbp,%rcx,1)
movzbl %al,%esi
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x288(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x288(%rbp)
jmp    14ae <main+0x31e>
lea    -0x189(%rbp),%rdi
mov    $0x9,%esi
call   1080 <crc8@plt>
mov    %al,-0x18a(%rbp)
movzbl -0x18a(%rbp),%ecx
lea    0xbcb(%rip),%rsi
lea    0xbc1(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xba9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpb   $0x0,-0x18a(%rbp)
je     1570 <main+0x3e0>
jmp    155c <main+0x3cc>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c2 <main+0x432>
movzbl -0x188(%rbp),%eax
shl    $0x8,%eax
movzbl -0x189(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x28a(%rbp)
movswl -0x28a(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  0xa63(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb53(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
jmp    1419 <main+0x289>
mov    -0x4(%rbp),%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xe98(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
jg     117f <main+0x2f>
lea    0xe99(%rip),%rdi
call   1070 <perror@plt>
jmp    11ad <main+0x5d>
mov    %eax,%ebx
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1040 <ioctl@plt>
test   %eax,%eax
jns    11bb <main+0x6b>
lea    0xe75(%rip),%rdi
call   1070 <perror@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
ret
mov    0x78(%rsp),%esi
mov    0x70(%rsp),%ecx
mov    0x74(%rsp),%edx
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe64(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>

LLVM IR (-O0):
%struct.hiddev_devinfo = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
%struct.TYPE_2__ = type { i64, i64, i8*, i8* }
%struct.hiddev_string_descriptor = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
%struct.hiddev_report_info = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
%struct.hiddev_usage_ref_multi = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
@.str = [17 x i8] c"/dev/usb/hiddev0\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@HIDIOCGDEVINFO = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@.str.3 = [46 x i8] c"VID: 0x%04hX PID: 0x%04hX version: 0x%04hX\0A\00"
@.str.4 = [18 x i8] c"Applications: %i\0A\00"
@.str.5 = [30 x i8] c"Bus: %d Devnum: %d Ifnum: %d\0A\00"
@HIDIOCGSTRING = global i32 0
@.str.6 = [30 x i8] c"Manufacturer: %s\0AProduct: %s\0A\00"
@.str.7 = [16 x i8] c"usb@6bez10.info\00"
@.str.8 = [11 x i8] c"DS18B20 v1\00"
@stderr = global i32 0
@.str.9 = [47 x i8] c"Your device is not supported by this software\0A\00"
@HID_REPORT_TYPE_FEATURE = global i8* null
@HID_REPORT_ID_FIRST = global i8* null
@HIDIOCGREPORT = global i32 0
@HIDIOCGUSAGES = global i32 0
@.str.10 = [6 x i8] c"%02X \00"
@.str.11 = [10 x i8] c"(CRC %s)\0A\00"
@.str.12 = [3 x i8] c"OK\00"
@.str.13 = [6 x i8] c"ERROR\00"
@.str.14 = [22 x i8] c"Temperature: %.04f*C\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.hiddev_devinfo
%5 = alloca %struct.hiddev_string_descriptor
%6 = alloca %struct.hiddev_string_descriptor
%7 = alloca i64
%8 = alloca [9 x i8]
%9 = alloca i8
%10 = alloca %struct.hiddev_report_info
%11 = alloca %struct.hiddev_usage_ref_multi
%12 = alloca i64
%13 = alloca i16
store i32 0, i32* %1
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 %15, i32* %2
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %200
19: ; preds = %0
%20 = load i32, i32* %2
%21 = load i32, i32* @HIDIOCGDEVINFO
%22 = bitcast %struct.hiddev_devinfo* %4 to %struct.hiddev_usage_ref_multi*
%23 = call i32 @ioctl(i32 %20, i32 %21, %struct.hiddev_usage_ref_multi* %22)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %2
%30 = call i32 @close(i32 %29)
store i32 1, i32* %1
br label %200
31: ; No predecessors!
br label %32
32: ; preds = %31, %19
%33 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 14
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 13
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 12
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %36, i32 %38)
%40 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 0
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %42)
%44 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 1
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 2
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %4, i32 0, i32 3
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 %47, i32 %49)
%51 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %5, i32 0, i32 4
store i32 1, i32* %51
%52 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %5, i32 0, i32 5
%53 = load i8*, i8** %52
%54 = getelementptr inbounds i8, i8* %53, i64 0
store i8 0, i8* %54
%55 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %6, i32 0, i32 4
store i32 2, i32* %55
%56 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %6, i32 0, i32 5
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 0
store i8 0, i8* %58
%59 = load i32, i32* %2
%60 = load i32, i32* @HIDIOCGSTRING
%61 = bitcast %struct.hiddev_string_descriptor* %5 to %struct.hiddev_usage_ref_multi*
%62 = call i32 @ioctl(i32 %59, i32 %60, %struct.hiddev_usage_ref_multi* %61)
store i32 %62, i32* %3
%63 = load i32, i32* %3
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %32
%66 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %67
67: ; preds = %65
%68 = load i32, i32* %2
%69 = call i32 @close(i32 %68)
store i32 1, i32* %1
br label %200
70: ; No predecessors!
br label %71
71: ; preds = %70, %32
%72 = load i32, i32* %2
%73 = load i32, i32* @HIDIOCGSTRING
%74 = bitcast %struct.hiddev_string_descriptor* %6 to %struct.hiddev_usage_ref_multi*
%75 = call i32 @ioctl(i32 %72, i32 %73, %struct.hiddev_usage_ref_multi* %74)
store i32 %75, i32* %3
%76 = load i32, i32* %3
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %71
%79 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %80
80: ; preds = %78
%81 = load i32, i32* %2
%82 = call i32 @close(i32 %81)
store i32 1, i32* %1
br label %200
83: ; No predecessors!
br label %84
84: ; preds = %83, %71
%85 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %5, i32 0, i32 5
%86 = load i8*, i8** %85
%87 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %6, i32 0, i32 5
%88 = load i8*, i8** %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %86, i8* %88)
%90 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %5, i32 0, i32 5
%91 = load i8*, i8** %90
%92 = call i64 @strcmp(i8* %91, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%93 = icmp ne i64 %92, 0
br i1 %93, label %99, label %94
94: ; preds = %84
%95 = getelementptr inbounds %struct.hiddev_string_descriptor, %struct.hiddev_string_descriptor* %6, i32 0, i32 5
%96 = load i8*, i8** %95
%97 = call i64 @strcmp(i8* %96, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %106
99: ; preds = %94, %84
%100 = load i32, i32* @stderr
%101 = call i32 @fprintf(i32 %100, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0))
br label %102
102: ; preds = %99
%103 = load i32, i32* %2
%104 = call i32 @close(i32 %103)
store i32 1, i32* %1
br label %200
105: ; No predecessors!
br label %106
106: ; preds = %105, %94
store i64 9, i64* %7
%107 = load i8*, i8** @HID_REPORT_TYPE_FEATURE
%108 = getelementptr inbounds %struct.hiddev_report_info, %struct.hiddev_report_info* %10, i32 0, i32 11
store i8* %107, i8** %108
%109 = load i8*, i8** @HID_REPORT_ID_FIRST
%110 = getelementptr inbounds %struct.hiddev_report_info, %struct.hiddev_report_info* %10, i32 0, i32 10
store i8* %109, i8** %110
%111 = getelementptr inbounds %struct.hiddev_report_info, %struct.hiddev_report_info* %10, i32 0, i32 6
store i32 1, i32* %111
%112 = load i8*, i8** @HID_REPORT_TYPE_FEATURE
%113 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 9
%114 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %113, i32 0, i32 3
store i8* %112, i8** %114
%115 = load i8*, i8** @HID_REPORT_ID_FIRST
%116 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 9
%117 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %116, i32 0, i32 2
store i8* %115, i8** %117
%118 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 9
%119 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %118, i32 0, i32 1
store i64 0, i64* %119
%120 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 9
%121 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %120, i32 0, i32 0
store i64 0, i64* %121
%122 = load i64, i64* %7
%123 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 7
store i64 %122, i64* %123
br label %124
124: ; preds = %106, %183
%125 = load i32, i32* %2
%126 = load i32, i32* @HIDIOCGREPORT
%127 = bitcast %struct.hiddev_report_info* %10 to %struct.hiddev_usage_ref_multi*
%128 = call i32 @ioctl(i32 %125, i32 %126, %struct.hiddev_usage_ref_multi* %127)
store i32 %128, i32* %3
%129 = load i32, i32* %3
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %137
131: ; preds = %124
%132 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %133
133: ; preds = %131
%134 = load i32, i32* %2
%135 = call i32 @close(i32 %134)
store i32 1, i32* %1
br label %200
136: ; No predecessors!
br label %137
137: ; preds = %136, %124
%138 = load i32, i32* %2
%139 = load i32, i32* @HIDIOCGUSAGES
%140 = call i32 @ioctl(i32 %138, i32 %139, %struct.hiddev_usage_ref_multi* %11)
store i32 %140, i32* %3
%141 = load i32, i32* %3
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %149
143: ; preds = %137
%144 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %145
145: ; preds = %143
%146 = load i32, i32* %2
%147 = call i32 @close(i32 %146)
store i32 1, i32* %1
br label %200
148: ; No predecessors!
br label %149
149: ; preds = %148, %137
store i64 0, i64* %12
br label %150
150: ; preds = %164, %149
%151 = load i64, i64* %12
%152 = load i64, i64* %7
%153 = icmp ult i64 %151, %152
br i1 %153, label %154, label %167
154: ; preds = %150
%155 = getelementptr inbounds %struct.hiddev_usage_ref_multi, %struct.hiddev_usage_ref_multi* %11, i32 0, i32 8
%156 = load i8*, i8** %155
%157 = load i64, i64* %12
%158 = getelementptr inbounds i8, i8* %156, i64 %157
%159 = load i8, i8* %158
%160 = load i64, i64* %12
%161 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 %160
store i8 %159, i8* %161
%162 = zext i8 %159 to i32
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %162)
br label %164
164: ; preds = %154
%165 = load i64, i64* %12
%166 = add i64 %165, 1
store i64 %166, i64* %12
br label %150
167: ; preds = %150
%168 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%169 = call zeroext i8 @crc8(i8* %168, i32 9)
store i8 %169, i8* %9
%170 = load i8, i8* %9
%171 = zext i8 %170 to i32
%172 = icmp eq i32 %171, 0
%173 = zext i1 %172 to i64
%174 = select i1 %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0)
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %174)
%176 = load i8, i8* %9
%177 = icmp ne i8 %176, 0
br i1 %177, label %178, label %183
178: ; preds = %167
br label %179
179: ; preds = %178
%180 = load i32, i32* %2
%181 = call i32 @close(i32 %180)
store i32 1, i32* %1
br label %200
182: ; No predecessors!
br label %183
183: ; preds = %182, %167
%184 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 1
%185 = load i8, i8* %184
%186 = zext i8 %185 to i16
%187 = sext i16 %186 to i32
%188 = shl i32 %187, 8
%189 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%190 = load i8, i8* %189
%191 = zext i8 %190 to i32
%192 = or i32 %188, %191
%193 = trunc i32 %192 to i16
store i16 %193, i16* %13
%194 = load i16, i16* %13
%195 = sitofp i16 %194 to float
%196 = fdiv float %195, 1.600000e+01
%197 = fpext float %196 to double
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), double %197)
%199 = call i32 @sleep(i32 1)
br label %124
200: ; preds = %179, %145, %133, %102, %80, %67, %28, %17
%201 = load i32, i32* %1
ret i32 %201
}

LLVM IR (-O2):
%struct.hiddev_devinfo = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
%struct.TYPE_2__ = type { i64, i64, i8*, i8* }
%struct.hiddev_usage_ref_multi = type { float, i32, i32, i32, i32, i8*, i32, i64, i8*, %struct.TYPE_2__, i8*, i8*, i32, i32, i32 }
@.str = [17 x i8] c"/dev/usb/hiddev0\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@HIDIOCGDEVINFO = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@.str.3 = [46 x i8] c"VID: 0x%04hX PID: 0x%04hX version: 0x%04hX\0A\00"
@.str.4 = [18 x i8] c"Applications: %i\0A\00"
@.str.5 = [30 x i8] c"Bus: %d Devnum: %d Ifnum: %d\0A\00"
@HIDIOCGSTRING = global i32 0
@stderr = global i32 0
@HID_REPORT_TYPE_FEATURE = global i8* null
@HID_REPORT_ID_FIRST = global i8* null
@HIDIOCGREPORT = global i32 0
@HIDIOCGUSAGES = global i32 0
define i32 @main() {
%1 = alloca %struct.hiddev_devinfo
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %35
7: ; preds = %0
%8 = bitcast %struct.hiddev_devinfo* %1 to i8*
%9 = load i32, i32* @HIDIOCGDEVINFO
%10 = bitcast %struct.hiddev_devinfo* %1 to %struct.hiddev_usage_ref_multi*
%11 = call i32 @ioctl(i32 %3, i32 %9, %struct.hiddev_usage_ref_multi* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @close(i32 %3)
br label %35
16: ; preds = %7
%17 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 14
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 13
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 12
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %20, i32 %22)
%24 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 0
%25 = load float, float* %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %26)
%28 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 2
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.hiddev_devinfo, %struct.hiddev_devinfo* %1, i64 0, i32 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %31, i32 %33)
unreachable
35: ; preds = %13, %5
ret i32 1
}