#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
float atan2(short, short);
int errno;
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, ...);
int /*<<< orphan*/ selectDevice(int, int, char *);
char *strerror(int);
int /*<<< orphan*/ usleep(int);
int write(int, unsigned char *, int);
int /*<<< orphan*/ writeToDevice(int, int, int, char *);
int main(int argc, char **argv) {
  short adxl345_x, adxl345_y, adxl345_z;
  float adxl345_xa, adxl345_ya, adxl345_za;
  float adxl345_xa_ya, adxl345_xa_za, adxl345_ya_za;
  int adxl345, tmp102, hmc5883l;
  int tmp102_temperature;
  unsigned char adxl345_buf[16];
  char tmp102_buf[1] = {0};
  short hmc5883l_x, hmc5883l_y, hmc5883l_z;
  float hmc5883l_head;
  unsigned char hmc5883l_buf[16];
  int eventcount = 0;
  int screenon = 1;
  if ((hmc5883l = open("/dev/i2c-0", O_RDWR)) < 0) {
    printf("Failed to open i2c bus for tmp102.");
    printf("error: %s (%d)\n", strerror(errno), errno);
    exit(1);
  }
  selectDevice(hmc5883l, 0x1e, "hmc5883l");
  writeToDevice(hmc5883l, 0x00, 0x74, "hmc5883l");
  writeToDevice(hmc5883l, 0x01, 0x20, "hmc5883l");
  writeToDevice(hmc5883l, 0x02, 0x00, "hmc5883l");
  usleep(67000);
  if ((tmp102 = open("/dev/i2c-0", O_RDWR)) < 0) {
    printf("Failed to open i2c bus for tmp102.");
    printf("error: %s (%d)\n", strerror(errno), errno);
    exit(1);
  }
  selectDevice(tmp102, 0x49, "tmp102");
  writeToDevice(tmp102, 0x00, 1, "tmp102");
  if ((adxl345 = open("/dev/i2c-0", O_RDWR)) < 0) {
    printf("Failed to open i2c bus for adxl345\n");
    printf("error: %s (%d)\n", strerror(errno), errno);
    exit(1);
  }
  selectDevice(adxl345, 0x53, "ADXL345");
  writeToDevice(adxl345, 0x2d, 0, "adxl345");
  writeToDevice(adxl345, 0x2d, 16, "adxl345");
  writeToDevice(adxl345, 0x2d, 8, "adxl345");
  writeToDevice(adxl345, 0x2d, 11, "adxl345");
  while (1) {
    selectDevice(adxl345, 0x53, "ADXL345");
    adxl345_buf[0] = 0x32;
    if ((write(adxl345, adxl345_buf, 1)) != 1) {
      printf("Error writing to I2C slave\n");
      printf("error: %s (%d)\n", strerror(errno), errno);
    }
    if (read(adxl345, adxl345_buf, 6) != 6) {
      printf("Unable to read from ADXL345\n");
      printf("error: %s (%d)\n", strerror(errno), errno);
    } else {
      adxl345_x = adxl345_buf[1] << 8 | adxl345_buf[0];
      adxl345_y = adxl345_buf[3] << 8 | adxl345_buf[2];
      adxl345_z = adxl345_buf[5] << 8 | adxl345_buf[4];
      adxl345_xa = (90.0 / 256.0) * (float)adxl345_x;
      adxl345_ya = (90.0 / 256.0) * (float)adxl345_y;
      adxl345_za = (90.0 / 256.0) * (float)adxl345_z;
    }
    adxl345_xa_ya = adxl345_xa / adxl345_ya;
    adxl345_xa_za = adxl345_xa / adxl345_za;
    adxl345_ya_za = adxl345_ya / adxl345_za;
    if (!screenon) {
      if ((adxl345_xa_ya > -1.0) && (adxl345_xa_ya < 1.0) &&
          (adxl345_xa_za > -1.0) && (adxl345_xa_za < 1.0) &&
          (adxl345_ya_za > 0) && (adxl345_ya_za < 5.0)) {
        eventcount++;
      } else {
        eventcount = 0;
      }
      if (eventcount > 15) {
        screenon = 1;
        eventcount = 0;
      }
    }
    if (screenon) {
      if (!((adxl345_xa_ya > -1.0) && (adxl345_xa_ya < 1.0) &&
            (adxl345_xa_za > -1.0) && (adxl345_xa_za < 1.0) &&
            (adxl345_ya_za > 0) && (adxl345_ya_za < 5.0))) {
        printf("If2");
        eventcount++;
      } else {
        eventcount = 0;
      }
      if (eventcount > 25) {
        screenon = 0;
        eventcount = 0;
      }
    }
    float data;
    int k = read(tmp102, tmp102_buf, 2);
    if ((k != 2)) {
      printf("tmp102 failed to report data");
      printf("error: %s (%d)\n", strerror(errno), errno);
    } else {
      tmp102_temperature = ((tmp102_buf[0]) << 8) | (tmp102_buf[1]);
      tmp102_temperature >>= 4;
      if (tmp102_temperature & (1 << 11)) {
        tmp102_temperature |= 0xF800;
      }
      printf("temp: %04f, ", tmp102_temperature * 0.0625);
    }
    selectDevice(hmc5883l, 0x1e, "hmc5883l");
    hmc5883l_buf[0] = 0x03;
    if ((write(hmc5883l, hmc5883l_buf, 1)) != 1) {
      printf("Error writing to I2C slave\n");
      printf("error: %s (%d)\n", strerror(errno), errno);
    }
    if (read(hmc5883l, hmc5883l_buf, 6) != 6) {
      printf("Unable to read from hmc5883l\n");
      printf("error: %s (%d)\n", strerror(errno), errno);
    } else {
      hmc5883l_x = hmc5883l_buf[1] << 8 | hmc5883l_buf[0];
      hmc5883l_z = hmc5883l_buf[3] << 8 | hmc5883l_buf[2];
      hmc5883l_y = hmc5883l_buf[5] << 8 | hmc5883l_buf[4];
      hmc5883l_head = atan2(hmc5883l_y, hmc5883l_x);
      if (hmc5883l_head < 0) {
        hmc5883l_head += 2 * 3.14159265358979323846;
      }
      hmc5883l_head = hmc5883l_head * 180 / 3.14159265358979323846;
      printf(" Compass x: %d, y: %d, heading: %4.0f\n", hmc5883l_x, hmc5883l_y,
             hmc5883l_head);
    }
    printf(
        " x/y: %4.4f x/z: %4.4f y/z: %4.4f :::: eventcount %d, screenon %d \n",
        adxl345_xa_ya, adxl345_xa_za, adxl345_ya_za, eventcount, screenon);
    usleep(100000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x51(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x1,-0x78(%rbp)
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    0xe45(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jge    1248 <main+0x98>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2daa(%rip),%rax
mov    (%rax),%edx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x3c(%rbp),%edi
mov    $0x1e,%esi
lea    0xe23(%rip),%rdx
call   10b0 <selectDevice@plt>
mov    -0x3c(%rbp),%edi
xor    %esi,%esi
mov    $0x74,%edx
lea    0xe0d(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
mov    $0x20,%edx
lea    0xdf4(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x3c(%rbp),%edi
mov    $0x2,%esi
xor    %edx,%edx
lea    0xdde(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    $0x105b8,%edi
call   10d0 <usleep@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
lea    0xd81(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jge    130c <main+0x15c>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2ce6(%rip),%rax
mov    (%rax),%edx
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%edi
mov    $0x49,%esi
lea    0xd68(%rip),%rdx
call   10b0 <selectDevice@plt>
mov    -0x38(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%edx
lea    0xd52(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%esi
lea    0xcf6(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1397 <main+0x1e7>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2c5b(%rip),%rax
mov    (%rax),%edx
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x34(%rbp),%edi
mov    $0x53,%esi
lea    0xd08(%rip),%rdx
call   10b0 <selectDevice@plt>
mov    -0x34(%rbp),%edi
mov    $0x2d,%esi
xor    %edx,%edx
lea    0xcfa(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x34(%rbp),%edi
mov    $0x2d,%esi
mov    $0x10,%edx
lea    0xce1(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x34(%rbp),%edi
mov    $0x2d,%esi
mov    $0x8,%edx
lea    0xcc8(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x34(%rbp),%edi
mov    $0x2d,%esi
mov    $0xb,%edx
lea    0xcaf(%rip),%rcx
call   1060 <writeToDevice@plt>
mov    -0x34(%rbp),%edi
mov    $0x53,%esi
lea    0xc93(%rip),%rdx
call   10b0 <selectDevice@plt>
movb   $0x32,-0x50(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     1474 <main+0x2c4>
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2b74(%rip),%rax
mov    (%rax),%edx
lea    0xbfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1080 <read@plt>
cmp    $0x6,%eax
je     14cb <main+0x31b>
lea    0xc43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2b22(%rip),%rax
mov    (%rax),%edx
lea    0xbab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1559 <main+0x3a9>
movzbl -0x4f(%rbp),%eax
shl    $0x8,%eax
movzbl -0x50(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x12(%rbp)
movzbl -0x4d(%rbp),%eax
shl    $0x8,%eax
movzbl -0x4e(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x14(%rbp)
movzbl -0x4b(%rbp),%eax
shl    $0x8,%eax
movzbl -0x4c(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x16(%rbp)
movswl -0x12(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xaee(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movswl -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movswl -0x16(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xab4(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0x78(%rbp)
jne    165a <main+0x4aa>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xa67(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1636 <main+0x486>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xa54(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1636 <main+0x486>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xa31(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1636 <main+0x486>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xa1e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1636 <main+0x486>
movss  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1636 <main+0x486>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0x9fa(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1636 <main+0x486>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    163d <main+0x48d>
movl   $0x0,-0x74(%rbp)
cmpl   $0xf,-0x74(%rbp)
jle    1655 <main+0x4a5>
movl   $0x1,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
jmp    165a <main+0x4aa>
cmpl   $0x0,-0x78(%rbp)
je     173c <main+0x58c>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x993(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    16fc <main+0x54c>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0x980(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    16fc <main+0x54c>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x95d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    16fc <main+0x54c>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0x94a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    16fc <main+0x54c>
movss  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    16fc <main+0x54c>
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0x926(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1718 <main+0x568>
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    171f <main+0x56f>
movl   $0x0,-0x74(%rbp)
cmpl   $0x19,-0x74(%rbp)
jle    1737 <main+0x587>
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
jmp    173c <main+0x58c>
mov    -0x38(%rbp),%edi
lea    -0x51(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x2,-0x80(%rbp)
je     1797 <main+0x5e7>
lea    0x998(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2867(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2856(%rip),%rax
mov    (%rax),%edx
lea    0x8df(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    17eb <main+0x63b>
movsbl -0x51(%rbp),%eax
shl    $0x8,%eax
movsbl -0x50(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     17cc <main+0x61c>
mov    -0x40(%rbp),%eax
or     $0xf800,%eax
mov    %eax,-0x40(%rbp)
cvtsi2sdl -0x40(%rbp),%xmm0
movsd  0x847(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0x934(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%edi
mov    $0x1e,%esi
lea    0x880(%rip),%rdx
call   10b0 <selectDevice@plt>
movb   $0x3,-0x70(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     1853 <main+0x6a3>
lea    0x89a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x27a6(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2795(%rip),%rax
mov    (%rax),%edx
lea    0x81e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1080 <read@plt>
cmp    $0x6,%eax
je     18aa <main+0x6fa>
lea    0x8af(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2754(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %rax,%rsi
mov    0x2743(%rip),%rax
mov    (%rax),%edx
lea    0x7cc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1962 <main+0x7b2>
movzbl -0x6f(%rbp),%eax
shl    $0x8,%eax
movzbl -0x70(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x54(%rbp)
movzbl -0x6d(%rbp),%eax
shl    $0x8,%eax
movzbl -0x6e(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x58(%rbp)
movzbl -0x6b(%rbp),%eax
shl    $0x8,%eax
movzbl -0x6c(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x56(%rbp)
mov    -0x56(%rbp),%ax
movswl %ax,%edi
movswl -0x54(%rbp),%esi
call   1040 <atan2@plt>
movss  %xmm0,-0x5c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x5c(%rbp),%xmm0
jbe    191d <main+0x76d>
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x718(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  0x713(%rip),%xmm0
mulss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x6fa(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
movswl -0x54(%rbp),%esi
movswl -0x56(%rbp),%edx
movss  -0x5c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0x7e8(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x30(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
lea    0x7e0(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    $0x186a0,%edi
call   10d0 <usleep@plt>
jmp    140c <main+0x25c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movb   $0x0,0x7(%rsp)
mov    0x2e1b(%rip),%r14
mov    (%r14),%esi
lea    0xe9d(%rip),%rdi
call   1090 <open@plt>
test   %eax,%eax
js     17f6 <main+0x646>
mov    %eax,%r15d
lea    0xf78(%rip),%rbx
mov    %eax,%edi
mov    $0x1e,%esi
mov    %rbx,%rdx
call   10b0 <selectDevice@plt>
mov    %r15d,%edi
xor    %esi,%esi
mov    $0x74,%edx
mov    %rbx,%rcx
call   1070 <writeToDevice@plt>
mov    %r15d,%edi
mov    $0x1,%esi
mov    $0x20,%edx
mov    %rbx,%rcx
call   1070 <writeToDevice@plt>
mov    %r15d,%edi
mov    $0x2,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1070 <writeToDevice@plt>
mov    $0x105b8,%edi
call   10d0 <usleep@plt>
mov    (%r14),%esi
lea    0xe2a(%rip),%rdi
call   1090 <open@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     17f6 <main+0x646>
lea    0xe50(%rip),%rbx
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    $0x49,%esi
mov    %rbx,%rdx
call   10b0 <selectDevice@plt>
mov    $0x1,%r13d
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <writeToDevice@plt>
mov    (%r14),%esi
lea    0xdde(%rip),%rdi
call   1090 <open@plt>
test   %eax,%eax
js     1806 <main+0x656>
mov    %eax,%ebx
lea    0xed7(%rip),%rdx
mov    %eax,%edi
mov    $0x53,%esi
call   10b0 <selectDevice@plt>
mov    %ebx,0x8(%rsp)
lea    0xefe(%rip),%r14
mov    0x8(%rsp),%edi
mov    $0x2d,%esi
xor    %edx,%edx
mov    %r14,%rcx
call   1070 <writeToDevice@plt>
mov    0x8(%rsp),%edi
mov    $0x2d,%esi
mov    $0x10,%edx
mov    %r14,%rcx
call   1070 <writeToDevice@plt>
mov    0x8(%rsp),%edi
mov    $0x2d,%esi
mov    $0x8,%edx
mov    %r14,%rcx
call   1070 <writeToDevice@plt>
mov    0x8(%rsp),%edi
mov    $0x2d,%esi
mov    $0xb,%edx
mov    %r14,%rcx
mov    0x8(%rsp),%r14d
call   1070 <writeToDevice@plt>
xor    %ebx,%ebx
jmp    1405 <main+0x255>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x11(%rsp),%eax
shl    $0x8,%eax
movzbl 0x10(%rsp),%ecx
mov    %r15d,%ebp
movswl %ax,%r15d
or     %ecx,%r15d
movzbl 0x15(%rsp),%eax
shl    $0x8,%eax
movzbl 0x14(%rsp),%ecx
movswl %ax,%r14d
or     %ecx,%r14d
mov    %r14d,%edi
mov    %r15d,%esi
call   1050 <atan2@plt>
cvtss2sd %xmm0,%xmm1
addsd  0xcde(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
movaps %xmm0,%xmm2
cmpltss 0xcee(%rip),%xmm2
movaps %xmm2,%xmm3
andnps %xmm0,%xmm3
andps  %xmm1,%xmm2
orps   %xmm3,%xmm2
mulss  0xcd6(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
divsd  0xcb3(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd33(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%r15d
mov    %r14d,%edx
mov    0x8(%rsp),%r14d
mov    $0x1,%al
call   1060 <printf@plt>
movaps 0x70(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movaps 0x40(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movaps 0x30(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd23(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    $0x3,%al
call   1060 <printf@plt>
mov    $0x186a0,%edi
call   10d0 <usleep@plt>
mov    %r12d,%ebx
mov    %r14d,%edi
mov    $0x53,%esi
lea    0xd6f(%rip),%rdx
call   10b0 <selectDevice@plt>
movb   $0x32,0x20(%rsp)
mov    %r14d,%edi
lea    0x20(%rsp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
je     1464 <main+0x2b4>
lea    0xd4f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2b90(%rip),%rbp
mov    0x0(%rbp),%edi
call   10c0 <strerror@plt>
mov    0x0(%rbp),%edx
lea    0xc48(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
lea    0x20(%rsp),%rsi
mov    $0x6,%edx
xor    %eax,%eax
call   1080 <read@plt>
cmp    $0x6,%eax
jne    1530 <main+0x380>
movdqa 0x20(%rsp),%xmm0
movdqa %xmm0,0x80(%rsp)
psrld  $0x10,%xmm0
movzbl 0x83(%rsp),%eax
mov    %eax,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
movzbl 0x21(%rsp),%edx
shl    $0x8,%edx
or     %eax,%edx
movd   %edx,%xmm1
pinsrw $0x1,%ecx,%xmm1
pxor   %xmm2,%xmm2
punpcklbw %xmm1,%xmm2
movd   0x20(%rsp),%xmm1
psllw  $0x8,%xmm1
movdqa 0xb2e(%rip),%xmm4
movdqa %xmm4,%xmm3
pandn  %xmm1,%xmm3
pand   %xmm4,%xmm0
por    %xmm3,%xmm0
punpcklbw 0xb46(%rip),%xmm0
movswl 0x24(%rsp),%eax
pshuflw $0x60,%xmm0,%xmm0
pshuflw $0x60,%xmm2,%xmm1
por    %xmm0,%xmm1
psrad  $0x10,%xmm1
cvtdq2pd %xmm1,%xmm0
mulpd  0xb02(%rip),%xmm0
cvtpd2ps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xb1f(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
jmp    156a <main+0x3ba>
nopw   0x0(%rax,%rax,1)
lea    0xc38(%rip),%rdi
call   1030 <puts@plt>
mov    0x2a95(%rip),%rbp
mov    0x0(%rbp),%edi
call   10c0 <strerror@plt>
mov    0x0(%rbp),%edx
lea    0xb4d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
movapd 0x60(%rsp),%xmm1
movaps 0x50(%rsp),%xmm0
movapd %xmm1,%xmm2
shufps $0x55,%xmm1,%xmm2
divss  %xmm1,%xmm2
movaps %xmm0,0x50(%rsp)
shufps $0x0,%xmm0,%xmm0
movaps %xmm1,%xmm3
divps  %xmm0,%xmm3
movaps %xmm3,0x30(%rsp)
shufps $0x55,%xmm3,%xmm3
movaps %xmm3,0x40(%rsp)
test   %r13d,%r13d
movaps %xmm1,0x60(%rsp)
movaps %xmm2,0x70(%rsp)
je     1770 <main+0x5c0>
ucomiss 0xab3(%rip),%xmm2
jbe    1600 <main+0x450>
movss  0xaad(%rip),%xmm0
ucomiss %xmm2,%xmm0
jbe    1600 <main+0x450>
movaps 0x40(%rsp),%xmm0
ucomiss 0xa98(%rip),%xmm0
jbe    1600 <main+0x450>
movaps 0x30(%rsp),%xmm0
cmpltps 0xa49(%rip),%xmm0
01
unpcklps %xmm0,%xmm0
movmskpd %xmm0,%eax
test   $0x2,%al
je     1600 <main+0x450>
movaps 0x30(%rsp),%xmm0
ucomiss 0xa82(%rip),%xmm0
jbe    1600 <main+0x450>
xor    %r12d,%r12d
test   $0x1,%al
jne    1614 <main+0x464>
nopw   0x0(%rax,%rax,1)
lea    0xab2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
mov    %ebx,%r12d
xor    %r13d,%r13d
cmp    $0x1a,%r12d
setl   %r13b
mov    $0x0,%eax
cmovge %eax,%r12d
mov    0xc(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1080 <read@plt>
cmp    $0x2,%eax
jne    1690 <main+0x4e0>
movsbl 0x7(%rsp),%eax
shl    $0x8,%eax
movsbl 0x8(%rsp),%ecx
or     %eax,%ecx
mov    %ecx,%eax
sar    $0x4,%eax
mov    %eax,%edx
or     $0xf800,%edx
test   $0x8000,%ecx
cmove  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  0x9d2(%rip),%xmm0
lea    0xa5d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    16bf <main+0x50f>
cs nopw 0x0(%rax,%rax,1)
lea    0xa26(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2933(%rip),%rbx
mov    (%rbx),%edi
call   10c0 <strerror@plt>
mov    (%rbx),%edx
lea    0x9ed(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %r15d,%edi
mov    $0x1e,%esi
lea    0xa93(%rip),%rdx
call   10b0 <selectDevice@plt>
movb   $0x3,0x10(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
je     1721 <main+0x571>
lea    0xa92(%rip),%rdi
call   1030 <puts@plt>
mov    0x28d3(%rip),%rbp
mov    0x0(%rbp),%edi
call   10c0 <strerror@plt>
mov    0x0(%rbp),%edx
lea    0x98b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x6,%edx
xor    %eax,%eax
call   1080 <read@plt>
cmp    $0x6,%eax
je     1330 <main+0x180>
lea    0xa0f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2889(%rip),%rbx
mov    (%rbx),%edi
call   10c0 <strerror@plt>
mov    (%rbx),%edx
lea    0x943(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13c9 <main+0x219>
xchg   %ax,%ax
xor    %r12d,%r12d
ucomiss 0x8e6(%rip),%xmm2
jbe    17ee <main+0x63e>
movss  0x8e0(%rip),%xmm0
ucomiss %xmm2,%xmm0
jbe    17ee <main+0x63e>
movaps 0x40(%rsp),%xmm0
ucomiss 0x8cb(%rip),%xmm0
mov    $0x0,%r13d
jbe    1628 <main+0x478>
add    $0x1,%ebx
xor    %r13d,%r13d
movss  0x8b9(%rip),%xmm0
movaps 0x30(%rsp),%xmm3
ucomiss %xmm3,%xmm0
cmovbe %r13d,%ebx
ucomiss 0x8ae(%rip),%xmm3
cmovbe %r13d,%ebx
movss  0x896(%rip),%xmm0
ucomiss 0x40(%rsp),%xmm0
mov    %ebx,%r12d
cmovbe %r13d,%r12d
mov    $0x0,%ebx
cmp    $0x10,%r12d
jge    15a6 <main+0x3f6>
jmp    1628 <main+0x478>
xor    %r13d,%r13d
jmp    1628 <main+0x478>
lea    0x882(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1812 <main+0x662>
lea    0x999(%rip),%rdi
call   1030 <puts@plt>
mov    0x27bf(%rip),%rbx
mov    (%rbx),%edi
call   10c0 <strerror@plt>
mov    (%rbx),%edx
lea    0x879(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-0\00"
@O_RDWR = global i32 0
@.str.1 = [35 x i8] c"Failed to open i2c bus for tmp102.\00"
@.str.2 = [16 x i8] c"error: %s (%d)\0A\00"
@errno = global i32 0
@.str.3 = [9 x i8] c"hmc5883l\00"
@.str.4 = [7 x i8] c"tmp102\00"
@.str.5 = [36 x i8] c"Failed to open i2c bus for adxl345\0A\00"
@.str.6 = [8 x i8] c"ADXL345\00"
@.str.7 = [8 x i8] c"adxl345\00"
@.str.8 = [28 x i8] c"Error writing to I2C slave\0A\00"
@.str.9 = [29 x i8] c"Unable to read from ADXL345\0A\00"
@.str.10 = [4 x i8] c"If2\00"
@.str.11 = [29 x i8] c"tmp102 failed to report data\00"
@.str.12 = [13 x i8] c"temp: %04f, \00"
@.str.13 = [30 x i8] c"Unable to read from hmc5883l\0A\00"
@.str.14 = [39 x i8] c" Compass x: %d, y: %d, heading: %4.0f\0A\00"
@.str.15 = [68 x i8] c" x/y: %4.4f x/z: %4.4f y/z: %4.4f :::: eventcount %d, screenon %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [16 x i8]
%20 = alloca [1 x i8]
%21 = alloca i16
%22 = alloca i16
%23 = alloca i16
%24 = alloca float
%25 = alloca [16 x i8]
%26 = alloca i32
%27 = alloca i32
%28 = alloca float
%29 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = bitcast [1 x i8]* %20 to i8*
store i32 0, i32* %26
store i32 1, i32* %27
%31 = load i32, i32* @O_RDWR
%32 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %31)
store i32 %32, i32* %17
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = load i32, i32* @errno
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %2
%42 = load i32, i32* %17
%43 = call i32 @selectDevice(i32 %42, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %17
%45 = call i32 @writeToDevice(i32 %44, i32 0, i32 116, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* %17
%47 = call i32 @writeToDevice(i32 %46, i32 1, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* %17
%49 = call i32 @writeToDevice(i32 %48, i32 2, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 @usleep(i32 67000)
%51 = load i32, i32* @O_RDWR
%52 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %51)
store i32 %52, i32* %16
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %41
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = load i32, i32* @errno
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %57, i32 %58)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %41
%62 = load i32, i32* %16
%63 = call i32 @selectDevice(i32 %62, i32 73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%64 = load i32, i32* %16
%65 = call i32 @writeToDevice(i32 %64, i32 0, i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* @O_RDWR
%67 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %66)
store i32 %67, i32* %15
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %61
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = load i32, i32* @errno
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %72, i32 %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %61
%77 = load i32, i32* %15
%78 = call i32 @selectDevice(i32 %77, i32 83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%79 = load i32, i32* %15
%80 = call i32 @writeToDevice(i32 %79, i32 45, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32, i32* %15
%82 = call i32 @writeToDevice(i32 %81, i32 45, i32 16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%83 = load i32, i32* %15
%84 = call i32 @writeToDevice(i32 %83, i32 45, i32 8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%85 = load i32, i32* %15
%86 = call i32 @writeToDevice(i32 %85, i32 45, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %87
87: ; preds = %76, %345
%88 = load i32, i32* %15
%89 = call i32 @selectDevice(i32 %88, i32 83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%90 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 0
store i8 50, i8* %90
%91 = load i32, i32* %15
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 0
%93 = call i32 @write(i32 %91, i8* %92, i32 1)
%94 = icmp ne i32 %93, 1
br i1 %94, label %95, label %101
95: ; preds = %87
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = load i32, i32* @errno
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %98, i32 %99)
br label %101
101: ; preds = %95, %87
%102 = load i32, i32* %15
%103 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 0
%104 = call i32 (i32, ...) @read(i32 %102, i8* %103, i32 6)
%105 = icmp ne i32 %104, 6
br i1 %105, label %106, label %112
106: ; preds = %101
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = load i32, i32* @errno
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %109, i32 %110)
br label %155
112: ; preds = %101
%113 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 1
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = shl i32 %115, 8
%117 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 0
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = or i32 %116, %119
%121 = trunc i32 %120 to i16
store i16 %121, i16* %6
%122 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 3
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = shl i32 %124, 8
%126 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 2
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = or i32 %125, %128
%130 = trunc i32 %129 to i16
store i16 %130, i16* %7
%131 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 5
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = shl i32 %133, 8
%135 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 4
%136 = load i8, i8* %135
%137 = zext i8 %136 to i32
%138 = or i32 %134, %137
%139 = trunc i32 %138 to i16
store i16 %139, i16* %8
%140 = load i16, i16* %6
%141 = sitofp i16 %140 to float
%142 = fpext float %141 to double
%143 = fmul double 0x3FD6800000000000, %142
%144 = fptrunc double %143 to float
store float %144, float* %9
%145 = load i16, i16* %7
%146 = sitofp i16 %145 to float
%147 = fpext float %146 to double
%148 = fmul double 0x3FD6800000000000, %147
%149 = fptrunc double %148 to float
store float %149, float* %10
%150 = load i16, i16* %8
%151 = sitofp i16 %150 to float
%152 = fpext float %151 to double
%153 = fmul double 0x3FD6800000000000, %152
%154 = fptrunc double %153 to float
store float %154, float* %11
br label %155
155: ; preds = %112, %106
%156 = load float, float* %9
%157 = load float, float* %10
%158 = fdiv float %156, %157
store float %158, float* %12
%159 = load float, float* %9
%160 = load float, float* %11
%161 = fdiv float %159, %160
store float %161, float* %13
%162 = load float, float* %10
%163 = load float, float* %11
%164 = fdiv float %162, %163
store float %164, float* %14
%165 = load i32, i32* %27
%166 = icmp ne i32 %165, 0
br i1 %166, label %199, label %167
167: ; preds = %155
%168 = load float, float* %12
%169 = fpext float %168 to double
%170 = fcmp ogt double %169, -1.000000e+00
br i1 %170, label %171, label %193
171: ; preds = %167
%172 = load float, float* %12
%173 = fpext float %172 to double
%174 = fcmp olt double %173, 1.000000e+00
br i1 %174, label %175, label %193
175: ; preds = %171
%176 = load float, float* %13
%177 = fpext float %176 to double
%178 = fcmp ogt double %177, -1.000000e+00
br i1 %178, label %179, label %193
179: ; preds = %175
%180 = load float, float* %13
%181 = fpext float %180 to double
%182 = fcmp olt double %181, 1.000000e+00
br i1 %182, label %183, label %193
183: ; preds = %179
%184 = load float, float* %14
%185 = fcmp ogt float %184, 0.000000e+00
br i1 %185, label %186, label %193
186: ; preds = %183
%187 = load float, float* %14
%188 = fpext float %187 to double
%189 = fcmp olt double %188, 5.000000e+00
br i1 %189, label %190, label %193
190: ; preds = %186
%191 = load i32, i32* %26
%192 = add nsw i32 %191, 1
store i32 %192, i32* %26
br label %194
193: ; preds = %186, %183, %179, %175, %171, %167
store i32 0, i32* %26
br label %194
194: ; preds = %193, %190
%195 = load i32, i32* %26
%196 = icmp sgt i32 %195, 15
br i1 %196, label %197, label %198
197: ; preds = %194
store i32 1, i32* %27
store i32 0, i32* %26
br label %198
198: ; preds = %197, %194
br label %199
199: ; preds = %198, %155
%200 = load i32, i32* %27
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %235
202: ; preds = %199
%203 = load float, float* %12
%204 = fpext float %203 to double
%205 = fcmp ogt double %204, -1.000000e+00
br i1 %205, label %206, label %225
206: ; preds = %202
%207 = load float, float* %12
%208 = fpext float %207 to double
%209 = fcmp olt double %208, 1.000000e+00
br i1 %209, label %210, label %225
210: ; preds = %206
%211 = load float, float* %13
%212 = fpext float %211 to double
%213 = fcmp ogt double %212, -1.000000e+00
br i1 %213, label %214, label %225
214: ; preds = %210
%215 = load float, float* %13
%216 = fpext float %215 to double
%217 = fcmp olt double %216, 1.000000e+00
br i1 %217, label %218, label %225
218: ; preds = %214
%219 = load float, float* %14
%220 = fcmp ogt float %219, 0.000000e+00
br i1 %220, label %221, label %225
221: ; preds = %218
%222 = load float, float* %14
%223 = fpext float %222 to double
%224 = fcmp olt double %223, 5.000000e+00
br i1 %224, label %229, label %225
225: ; preds = %221, %218, %214, %210, %206, %202
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%227 = load i32, i32* %26
%228 = add nsw i32 %227, 1
store i32 %228, i32* %26
br label %230
229: ; preds = %221
store i32 0, i32* %26
br label %230
230: ; preds = %229, %225
%231 = load i32, i32* %26
%232 = icmp sgt i32 %231, 25
br i1 %232, label %233, label %234
233: ; preds = %230
store i32 0, i32* %27
store i32 0, i32* %26
br label %234
234: ; preds = %233, %230
br label %235
235: ; preds = %234, %199
%236 = load i32, i32* %16
%237 = getelementptr inbounds [1 x i8], [1 x i8]* %20, i64 0, i64 0
%238 = call i32 (i32, ...) @read(i32 %236, i8* %237, i32 2)
store i32 %238, i32* %29
%239 = load i32, i32* %29
%240 = icmp ne i32 %239, 2
br i1 %240, label %241, label %247
241: ; preds = %235
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%243 = load i32, i32* @errno
%244 = call i8* @strerror(i32 %243)
%245 = load i32, i32* @errno
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %244, i32 %245)
br label %269
247: ; preds = %235
%248 = getelementptr inbounds [1 x i8], [1 x i8]* %20, i64 0, i64 0
%249 = load i8, i8* %248
%250 = sext i8 %249 to i32
%251 = shl i32 %250, 8
%252 = getelementptr inbounds [1 x i8], [1 x i8]* %20, i64 0, i64 1
%253 = load i8, i8* %252
%254 = sext i8 %253 to i32
%255 = or i32 %251, %254
store i32 %255, i32* %18
%256 = load i32, i32* %18
%257 = ashr i32 %256, 4
store i32 %257, i32* %18
%258 = load i32, i32* %18
%259 = and i32 %258, 2048
%260 = icmp ne i32 %259, 0
br i1 %260, label %261, label %264
261: ; preds = %247
%262 = load i32, i32* %18
%263 = or i32 %262, 63488
store i32 %263, i32* %18
br label %264
264: ; preds = %261, %247
%265 = load i32, i32* %18
%266 = sitofp i32 %265 to double
%267 = fmul double %266, 6.250000e-02
%268 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), double %267)
br label %269
269: ; preds = %264, %241
%270 = load i32, i32* %17
%271 = call i32 @selectDevice(i32 %270, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%272 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 0
store i8 3, i8* %272
%273 = load i32, i32* %17
%274 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 0
%275 = call i32 @write(i32 %273, i8* %274, i32 1)
%276 = icmp ne i32 %275, 1
br i1 %276, label %277, label %283
277: ; preds = %269
%278 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%279 = load i32, i32* @errno
%280 = call i8* @strerror(i32 %279)
%281 = load i32, i32* @errno
%282 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %280, i32 %281)
br label %283
283: ; preds = %277, %269
%284 = load i32, i32* %17
%285 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 0
%286 = call i32 (i32, ...) @read(i32 %284, i8* %285, i32 6)
%287 = icmp ne i32 %286, 6
br i1 %287, label %288, label %294
288: ; preds = %283
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%290 = load i32, i32* @errno
%291 = call i8* @strerror(i32 %290)
%292 = load i32, i32* @errno
%293 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %291, i32 %292)
br label %345
294: ; preds = %283
%295 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 1
%296 = load i8, i8* %295
%297 = zext i8 %296 to i32
%298 = shl i32 %297, 8
%299 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 0
%300 = load i8, i8* %299
%301 = zext i8 %300 to i32
%302 = or i32 %298, %301
%303 = trunc i32 %302 to i16
store i16 %303, i16* %21
%304 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 3
%305 = load i8, i8* %304
%306 = zext i8 %305 to i32
%307 = shl i32 %306, 8
%308 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 2
%309 = load i8, i8* %308
%310 = zext i8 %309 to i32
%311 = or i32 %307, %310
%312 = trunc i32 %311 to i16
store i16 %312, i16* %23
%313 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 5
%314 = load i8, i8* %313
%315 = zext i8 %314 to i32
%316 = shl i32 %315, 8
%317 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 4
%318 = load i8, i8* %317
%319 = zext i8 %318 to i32
%320 = or i32 %316, %319
%321 = trunc i32 %320 to i16
store i16 %321, i16* %22
%322 = load i16, i16* %22
%323 = load i16, i16* %21
%324 = call float @atan2(i16 signext %322, i16 signext %323)
store float %324, float* %24
%325 = load float, float* %24
%326 = fcmp olt float %325, 0.000000e+00
br i1 %326, label %327, label %332
327: ; preds = %294
%328 = load float, float* %24
%329 = fpext float %328 to double
%330 = fadd double %329, 0x401921FB54442D18
%331 = fptrunc double %330 to float
store float %331, float* %24
br label %332
332: ; preds = %327, %294
%333 = load float, float* %24
%334 = fmul float %333, 1.800000e+02
%335 = fpext float %334 to double
%336 = fdiv double %335, 0x400921FB54442D18
%337 = fptrunc double %336 to float
store float %337, float* %24
%338 = load i16, i16* %21
%339 = sext i16 %338 to i32
%340 = load i16, i16* %22
%341 = sext i16 %340 to i32
%342 = load float, float* %24
%343 = fpext float %342 to double
%344 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i32 %339, i32 %341, double %343)
br label %345
345: ; preds = %332, %288
%346 = load float, float* %12
%347 = fpext float %346 to double
%348 = load float, float* %13
%349 = fpext float %348 to double
%350 = load float, float* %14
%351 = fpext float %350 to double
%352 = load i32, i32* %26
%353 = load i32, i32* %27
%354 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.15, i64 0, i64 0), double %347, double %349, double %351, i32 %352, i32 %353)
%355 = call i32 @usleep(i32 100000)
br label %87
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-0\00"
@O_RDWR = global i32 0
@.str.1 = [35 x i8] c"Failed to open i2c bus for tmp102.\00"
@.str.2 = [16 x i8] c"error: %s (%d)\0A\00"
@errno = global i32 0
@.str.3 = [9 x i8] c"hmc5883l\00"
@.str.4 = [7 x i8] c"tmp102\00"
@.str.6 = [8 x i8] c"ADXL345\00"
@.str.7 = [8 x i8] c"adxl345\00"
@.str.10 = [4 x i8] c"If2\00"
@.str.11 = [29 x i8] c"tmp102 failed to report data\00"
@.str.12 = [13 x i8] c"temp: %04f, \00"
@.str.14 = [39 x i8] c" Compass x: %d, y: %d, heading: %4.0f\0A\00"
@.str.15 = [68 x i8] c" x/y: %4.4f x/z: %4.4f y/z: %4.4f :::: eventcount %d, screenon %d \0A\00"
@str = [29 x i8] c"Unable to read from hmc5883l\00"
@str.17 = [28 x i8] c"Unable to read from ADXL345\00"
@str.18 = [27 x i8] c"Error writing to I2C slave\00"
@str.19 = [35 x i8] c"Failed to open i2c bus for adxl345\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca <16 x i8>
%4 = alloca [1 x i8]
%5 = alloca [16 x i8]
%6 = getelementptr inbounds <16 x i8>, <16 x i8>* %3, i64 0, i64 0
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 0, i8* %7
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* @O_RDWR
%10 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = load i32, i32* @errno
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = tail call i32 @selectDevice(i32 %10, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 @writeToDevice(i32 %10, i32 0, i32 116, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @writeToDevice(i32 %10, i32 1, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @writeToDevice(i32 %10, i32 2, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @usleep(i32 67000)
%25 = load i32, i32* @O_RDWR
%26 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %19
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @errno
%31 = tail call i8* @strerror(i32 %30)
%32 = load i32, i32* @errno
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %31, i32 %32)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %19
%36 = tail call i32 @selectDevice(i32 %26, i32 73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%37 = tail call i32 @writeToDevice(i32 %26, i32 0, i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%38 = load i32, i32* @O_RDWR
%39 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %35
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.19, i64 0, i64 0))
%43 = load i32, i32* @errno
%44 = tail call i8* @strerror(i32 %43)
%45 = load i32, i32* @errno
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %44, i32 %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %35
%49 = tail call i32 @selectDevice(i32 %39, i32 83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%50 = tail call i32 @writeToDevice(i32 %39, i32 45, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%51 = tail call i32 @writeToDevice(i32 %39, i32 45, i32 16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%52 = tail call i32 @writeToDevice(i32 %39, i32 45, i32 8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%53 = tail call i32 @writeToDevice(i32 %39, i32 45, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%54 = getelementptr inbounds <16 x i8>, <16 x i8>* %3, i64 0, i64 1
%55 = getelementptr inbounds <16 x i8>, <16 x i8>* %3, i64 0, i64 5
%56 = getelementptr inbounds <16 x i8>, <16 x i8>* %3, i64 0, i64 4
%57 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 1
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 1
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 5
%60 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 4
br label %61
61: ; preds = %232, %48
%62 = phi float [ undef, %48 ], [ %109, %232 ]
%63 = phi i32 [ 0, %48 ], [ %161, %232 ]
%64 = phi i32 [ 1, %48 ], [ %162, %232 ]
%65 = phi <2 x float> [ undef, %48 ], [ %110, %232 ]
%66 = call i32 @selectDevice(i32 %39, i32 83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i8 50, i8* %6
%67 = call i32 @write(i32 %39, i8* %6, i32 1)
%68 = icmp eq i32 %67, 1
br i1 %68, label %75, label %69
69: ; preds = %61
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = load i32, i32* @errno
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %72, i32 %73)
br label %75
75: ; preds = %69, %61
%76 = call i32 (i32, ...) @read(i32 %39, i8* %6, i32 6)
%77 = icmp eq i32 %76, 6
br i1 %77, label %84, label %78
78: ; preds = %75
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = load i32, i32* @errno
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %81, i32 %82)
br label %108
84: ; preds = %75
%85 = load i8, i8* %54
%86 = load i8, i8* %6
%87 = load <16 x i8>, <16 x i8>* %3
%88 = shufflevector <16 x i8> %87, <16 x i8> poison, <2 x i32> <i32 3, i32 undef>
%89 = insertelement <2 x i8> %88, i8 %85, i64 1
%90 = zext <2 x i8> %89 to <2 x i16>
%91 = shl nuw <2 x i16> %90, <i16 8, i16 8>
%92 = shufflevector <16 x i8> %87, <16 x i8> poison, <2 x i32> <i32 2, i32 undef>
%93 = insertelement <2 x i8> %92, i8 %86, i64 1
%94 = zext <2 x i8> %93 to <2 x i16>
%95 = or <2 x i16> %91, %94
%96 = load i8, i8* %55
%97 = zext i8 %96 to i16
%98 = shl nuw i16 %97, 8
%99 = load i8, i8* %56
%100 = zext i8 %99 to i16
%101 = or i16 %98, %100
%102 = sitofp <2 x i16> %95 to <2 x double>
%103 = fmul <2 x double> %102, <double 0x3FD6800000000000, double 0x3FD6800000000000>
%104 = fptrunc <2 x double> %103 to <2 x float>
%105 = sitofp i16 %101 to double
%106 = fmul double %105, 0x3FD6800000000000
%107 = fptrunc double %106 to float
br label %108
108: ; preds = %84, %78
%109 = phi float [ %62, %78 ], [ %107, %84 ]
%110 = phi <2 x float> [ %65, %78 ], [ %104, %84 ]
%111 = extractelement <2 x float> %110, i64 0
%112 = extractelement <2 x float> %110, i64 1
%113 = fdiv float %112, %111
%114 = insertelement <2 x float> poison, float %109, i64 0
%115 = shufflevector <2 x float> %114, <2 x float> poison, <2 x i32> zeroinitializer
%116 = fdiv <2 x float> %110, %115
%117 = icmp eq i32 %64, 0
br i1 %117, label %118, label %135
118: ; preds = %108
%119 = fcmp ogt float %113, -1.000000e+00
%120 = fcmp olt float %113, 1.000000e+00
%121 = and i1 %119, %120
%122 = extractelement <2 x float> %116, i64 1
%123 = fcmp ogt float %122, -1.000000e+00
%124 = select i1 %121, i1 %123, i1 false
br i1 %124, label %125, label %160
125: ; preds = %118
%126 = fcmp olt float %122, 1.000000e+00
%127 = extractelement <2 x float> %116, i64 0
%128 = fcmp ogt float %127, 0.000000e+00
%129 = select i1 %126, i1 %128, i1 false
%130 = fcmp olt float %127, 5.000000e+00
%131 = select i1 %129, i1 %130, i1 false
%132 = add nsw i32 %63, 1
%133 = select i1 %131, i32 %132, i32 0
%134 = icmp sgt i32 %133, 15
br i1 %134, label %135, label %160
135: ; preds = %108, %125
%136 = phi i32 [ 0, %125 ], [ %63, %108 ]
%137 = fcmp ogt float %113, -1.000000e+00
%138 = fcmp olt float %113, 1.000000e+00
%139 = and i1 %137, %138
%140 = extractelement <2 x float> %116, i64 1
%141 = fcmp ogt float %140, -1.000000e+00
%142 = select i1 %139, i1 %141, i1 false
br i1 %142, label %143, label %151
143: ; preds = %135
%144 = extractelement <2 x float> %116, i64 0
%145 = fcmp ogt float %144, 0.000000e+00
%146 = fcmp olt <2 x float> %116, <float 5.000000e+00, float 1.000000e+00>
%147 = extractelement <2 x i1> %146, i64 1
%148 = select i1 %147, i1 %145, i1 false
%149 = extractelement <2 x i1> %146, i64 0
%150 = select i1 %148, i1 %149, i1 false
br i1 %150, label %154, label %151
151: ; preds = %143, %135
%152 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%153 = add nsw i32 %136, 1
br label %154
154: ; preds = %143, %151
%155 = phi i32 [ %153, %151 ], [ 0, %143 ]
%156 = icmp sgt i32 %155, 25
%157 = select i1 %156, i32 0, i32 %155
%158 = xor i1 %156, true
%159 = zext i1 %158 to i32
br label %160
160: ; preds = %118, %154, %125
%161 = phi i32 [ %133, %125 ], [ %157, %154 ], [ 0, %118 ]
%162 = phi i32 [ 0, %125 ], [ %159, %154 ], [ 0, %118 ]
%163 = call i32 (i32, ...) @read(i32 %26, i8* %7, i32 2)
%164 = icmp eq i32 %163, 2
br i1 %164, label %171, label %165
165: ; preds = %160
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%167 = load i32, i32* @errno
%168 = call i8* @strerror(i32 %167)
%169 = load i32, i32* @errno
%170 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %168, i32 %169)
br label %186
171: ; preds = %160
%172 = load i8, i8* %7
%173 = sext i8 %172 to i32
%174 = shl nsw i32 %173, 8
%175 = load i8, i8* %57
%176 = sext i8 %175 to i32
%177 = or i32 %174, %176
%178 = ashr i32 %177, 4
%179 = and i32 %177, 32768
%180 = icmp eq i32 %179, 0
%181 = or i32 %178, 63488
%182 = select i1 %180, i32 %178, i32 %181
%183 = sitofp i32 %182 to double
%184 = fmul double %183, 6.250000e-02
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), double %184)
br label %186
186: ; preds = %171, %165
%187 = call i32 @selectDevice(i32 %10, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i8 3, i8* %8
%188 = call i32 @write(i32 %10, i8* %8, i32 1)
%189 = icmp eq i32 %188, 1
br i1 %189, label %196, label %190
190: ; preds = %186
%191 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%192 = load i32, i32* @errno
%193 = call i8* @strerror(i32 %192)
%194 = load i32, i32* @errno
%195 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %193, i32 %194)
br label %196
196: ; preds = %190, %186
%197 = call i32 (i32, ...) @read(i32 %10, i8* %8, i32 6)
%198 = icmp eq i32 %197, 6
br i1 %198, label %205, label %199
199: ; preds = %196
%200 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%201 = load i32, i32* @errno
%202 = call i8* @strerror(i32 %201)
%203 = load i32, i32* @errno
%204 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %202, i32 %203)
br label %232
205: ; preds = %196
%206 = load i8, i8* %58
%207 = zext i8 %206 to i16
%208 = shl nuw i16 %207, 8
%209 = load i8, i8* %8
%210 = zext i8 %209 to i16
%211 = or i16 %208, %210
%212 = load i8, i8* %59
%213 = zext i8 %212 to i16
%214 = shl nuw i16 %213, 8
%215 = load i8, i8* %60
%216 = zext i8 %215 to i16
%217 = or i16 %214, %216
%218 = call float @atan2(i16 signext %217, i16 signext %211)
%219 = fcmp olt float %218, 0.000000e+00
%220 = fpext float %218 to double
%221 = fadd double %220, 0x401921FB54442D18
%222 = fptrunc double %221 to float
%223 = select i1 %219, float %222, float %218
%224 = fmul float %223, 1.800000e+02
%225 = fpext float %224 to double
%226 = fdiv double %225, 0x400921FB54442D18
%227 = fptrunc double %226 to float
%228 = sext i16 %211 to i32
%229 = sext i16 %217 to i32
%230 = fpext float %227 to double
%231 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0), i32 %228, i32 %229, double %230)
br label %232
232: ; preds = %205, %199
%233 = fpext float %113 to double
%234 = extractelement <2 x float> %116, i64 1
%235 = fpext float %234 to double
%236 = extractelement <2 x float> %116, i64 0
%237 = fpext float %236 to double
%238 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.15, i64 0, i64 0), double %233, double %235, double %237, i32 %161, i32 %162)
%239 = call i32 @usleep(i32 100000)
br label %61
}