#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 M_PI;
int atan2(short, short);
scalar_t__ i2c_read16(int);
unsigned char i2c_read8(int);
int /*<<< orphan*/ i2c_set_slave(int);
scalar_t__ i2c_setup(int);
int /*<<< orphan*/ i2c_write(int, int);
scalar_t__ i2c_write16(int, int, int, int);
int /*<<< orphan*/ i2c_write8(int, int, int);
int /*<<< orphan*/ mag3110_config(int);
short mag3110_readx(int);
short mag3110_ready(int);
scalar_t__ mag3110_readz(int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ printf(char *, float, ...);
int /*<<< orphan*/ sleep(int);
int main(void) {
  int addr = 0x49;
  if (i2c_setup(addr) < 0) {
    print("err setup");
  }
  i2c_set_slave(addr);
  if (i2c_write16(addr, 0x01, 0b10000011, 0x03) < 0)
    print("er r");
  i2c_read16(addr);
  i2c_read16(addr);
  sleep(1);
  i2c_write(addr, 0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  if (i2c_write16(addr, 0x01, 0b10010011, 0x03) < 0)
    print("er r");
  i2c_read16(addr);
  i2c_read16(addr);
  sleep(1);
  i2c_write(addr, 0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  printf("value: %f\n", (float)i2c_read16(addr) * 4.096 / 32767.0);
  i2c_set_slave(0x0e);
  mag3110_config(0x0e);
  printf("Value: %f\n", (float)mag3110_readx(0x0e));
  printf("Value: %f\n", (float)mag3110_ready(0x0e));
  printf("Value: %f\n", (float)mag3110_readz(0x0e));
  printf(
      "Value: %f\n",
      (float)((atan2(mag3110_ready(0x0e), mag3110_readx(0x0e)) * 180) / M_PI));
  i2c_set_slave(0x1e);
  i2c_write8(0x1e, 0x00, 0x14);
  i2c_write8(0x1e, 0x02, 0x00);
  short int x, y, z;
  unsigned char xh, xl, yh, yl, zh, zl;
  i2c_write(0x1e, 0x03);
  xh = i2c_read8(0x1e);
  i2c_write(0x1e, 0x04);
  xl = i2c_read8(0x1e);
  i2c_write(0x1e, 0x05);
  yh = i2c_read8(0x1e);
  i2c_write(0x1e, 0x06);
  yl = i2c_read8(0x1e);
  i2c_write(0x1e, 0x07);
  zh = i2c_read8(0x1e);
  i2c_write(0x1e, 0x08);
  zl = i2c_read8(0x1e);
  x = (short int)((xh << 8) + xl);
  y = (short int)((yh << 8) + yl);
  printf("v %f %f\n", (float)x, (float)y);
  printf("Value: %f\n", (float)(atan2(y, x) * 180) / M_PI);
  float MagMinX, MagMaxX;
  float MagMinY, MagMaxY;
  float MagMinZ, MagMaxZ;
  while (1) {
    i2c_write(0x1e, 0x03);
    xh = i2c_read8(0x1e);
    i2c_write(0x1e, 0x04);
    xl = i2c_read8(0x1e);
    i2c_write(0x1e, 0x05);
    yh = i2c_read8(0x1e);
    i2c_write(0x1e, 0x06);
    yl = i2c_read8(0x1e);
    i2c_write(0x1e, 0x07);
    zh = i2c_read8(0x1e);
    i2c_write(0x1e, 0x08);
    zl = i2c_read8(0x1e);
    x = (short int)((xh << 8) + xl);
    y = (short int)((yh << 8) + yl);
    z = (short int)((zh << 8) + zl);
    if (x < MagMinX)
      MagMinX = x;
    if (x > MagMaxX)
      MagMaxX = x;
    if (y < MagMinY)
      MagMinY = y;
    if (y > MagMaxY)
      MagMaxY = y;
    if (z < MagMinZ)
      MagMinZ = z;
    if (z > MagMaxZ)
      MagMaxZ = z;
    printf("v %f %f\n", (float)x, (float)y);
    printf("Value: %f\n", (float)atan2(y, x) * 180 / M_PI);
    printf("Mag  X Cal %f %f\n", MagMinX, MagMaxX);
    printf("Mag  Y Cal %f %f\n", MagMinY, MagMaxY);
    printf("Mag  Z Cal %f %f\n", MagMinY, MagMaxZ);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x49,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   10d0 <i2c_setup@plt>
cmp    $0x0,%rax
jge    1224 <main+0x34>
lea    0xdf5(%rip),%rdi
call   1070 <print@plt>
mov    -0x8(%rbp),%edi
call   10e0 <i2c_set_slave@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
mov    $0x83,%edx
mov    $0x3,%ecx
call   10c0 <i2c_write16@plt>
cmp    $0x0,%rax
jge    1259 <main+0x69>
lea    0xdca(%rip),%rdi
call   1070 <print@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1080 <i2c_write@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd72(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd5e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xd72(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd37(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd23(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xd37(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcfc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xce8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xcfc(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
mov    $0x93,%edx
mov    $0x3,%ecx
call   10c0 <i2c_write16@plt>
cmp    $0x0,%rax
jge    135b <main+0x16b>
lea    0xcc8(%rip),%rdi
call   1070 <print@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    %esi,-0x34(%rbp)
call   1080 <i2c_write@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc6d(%rip),%xmm1
movsd  %xmm1,-0x60(%rbp)
mulsd  %xmm1,%xmm0
movsd  0xc54(%rip),%xmm1
movsd  %xmm1,-0x58(%rbp)
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xc63(%rip),%rdi
mov    %rdi,-0x50(%rbp)
mov    $0x1,%al
mov    %al,-0x35(%rbp)
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mov    -0x50(%rbp),%rdi
mov    %rax,%rcx
mov    -0x35(%rbp),%al
cvtsi2ss %rcx,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1110 <i2c_read16@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mov    -0x50(%rbp),%rdi
mov    %rax,%rcx
mov    -0x35(%rbp),%al
cvtsi2ss %rcx,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <printf@plt>
mov    $0xe,%edi
mov    %edi,-0x48(%rbp)
call   10e0 <i2c_set_slave@plt>
mov    -0x48(%rbp),%edi
call   1040 <mag3110_config@plt>
mov    -0x48(%rbp),%edi
call   1090 <mag3110_readx@plt>
mov    %ax,%cx
mov    -0x35(%rbp),%al
movswl %cx,%ecx
cvtsi2ss %ecx,%xmm0
lea    0xbc3(%rip),%rdi
mov    %rdi,-0x40(%rbp)
call   1060 <printf@plt>
mov    -0x48(%rbp),%edi
call   1030 <mag3110_ready@plt>
mov    -0x40(%rbp),%rdi
mov    %ax,%cx
mov    -0x35(%rbp),%al
movswl %cx,%ecx
cvtsi2ss %ecx,%xmm0
call   1060 <printf@plt>
mov    -0x48(%rbp),%edi
call   10a0 <mag3110_readz@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rcx
mov    -0x35(%rbp),%al
cvtsi2ss %rcx,%xmm0
call   1060 <printf@plt>
mov    -0x48(%rbp),%edi
call   1030 <mag3110_ready@plt>
mov    -0x48(%rbp),%edi
mov    %ax,-0x42(%rbp)
call   1090 <mag3110_readx@plt>
mov    -0x42(%rbp),%cx
movswl %cx,%edi
movswl %ax,%esi
call   1050 <atan2@plt>
mov    -0x40(%rbp),%rdi
imul   $0xb4,%eax,%eax
mov    0x2b06(%rip),%rcx
mov    (%rcx),%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x35(%rbp),%al
cvtsi2ss %ecx,%xmm0
call   1060 <printf@plt>
mov    $0x1e,%edi
mov    %edi,-0x30(%rbp)
call   10e0 <i2c_set_slave@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edi
mov    $0x14,%edx
call   10b0 <i2c_write8@plt>
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%edi
mov    $0x2,%esi
call   10b0 <i2c_write8@plt>
mov    -0x30(%rbp),%edi
mov    $0x3,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    -0x30(%rbp),%edi
mov    %al,-0xf(%rbp)
mov    $0x4,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    -0x30(%rbp),%edi
mov    %al,-0x10(%rbp)
mov    $0x5,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    -0x30(%rbp),%edi
mov    %al,-0x11(%rbp)
mov    $0x6,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    -0x30(%rbp),%edi
mov    %al,-0x12(%rbp)
mov    $0x7,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    -0x30(%rbp),%edi
mov    %al,-0x13(%rbp)
mov    $0x8,%esi
call   1080 <i2c_write@plt>
mov    -0x30(%rbp),%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x14(%rbp)
movzbl -0xf(%rbp),%eax
shl    $0x8,%eax
movzbl -0x10(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0xa(%rbp)
movzbl -0x11(%rbp),%eax
shl    $0x8,%eax
movzbl -0x12(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0xc(%rbp)
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm0
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xa4a(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%ax
movswl %ax,%edi
movswl -0xa(%rbp),%esi
call   1050 <atan2@plt>
imul   $0xb4,%eax,%eax
cvtsi2ss %eax,%xmm0
mov    0x29d1(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0xa08(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x1e,%edi
mov    $0x3,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0xf(%rbp)
mov    $0x1e,%edi
mov    $0x4,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x10(%rbp)
mov    $0x1e,%edi
mov    $0x5,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x11(%rbp)
mov    $0x1e,%edi
mov    $0x6,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x12(%rbp)
mov    $0x1e,%edi
mov    $0x7,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x13(%rbp)
mov    $0x1e,%edi
mov    $0x8,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %al,-0x14(%rbp)
movzbl -0xf(%rbp),%eax
shl    $0x8,%eax
movzbl -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0xa(%rbp)
movzbl -0x11(%rbp),%eax
shl    $0x8,%eax
movzbl -0x12(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0xc(%rbp)
movzbl -0x13(%rbp),%eax
shl    $0x8,%eax
movzbl -0x14(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0xe(%rbp)
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    172b <main+0x53b>
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    174a <main+0x55a>
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  -0x20(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    176d <main+0x57d>
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
ucomiss -0x24(%rbp),%xmm0
jbe    178c <main+0x59c>
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movswl -0xe(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  -0x28(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    17af <main+0x5bf>
movswl -0xe(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movswl -0xe(%rbp),%eax
cvtsi2ss %eax,%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    17ce <main+0x5de>
movswl -0xe(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movswl -0xa(%rbp),%eax
cvtsi2ss %eax,%xmm0
movswl -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x850(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%ax
movswl %ax,%edi
movswl -0xa(%rbp),%esi
call   1050 <atan2@plt>
cvtsi2ss %eax,%xmm0
movss  0x804(%rip),%xmm1
mulss  %xmm1,%xmm0
mov    0x27d1(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0x808(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x800(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x7f6(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movss  -0x20(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x7ec(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
jmp    162d <main+0x43d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x49,%edi
call   10d0 <i2c_setup@plt>
test   %rax,%rax
jns    1219 <main+0x29>
lea    0xe00(%rip),%rdi
call   1070 <print@plt>
mov    $0x49,%edi
call   10e0 <i2c_set_slave@plt>
mov    $0x49,%edi
mov    $0x1,%esi
mov    $0x83,%edx
mov    $0x3,%ecx
call   10c0 <i2c_write16@plt>
test   %rax,%rax
jns    124d <main+0x5d>
lea    0xdd6(%rip),%rdi
call   1070 <print@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    $0x49,%edi
xor    %esi,%esi
call   1080 <i2c_write@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd6e(%rip),%xmm0
divsd  0xd6e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xd7e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd33(%rip),%xmm0
divsd  0xd33(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xcff(%rip),%xmm0
divsd  0xcff(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x49,%edi
mov    $0x1,%esi
mov    $0x93,%edx
mov    $0x3,%ecx
call   10c0 <i2c_write16@plt>
test   %rax,%rax
jns    1341 <main+0x151>
lea    0xce2(%rip),%rdi
call   1070 <print@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    $0x49,%edi
xor    %esi,%esi
call   1080 <i2c_write@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc77(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc73(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xc7f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xc34(%rip),%xmm0
divsd  0xc34(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x49,%edi
call   1110 <i2c_read16@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xc00(%rip),%xmm0
divsd  0xc00(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xe,%edi
call   10e0 <i2c_set_slave@plt>
mov    $0xe,%edi
call   1040 <mag3110_config@plt>
mov    $0xe,%edi
call   1090 <mag3110_readx@plt>
cwtl
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
lea    0xbeb(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xe,%edi
call   1030 <mag3110_ready@plt>
cwtl
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xe,%edi
call   10a0 <mag3110_readz@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xe,%edi
call   1030 <mag3110_ready@plt>
mov    %eax,%ebx
mov    $0xe,%edi
call   1090 <mag3110_readx@plt>
movswl %bx,%edi
movswl %ax,%esi
call   1050 <atan2@plt>
imul   $0xb4,%eax,%eax
mov    0x2b35(%rip),%r13
cltd
idivl  0x0(%r13)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x1e,%edi
call   10e0 <i2c_set_slave@plt>
mov    $0x1e,%edi
xor    %esi,%esi
mov    $0x14,%edx
call   10b0 <i2c_write8@plt>
mov    $0x1e,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   10b0 <i2c_write8@plt>
mov    $0x1e,%edi
mov    $0x3,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%ebp
mov    $0x1e,%edi
mov    $0x4,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r14d
mov    $0x1e,%edi
mov    $0x5,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r15d
mov    $0x1e,%edi
mov    $0x6,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%ebx
mov    $0x1e,%edi
mov    $0x7,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    $0x1e,%edi
mov    $0x8,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
movzbl %bpl,%eax
shl    $0x8,%eax
movzbl %r14b,%ecx
or     %eax,%ecx
movzbl %r15b,%eax
shl    $0x8,%eax
movzbl %bl,%edx
movswl %cx,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
or     %eax,%edx
movswl %dx,%ebp
cvtsi2sd %ebp,%xmm1
lea    0xa73(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <atan2@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x0(%r13),%xmm1
divss  %xmm1,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xa65(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1e,%edi
mov    $0x3,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%ebx
mov    $0x1e,%edi
mov    $0x4,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r14d
mov    $0x1e,%edi
mov    $0x5,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r15d
mov    $0x1e,%edi
mov    $0x6,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r12d
mov    $0x1e,%edi
mov    $0x7,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
mov    %eax,%r13d
mov    $0x1e,%edi
mov    $0x8,%esi
call   1080 <i2c_write@plt>
mov    $0x1e,%edi
call   1100 <i2c_read8@plt>
movzbl %bl,%ecx
movzbl %r15b,%edx
shl    $0x8,%edx
or     %ecx,%edx
movd   %edx,%xmm0
xorps  %xmm1,%xmm1
movzbl %r14b,%ecx
movd   %ecx,%xmm2
movzbl %r12b,%ecx
pinsrw $0x1,%ecx,%xmm2
punpcklbw %xmm0,%xmm1
por    %xmm1,%xmm2
movzbl %r13b,%ecx
shl    $0x8,%ecx
movzbl %al,%eax
or     %ecx,%eax
punpcklwd %xmm2,%xmm0
movdqa %xmm2,%xmm5
movdqa %xmm2,0x10(%rsp)
psrad  $0x10,%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm0,%xmm1
unpcklps %xmm0,%xmm1
movaps 0x20(%rsp),%xmm3
movaps %xmm3,%xmm2
shufps $0x48,%xmm0,%xmm2
shufps $0xd8,%xmm2,%xmm2
movaps %xmm0,%xmm4
shufps $0xd4,%xmm3,%xmm4
shufps $0xd8,%xmm4,%xmm4
cmpltps %xmm2,%xmm4
andps  %xmm4,%xmm1
cwtl
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
andnps %xmm3,%xmm4
orps   %xmm1,%xmm4
movaps %xmm4,0x20(%rsp)
pextrw $0x1,%xmm5,%eax
maxss  0xc(%rsp),%xmm2
movss  %xmm2,0xc(%rsp)
movswl %ax,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
lea    0x8da(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movdqa 0x10(%rsp),%xmm0
movd   %xmm0,%eax
movswl %ax,%esi
mov    %ebx,%edi
call   1050 <atan2@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x887(%rip),%xmm0
mov    0x2858(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0x88c(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movdqa 0x20(%rsp),%xmm0
pshufd $0x55,%xmm0,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x883(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movdqa 0x20(%rsp),%xmm2
pshufd $0xff,%xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
pshufd $0xee,%xmm2,%xmm0
movdqa %xmm0,0x10(%rsp)
lea    0x86a(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    %rbp,%rdi
movaps 0x10(%rsp),%xmm0
mov    $0x2,%al
call   1060 <printf@plt>
jmp    1610 <main+0x420>

LLVM IR (-O0):
@.str = [10 x i8] c"err setup\00"
@.str.1 = [5 x i8] c"er r\00"
@.str.2 = [11 x i8] c"value: %f\0A\00"
@.str.3 = [11 x i8] c"Value: %f\0A\00"
@M_PI = global i32 0
@.str.4 = [9 x i8] c"v %f %f\0A\00"
@.str.5 = [18 x i8] c"Mag X Cal %f %f\0A\00"
@.str.6 = [18 x i8] c"Mag Y Cal %f %f\0A\00"
@.str.7 = [18 x i8] c"Mag Z Cal %f %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store i32 0, i32* %1
store i32 73, i32* %2
%18 = load i32, i32* %2
%19 = call i64 @i2c_setup(i32 %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 @print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %0
%24 = load i32, i32* %2
%25 = call i32 @i2c_set_slave(i32 %24)
%26 = load i32, i32* %2
%27 = call i64 @i2c_write16(i32 %26, i32 1, i32 131, i32 3)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %23
%32 = load i32, i32* %2
%33 = call i64 @i2c_read16(i32 %32)
%34 = load i32, i32* %2
%35 = call i64 @i2c_read16(i32 %34)
%36 = call i32 @sleep(i32 1)
%37 = load i32, i32* %2
%38 = call i32 @i2c_write(i32 %37, i32 0)
%39 = load i32, i32* %2
%40 = call i64 @i2c_read16(i32 %39)
%41 = sitofp i64 %40 to float
%42 = fpext float %41 to double
%43 = fmul double %42, 4.096000e+00
%44 = fdiv double %43, 3.276700e+04
%45 = fptrunc double %44 to float
%46 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %45)
%47 = load i32, i32* %2
%48 = call i64 @i2c_read16(i32 %47)
%49 = sitofp i64 %48 to float
%50 = fpext float %49 to double
%51 = fmul double %50, 4.096000e+00
%52 = fdiv double %51, 3.276700e+04
%53 = fptrunc double %52 to float
%54 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %53)
%55 = load i32, i32* %2
%56 = call i64 @i2c_read16(i32 %55)
%57 = sitofp i64 %56 to float
%58 = fpext float %57 to double
%59 = fmul double %58, 4.096000e+00
%60 = fdiv double %59, 3.276700e+04
%61 = fptrunc double %60 to float
%62 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %61)
%63 = load i32, i32* %2
%64 = call i64 @i2c_write16(i32 %63, i32 1, i32 147, i32 3)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %31
%67 = call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %68
68: ; preds = %66, %31
%69 = load i32, i32* %2
%70 = call i64 @i2c_read16(i32 %69)
%71 = load i32, i32* %2
%72 = call i64 @i2c_read16(i32 %71)
%73 = call i32 @sleep(i32 1)
%74 = load i32, i32* %2
%75 = call i32 @i2c_write(i32 %74, i32 0)
%76 = load i32, i32* %2
%77 = call i64 @i2c_read16(i32 %76)
%78 = sitofp i64 %77 to float
%79 = fpext float %78 to double
%80 = fmul double %79, 4.096000e+00
%81 = fdiv double %80, 3.276700e+04
%82 = fptrunc double %81 to float
%83 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %82)
%84 = load i32, i32* %2
%85 = call i64 @i2c_read16(i32 %84)
%86 = sitofp i64 %85 to float
%87 = fpext float %86 to double
%88 = fmul double %87, 4.096000e+00
%89 = fdiv double %88, 3.276700e+04
%90 = fptrunc double %89 to float
%91 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %90)
%92 = load i32, i32* %2
%93 = call i64 @i2c_read16(i32 %92)
%94 = sitofp i64 %93 to float
%95 = fpext float %94 to double
%96 = fmul double %95, 4.096000e+00
%97 = fdiv double %96, 3.276700e+04
%98 = fptrunc double %97 to float
%99 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %98)
%100 = call i32 @i2c_set_slave(i32 14)
%101 = call i32 @mag3110_config(i32 14)
%102 = call signext i16 @mag3110_readx(i32 14)
%103 = sitofp i16 %102 to float
%104 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %103)
%105 = call signext i16 @mag3110_ready(i32 14)
%106 = sitofp i16 %105 to float
%107 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %106)
%108 = call i64 @mag3110_readz(i32 14)
%109 = sitofp i64 %108 to float
%110 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %109)
%111 = call signext i16 @mag3110_ready(i32 14)
%112 = call signext i16 @mag3110_readx(i32 14)
%113 = call i32 @atan2(i16 signext %111, i16 signext %112)
%114 = mul nsw i32 %113, 180
%115 = load i32, i32* @M_PI
%116 = sdiv i32 %114, %115
%117 = sitofp i32 %116 to float
%118 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %117)
%119 = call i32 @i2c_set_slave(i32 30)
%120 = call i32 @i2c_write8(i32 30, i32 0, i32 20)
%121 = call i32 @i2c_write8(i32 30, i32 2, i32 0)
%122 = call i32 @i2c_write(i32 30, i32 3)
%123 = call zeroext i8 @i2c_read8(i32 30)
store i8 %123, i8* %6
%124 = call i32 @i2c_write(i32 30, i32 4)
%125 = call zeroext i8 @i2c_read8(i32 30)
store i8 %125, i8* %7
%126 = call i32 @i2c_write(i32 30, i32 5)
%127 = call zeroext i8 @i2c_read8(i32 30)
store i8 %127, i8* %8
%128 = call i32 @i2c_write(i32 30, i32 6)
%129 = call zeroext i8 @i2c_read8(i32 30)
store i8 %129, i8* %9
%130 = call i32 @i2c_write(i32 30, i32 7)
%131 = call zeroext i8 @i2c_read8(i32 30)
store i8 %131, i8* %10
%132 = call i32 @i2c_write(i32 30, i32 8)
%133 = call zeroext i8 @i2c_read8(i32 30)
store i8 %133, i8* %11
%134 = load i8, i8* %6
%135 = zext i8 %134 to i32
%136 = shl i32 %135, 8
%137 = load i8, i8* %7
%138 = zext i8 %137 to i32
%139 = add nsw i32 %136, %138
%140 = trunc i32 %139 to i16
store i16 %140, i16* %3
%141 = load i8, i8* %8
%142 = zext i8 %141 to i32
%143 = shl i32 %142, 8
%144 = load i8, i8* %9
%145 = zext i8 %144 to i32
%146 = add nsw i32 %143, %145
%147 = trunc i32 %146 to i16
store i16 %147, i16* %4
%148 = load i16, i16* %3
%149 = sitofp i16 %148 to float
%150 = load i16, i16* %4
%151 = sitofp i16 %150 to float
%152 = fpext float %151 to double
%153 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), float %149, double %152)
%154 = load i16, i16* %4
%155 = load i16, i16* %3
%156 = call i32 @atan2(i16 signext %154, i16 signext %155)
%157 = mul nsw i32 %156, 180
%158 = sitofp i32 %157 to float
%159 = load i32, i32* @M_PI
%160 = sitofp i32 %159 to float
%161 = fdiv float %158, %160
%162 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %161)
br label %163
163: ; preds = %68, %250
%164 = call i32 @i2c_write(i32 30, i32 3)
%165 = call zeroext i8 @i2c_read8(i32 30)
store i8 %165, i8* %6
%166 = call i32 @i2c_write(i32 30, i32 4)
%167 = call zeroext i8 @i2c_read8(i32 30)
store i8 %167, i8* %7
%168 = call i32 @i2c_write(i32 30, i32 5)
%169 = call zeroext i8 @i2c_read8(i32 30)
store i8 %169, i8* %8
%170 = call i32 @i2c_write(i32 30, i32 6)
%171 = call zeroext i8 @i2c_read8(i32 30)
store i8 %171, i8* %9
%172 = call i32 @i2c_write(i32 30, i32 7)
%173 = call zeroext i8 @i2c_read8(i32 30)
store i8 %173, i8* %10
%174 = call i32 @i2c_write(i32 30, i32 8)
%175 = call zeroext i8 @i2c_read8(i32 30)
store i8 %175, i8* %11
%176 = load i8, i8* %6
%177 = zext i8 %176 to i32
%178 = shl i32 %177, 8
%179 = load i8, i8* %7
%180 = zext i8 %179 to i32
%181 = add nsw i32 %178, %180
%182 = trunc i32 %181 to i16
store i16 %182, i16* %3
%183 = load i8, i8* %8
%184 = zext i8 %183 to i32
%185 = shl i32 %184, 8
%186 = load i8, i8* %9
%187 = zext i8 %186 to i32
%188 = add nsw i32 %185, %187
%189 = trunc i32 %188 to i16
store i16 %189, i16* %4
%190 = load i8, i8* %10
%191 = zext i8 %190 to i32
%192 = shl i32 %191, 8
%193 = load i8, i8* %11
%194 = zext i8 %193 to i32
%195 = add nsw i32 %192, %194
%196 = trunc i32 %195 to i16
store i16 %196, i16* %5
%197 = load i16, i16* %3
%198 = sext i16 %197 to i32
%199 = sitofp i32 %198 to float
%200 = load float, float* %12
%201 = fcmp olt float %199, %200
br i1 %201, label %202, label %205
202: ; preds = %163
%203 = load i16, i16* %3
%204 = sitofp i16 %203 to float
store float %204, float* %12
br label %205
205: ; preds = %202, %163
%206 = load i16, i16* %3
%207 = sext i16 %206 to i32
%208 = sitofp i32 %207 to float
%209 = load float, float* %13
%210 = fcmp ogt float %208, %209
br i1 %210, label %211, label %214
211: ; preds = %205
%212 = load i16, i16* %3
%213 = sitofp i16 %212 to float
store float %213, float* %13
br label %214
214: ; preds = %211, %205
%215 = load i16, i16* %4
%216 = sext i16 %215 to i32
%217 = sitofp i32 %216 to float
%218 = load float, float* %14
%219 = fcmp olt float %217, %218
br i1 %219, label %220, label %223
220: ; preds = %214
%221 = load i16, i16* %4
%222 = sitofp i16 %221 to float
store float %222, float* %14
br label %223
223: ; preds = %220, %214
%224 = load i16, i16* %4
%225 = sext i16 %224 to i32
%226 = sitofp i32 %225 to float
%227 = load float, float* %15
%228 = fcmp ogt float %226, %227
br i1 %228, label %229, label %232
229: ; preds = %223
%230 = load i16, i16* %4
%231 = sitofp i16 %230 to float
store float %231, float* %15
br label %232
232: ; preds = %229, %223
%233 = load i16, i16* %5
%234 = sext i16 %233 to i32
%235 = sitofp i32 %234 to float
%236 = load float, float* %16
%237 = fcmp olt float %235, %236
br i1 %237, label %238, label %241
238: ; preds = %232
%239 = load i16, i16* %5
%240 = sitofp i16 %239 to float
store float %240, float* %16
br label %241
241: ; preds = %238, %232
%242 = load i16, i16* %5
%243 = sext i16 %242 to i32
%244 = sitofp i32 %243 to float
%245 = load float, float* %17
%246 = fcmp ogt float %244, %245
br i1 %246, label %247, label %250
247: ; preds = %241
%248 = load i16, i16* %5
%249 = sitofp i16 %248 to float
store float %249, float* %17
br label %250
250: ; preds = %247, %241
%251 = load i16, i16* %3
%252 = sitofp i16 %251 to float
%253 = load i16, i16* %4
%254 = sitofp i16 %253 to float
%255 = fpext float %254 to double
%256 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), float %252, double %255)
%257 = load i16, i16* %4
%258 = load i16, i16* %3
%259 = call i32 @atan2(i16 signext %257, i16 signext %258)
%260 = sitofp i32 %259 to float
%261 = fmul float %260, 1.800000e+02
%262 = load i32, i32* @M_PI
%263 = sitofp i32 %262 to float
%264 = fdiv float %261, %263
%265 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %264)
%266 = load float, float* %12
%267 = load float, float* %13
%268 = fpext float %267 to double
%269 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), float %266, double %268)
%270 = load float, float* %14
%271 = load float, float* %15
%272 = fpext float %271 to double
%273 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), float %270, double %272)
%274 = load float, float* %14
%275 = load float, float* %17
%276 = fpext float %275 to double
%277 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), float %274, double %276)
br label %163
}

LLVM IR (-O2):
@.str = [10 x i8] c"err setup\00"
@.str.1 = [5 x i8] c"er r\00"
@.str.2 = [11 x i8] c"value: %f\0A\00"
@.str.3 = [11 x i8] c"Value: %f\0A\00"
@M_PI = global i32 0
@.str.4 = [9 x i8] c"v %f %f\0A\00"
@.str.5 = [18 x i8] c"Mag X Cal %f %f\0A\00"
@.str.6 = [18 x i8] c"Mag Y Cal %f %f\0A\00"
@.str.7 = [18 x i8] c"Mag Z Cal %f %f\0A\00"
define i32 @main() {
%1 = tail call i64 @i2c_setup(i32 73)
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @i2c_set_slave(i32 73)
%7 = tail call i64 @i2c_write16(i32 73, i32 1, i32 131, i32 3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = tail call i64 @i2c_read16(i32 73)
%13 = tail call i64 @i2c_read16(i32 73)
%14 = tail call i32 @sleep(i32 1)
%15 = tail call i32 @i2c_write(i32 73, i32 0)
%16 = tail call i64 @i2c_read16(i32 73)
%17 = sitofp i64 %16 to float
%18 = fpext float %17 to double
%19 = fmul double %18, 4.096000e+00
%20 = fdiv double %19, 3.276700e+04
%21 = fptrunc double %20 to float
%22 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %21)
%23 = tail call i64 @i2c_read16(i32 73)
%24 = sitofp i64 %23 to float
%25 = fpext float %24 to double
%26 = fmul double %25, 4.096000e+00
%27 = fdiv double %26, 3.276700e+04
%28 = fptrunc double %27 to float
%29 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %28)
%30 = tail call i64 @i2c_read16(i32 73)
%31 = sitofp i64 %30 to float
%32 = fpext float %31 to double
%33 = fmul double %32, 4.096000e+00
%34 = fdiv double %33, 3.276700e+04
%35 = fptrunc double %34 to float
%36 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %35)
%37 = tail call i64 @i2c_write16(i32 73, i32 1, i32 147, i32 3)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %11
%40 = tail call i32 @print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %11
%42 = tail call i64 @i2c_read16(i32 73)
%43 = tail call i64 @i2c_read16(i32 73)
%44 = tail call i32 @sleep(i32 1)
%45 = tail call i32 @i2c_write(i32 73, i32 0)
%46 = tail call i64 @i2c_read16(i32 73)
%47 = sitofp i64 %46 to float
%48 = fpext float %47 to double
%49 = fmul double %48, 4.096000e+00
%50 = fdiv double %49, 3.276700e+04
%51 = fptrunc double %50 to float
%52 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %51)
%53 = tail call i64 @i2c_read16(i32 73)
%54 = sitofp i64 %53 to float
%55 = fpext float %54 to double
%56 = fmul double %55, 4.096000e+00
%57 = fdiv double %56, 3.276700e+04
%58 = fptrunc double %57 to float
%59 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %58)
%60 = tail call i64 @i2c_read16(i32 73)
%61 = sitofp i64 %60 to float
%62 = fpext float %61 to double
%63 = fmul double %62, 4.096000e+00
%64 = fdiv double %63, 3.276700e+04
%65 = fptrunc double %64 to float
%66 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %65)
%67 = tail call i32 @i2c_set_slave(i32 14)
%68 = tail call i32 @mag3110_config(i32 14)
%69 = tail call signext i16 @mag3110_readx(i32 14)
%70 = sitofp i16 %69 to float
%71 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %70)
%72 = tail call signext i16 @mag3110_ready(i32 14)
%73 = sitofp i16 %72 to float
%74 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %73)
%75 = tail call i64 @mag3110_readz(i32 14)
%76 = sitofp i64 %75 to float
%77 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %76)
%78 = tail call signext i16 @mag3110_ready(i32 14)
%79 = tail call signext i16 @mag3110_readx(i32 14)
%80 = tail call i32 @atan2(i16 signext %78, i16 signext %79)
%81 = mul nsw i32 %80, 180
%82 = load i32, i32* @M_PI
%83 = sdiv i32 %81, %82
%84 = sitofp i32 %83 to float
%85 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %84)
%86 = tail call i32 @i2c_set_slave(i32 30)
%87 = tail call i32 @i2c_write8(i32 30, i32 0, i32 20)
%88 = tail call i32 @i2c_write8(i32 30, i32 2, i32 0)
%89 = tail call i32 @i2c_write(i32 30, i32 3)
%90 = tail call zeroext i8 @i2c_read8(i32 30)
%91 = tail call i32 @i2c_write(i32 30, i32 4)
%92 = tail call zeroext i8 @i2c_read8(i32 30)
%93 = tail call i32 @i2c_write(i32 30, i32 5)
%94 = tail call zeroext i8 @i2c_read8(i32 30)
%95 = tail call i32 @i2c_write(i32 30, i32 6)
%96 = tail call zeroext i8 @i2c_read8(i32 30)
%97 = tail call i32 @i2c_write(i32 30, i32 7)
%98 = tail call zeroext i8 @i2c_read8(i32 30)
%99 = tail call i32 @i2c_write(i32 30, i32 8)
%100 = tail call zeroext i8 @i2c_read8(i32 30)
%101 = zext i8 %90 to i16
%102 = shl nuw i16 %101, 8
%103 = zext i8 %92 to i16
%104 = or i16 %102, %103
%105 = zext i8 %94 to i16
%106 = shl nuw i16 %105, 8
%107 = zext i8 %96 to i16
%108 = or i16 %106, %107
%109 = sitofp i16 %104 to float
%110 = sitofp i16 %108 to double
%111 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), float %109, double %110)
%112 = tail call i32 @atan2(i16 signext %108, i16 signext %104)
%113 = mul nsw i32 %112, 180
%114 = sitofp i32 %113 to float
%115 = load i32, i32* @M_PI
%116 = sitofp i32 %115 to float
%117 = fdiv float %114, %116
%118 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %117)
br label %119
119: ; preds = %119, %41
%120 = phi float [ undef, %41 ], [ %158, %119 ]
%121 = phi <4 x float> [ poison, %41 ], [ %155, %119 ]
%122 = tail call i32 @i2c_write(i32 30, i32 3)
%123 = tail call zeroext i8 @i2c_read8(i32 30)
%124 = tail call i32 @i2c_write(i32 30, i32 4)
%125 = tail call zeroext i8 @i2c_read8(i32 30)
%126 = tail call i32 @i2c_write(i32 30, i32 5)
%127 = tail call zeroext i8 @i2c_read8(i32 30)
%128 = tail call i32 @i2c_write(i32 30, i32 6)
%129 = tail call zeroext i8 @i2c_read8(i32 30)
%130 = tail call i32 @i2c_write(i32 30, i32 7)
%131 = tail call zeroext i8 @i2c_read8(i32 30)
%132 = tail call i32 @i2c_write(i32 30, i32 8)
%133 = tail call zeroext i8 @i2c_read8(i32 30)
%134 = insertelement <2 x i8> poison, i8 %123, i64 0
%135 = insertelement <2 x i8> %134, i8 %127, i64 1
%136 = zext <2 x i8> %135 to <2 x i16>
%137 = shl nuw <2 x i16> %136, <i16 8, i16 8>
%138 = insertelement <2 x i8> poison, i8 %125, i64 0
%139 = insertelement <2 x i8> %138, i8 %129, i64 1
%140 = zext <2 x i8> %139 to <2 x i16>
%141 = or <2 x i16> %137, %140
%142 = zext i8 %131 to i16
%143 = shl nuw i16 %142, 8
%144 = zext i8 %133 to i16
%145 = or i16 %143, %144
%146 = sitofp <2 x i16> %141 to <2 x float>
%147 = shufflevector <2 x float> %146, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%148 = shufflevector <2 x float> %146, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%149 = shufflevector <2 x float> %146, <2 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
%150 = extractelement <2 x float> %146, i64 0
%151 = shufflevector <4 x float> %121, <4 x float> %148, <4 x i32> <i32 0, i32 4, i32 2, i32 5>
%152 = shufflevector <4 x float> %121, <4 x float> %147, <4 x i32> <i32 4, i32 1, i32 5, i32 undef>
%153 = shufflevector <4 x float> %152, <4 x float> %121, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
%154 = fcmp ogt <4 x float> %151, %153
%155 = select <4 x i1> %154, <4 x float> %149, <4 x float> %121
%156 = sitofp i16 %145 to float
%157 = fcmp olt float %120, %156
%158 = select i1 %157, float %156, float %120
%159 = extractelement <2 x i16> %141, i64 1
%160 = sitofp i16 %159 to double
%161 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), float %150, double %160)
%162 = extractelement <2 x i16> %141, i64 0
%163 = tail call i32 @atan2(i16 signext %159, i16 signext %162)
%164 = sitofp i32 %163 to float
%165 = fmul float %164, 1.800000e+02
%166 = load i32, i32* @M_PI
%167 = sitofp i32 %166 to float
%168 = fdiv float %165, %167
%169 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %168)
%170 = extractelement <4 x float> %155, i64 1
%171 = fpext float %170 to double
%172 = extractelement <4 x float> %155, i64 0
%173 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), float %172, double %171)
%174 = extractelement <4 x float> %155, i64 3
%175 = fpext float %174 to double
%176 = extractelement <4 x float> %155, i64 2
%177 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), float %176, double %175)
%178 = fpext float %158 to double
%179 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), float %176, double %178)
br label %119
}