#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 */
struct termios {
  int c_cflag;
  scalar_t__ *c_cc;
  scalar_t__ c_oflag;
  scalar_t__ c_lflag;
  scalar_t__ c_iflag;
};

/* Variables and functions */
int /*<<< orphan*/ B115200;
int CREAD;
int CS8;
int O_NDELAY;
int O_NOCTTY;
int O_RDWR;
unsigned char ReceiveHeader(int);
scalar_t__ ReceiveULong(int);
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ TransmitCommand(char *, int);
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ WaitForReception(int);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  struct termios if_mode;
  char *robovero_dev;
  int serial_if;
  int error;
  if (argc < 2) {
    printf("Syntax is: robocomm [device file]\n"
           "Example: robocomm /dev/ttyACM0\n");
    return -1;
  }
  robovero_dev = argv[1];
  serial_if = open(robovero_dev, O_RDWR | O_NOCTTY | O_NDELAY);
  if (serial_if == -1) {
    printf("Couldn't open device file: %s\n", robovero_dev);
    return -1;
  }
  tcgetattr(serial_if, &if_mode);
  if_mode.c_cflag = CS8 | CREAD;
  if_mode.c_iflag = 0;
  if_mode.c_lflag = 0;
  if_mode.c_oflag = 0;
  if_mode.c_cc[VMIN] = 0;
  if_mode.c_cc[VTIME] = 0;
  cfsetispeed(&if_mode, B115200);
  cfsetospeed(&if_mode, B115200);
  error = tcsetattr(serial_if, TCSANOW, &if_mode);
  if (error != 0) {
    printf("Error setting serial attributes\n");
    return -1;
  }
  TransmitCommand("\n", serial_if);
  TransmitCommand("promptOff\n", serial_if);
  TransmitCommand("resetConfig\n", serial_if);
  TransmitCommand("roboveroConfig\n", serial_if);
  WaitForReception(512);
  tcflush(serial_if, TCIFLUSH);
  TransmitCommand("configAccel 1 1 1 1 32 4\n", serial_if);
  TransmitCommand("configMag 1 0 96 19\n", serial_if);
  TransmitCommand("configGyro 1 1 1 1  64 fa\n", serial_if);
  while (1) {
    double x_axis;
    double y_axis;
    double z_axis;
    unsigned char header;
    TransmitCommand("readAccel\n", serial_if);
    header = ReceiveHeader(serial_if);
    x_axis = ((double)ReceiveULong(serial_if) - 32768.0) / (double)(32768 / 4);
    y_axis = ((double)ReceiveULong(serial_if) - 32768.0) / (double)(32768 / 4);
    z_axis = ((double)ReceiveULong(serial_if) - 32768.0) / (double)(32768 / 4);
    printf("Accel:%c\t%.3f\t%.3f\t%.3f\n", header, x_axis, y_axis, z_axis);
    TransmitCommand("readMag\n", serial_if);
    header = ReceiveHeader(serial_if);
    x_axis = ((double)ReceiveULong(serial_if) - 4096) / (double)(4096 / 0x19);
    y_axis = ((double)ReceiveULong(serial_if) - 4096) / (double)(4096 / 0x19);
    z_axis = ((double)ReceiveULong(serial_if) - 4096) / (double)(4096 / 0x19);
    printf("Mag:%c\t%.3f\t%.3f\t%.3f\n", header, x_axis, y_axis, z_axis);
    TransmitCommand("readGyro\n", serial_if);
    header = ReceiveHeader(serial_if);
    x_axis = ((double)ReceiveULong(serial_if) - 32768) / (double)(32768 / 0xFA);
    y_axis = ((double)ReceiveULong(serial_if) - 32768) / (double)(32768 / 0xFA);
    z_axis = ((double)ReceiveULong(serial_if) - 32768) / (double)(32768 / 0xFA);
    printf("Gyro:%c\t%.3f\t%.3f\t%.3f\n", header, x_axis, y_axis, z_axis);
    usleep(100000);
  }
  printf("Test complete\n");
  TransmitCommand("resetConfig\n", serial_if);
  TransmitCommand("roboveroConfig\n", serial_if);
  WaitForReception(512);
  tcflush(serial_if, TCIFLUSH);
  close(serial_if);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11fd <main+0x3d>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1662 <main+0x4a2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
mov    0x2d93(%rip),%rax
or     (%rax),%esi
mov    0x2d82(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1258 <main+0x98>
mov    -0x40(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1662 <main+0x4a2>
mov    -0x44(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1080 <tcgetattr@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    0x2d64(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2d2c(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    0x2ce6(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdi
call   10b0 <cfsetispeed@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdi
call   1040 <cfsetospeed@plt>
mov    -0x44(%rbp),%edi
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1090 <tcsetattr@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     131d <main+0x15d>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1662 <main+0x4a2>
mov    -0x44(%rbp),%esi
lea    0xd41(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd74(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd70(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd6e(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    $0x200,%edi
call   10c0 <WaitForReception@plt>
mov    -0x44(%rbp),%edi
mov    0x2c4b(%rip),%rax
mov    (%rax),%esi
call   1050 <tcflush@plt>
mov    -0x44(%rbp),%esi
lea    0xd54(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd5f(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd65(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%esi
lea    0xd71(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%edi
call   1070 <ReceiveHeader@plt>
mov    %al,-0x61(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xc38(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  0xc3c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  %xmm0,-0x50(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xbfe(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  0xc02(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xbc4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  0xbc8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  %xmm0,-0x60(%rbp)
movzbl -0x61(%rbp),%esi
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
lea    0xca4(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xcac(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%edi
call   1070 <ReceiveHeader@plt>
mov    %al,-0x61(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xb5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  0xb43(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  %xmm0,-0x50(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xb25(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  0xb09(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xaeb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  0xacf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  %xmm0,-0x60(%rbp)
movzbl -0x61(%rbp),%esi
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
lea    0xbdd(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xbe3(%rip),%rdi
call   1030 <TransmitCommand@plt>
mov    -0x44(%rbp),%edi
call   1070 <ReceiveHeader@plt>
mov    %al,-0x61(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xa66(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xa4a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  %xmm0,-0x50(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0xa2c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xa10(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%edi
call   10d0 <ReceiveULong@plt>
cvtsi2sd %rax,%xmm0
movsd  0x9f5(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0x9dc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  %xmm0,-0x60(%rbp)
movzbl -0x61(%rbp),%esi
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
lea    0xb1e(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    $0x186a0,%edi
call   10e0 <usleep@plt>
jmp    13a1 <main+0x1e1>
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jg     11ef <main+0x1f>
lea    0xf55(%rip),%rdi
jmp    12bd <main+0xed>
mov    0x2df2(%rip),%rcx
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x8(%rsi),%rbp
mov    0x2d9c(%rip),%rcx
or     (%rcx),%eax
mov    %rbp,%rdi
mov    %eax,%esi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     12c4 <main+0xf4>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1090 <tcgetattr@plt>
mov    0x2d97(%rip),%rax
mov    0x2d98(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
mov    0x18(%rsp),%rax
mov    0x2d63(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d21(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d17(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   10c0 <cfsetispeed@plt>
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   1050 <cfsetospeed@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   10a0 <tcsetattr@plt>
test   %eax,%eax
je     12e9 <main+0x119>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
jmp    12d5 <main+0x105>
lea    0xd5d(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd97(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd49(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd46(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd45(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
mov    $0x200,%edi
call   10d0 <WaitForReception@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <tcflush@plt>
lea    0xd2d(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd39(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd40(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
lea    0xd71(%rip),%r12
lea    0xd73(%rip),%r13
lea    0xd83(%rip),%rbp
lea    0xd86(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd22(%rip),%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
mov    %ebx,%edi
call   1080 <ReceiveHeader@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0xc41(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xc3d(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xc14(%rip),%xmm0
mulsd  0xc14(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
addsd  0xbf0(%rip),%xmm2
mulsd  0xbf0(%rip),%xmm2
movzbl %r15b,%esi
lea    0xca1(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x3,%al
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
mov    %ebx,%edi
call   1080 <ReceiveHeader@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0xbb0(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xbac(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xb83(%rip),%xmm0
divsd  0xb83(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
addsd  0xb5f(%rip),%xmm2
divsd  0xb5f(%rip),%xmm2
movzbl %r15b,%esi
mov    %r13,%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x3,%al
call   1070 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <TransmitCommand@plt>
mov    %ebx,%edi
call   1080 <ReceiveHeader@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  0xb03(%rip),%xmm1
movsd  0xb1b(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xada(%rip),%xmm0
divsd  0xaf2(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   10e0 <ReceiveULong@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
addsd  0xab6(%rip),%xmm2
divsd  0xace(%rip),%xmm2
movzbl %r15b,%esi
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x3,%al
call   1070 <printf@plt>
mov    $0x186a0,%edi
call   10f0 <usleep@plt>
jmp    1390 <main+0x1c0>

LLVM IR (-O0):
%struct.termios = type { i32, i64*, i64, i64, i64 }
@.str = [66 x i8] c"Syntax is: robocomm [device file]\0AExample: robocomm /dev/ttyACM0\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@.str.1 = [31 x i8] c"Couldn't open device file: %s\0A\00"
@CS8 = global i32 0
@CREAD = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
@.str.2 = [33 x i8] c"Error setting serial attributes\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [11 x i8] c"promptOff\0A\00"
@.str.5 = [13 x i8] c"resetConfig\0A\00"
@.str.6 = [16 x i8] c"roboveroConfig\0A\00"
@TCIFLUSH = global i32 0
@.str.7 = [26 x i8] c"configAccel 1 1 1 1 32 4\0A\00"
@.str.8 = [21 x i8] c"configMag 1 0 96 19\0A\00"
@.str.9 = [27 x i8] c"configGyro 1 1 1 1 64 fa\0A\00"
@.str.10 = [11 x i8] c"readAccel\0A\00"
@.str.11 = [25 x i8] c"Accel:%c\09%.3f\09%.3f\09%.3f\0A\00"
@.str.12 = [9 x i8] c"readMag\0A\00"
@.str.13 = [23 x i8] c"Mag:%c\09%.3f\09%.3f\09%.3f\0A\00"
@.str.14 = [10 x i8] c"readGyro\0A\00"
@.str.15 = [24 x i8] c"Gyro:%c\09%.3f\09%.3f\09%.3f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.termios
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %159
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = load i32, i32* @O_RDWR
%24 = load i32, i32* @O_NOCTTY
%25 = or i32 %23, %24
%26 = load i32, i32* @O_NDELAY
%27 = or i32 %25, %26
%28 = call i32 @open(i8* %22, i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %18
%32 = load i8*, i8** %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 -1, i32* %3
br label %159
34: ; preds = %18
%35 = load i32, i32* %8
%36 = call i32 @tcgetattr(i32 %35, %struct.termios* %6)
%37 = load i32, i32* @CS8
%38 = load i32, i32* @CREAD
%39 = or i32 %37, %38
%40 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
store i32 %39, i32* %40
%41 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 4
store i64 0, i64* %41
%42 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
store i64 0, i64* %42
%43 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
store i64 0, i64* %43
%44 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%45 = load i64*, i64** %44
%46 = load i64, i64* @VMIN
%47 = getelementptr inbounds i64, i64* %45, i64 %46
store i64 0, i64* %47
%48 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%49 = load i64*, i64** %48
%50 = load i64, i64* @VTIME
%51 = getelementptr inbounds i64, i64* %49, i64 %50
store i64 0, i64* %51
%52 = load i32, i32* @B115200
%53 = call i32 @cfsetispeed(%struct.termios* %6, i32 %52)
%54 = load i32, i32* @B115200
%55 = call i32 @cfsetospeed(%struct.termios* %6, i32 %54)
%56 = load i32, i32* %8
%57 = load i32, i32* @TCSANOW
%58 = call i32 @tcsetattr(i32 %56, i32 %57, %struct.termios* %6)
store i32 %58, i32* %9
%59 = load i32, i32* %9
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %34
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %159
63: ; preds = %34
%64 = load i32, i32* %8
%65 = call i32 @TransmitCommand(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %8
%67 = call i32 @TransmitCommand(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %8
%69 = call i32 @TransmitCommand(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %8
%71 = call i32 @TransmitCommand(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %70)
%72 = call i32 @WaitForReception(i32 512)
%73 = load i32, i32* %8
%74 = load i32, i32* @TCIFLUSH
%75 = call i32 @tcflush(i32 %73, i32 %74)
%76 = load i32, i32* %8
%77 = call i32 @TransmitCommand(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %76)
%78 = load i32, i32* %8
%79 = call i32 @TransmitCommand(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %8
%81 = call i32 @TransmitCommand(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %63, %82
%83 = load i32, i32* %8
%84 = call i32 @TransmitCommand(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %8
%86 = call zeroext i8 @ReceiveHeader(i32 %85)
store i8 %86, i8* %13
%87 = load i32, i32* %8
%88 = call i64 @ReceiveULong(i32 %87)
%89 = sitofp i64 %88 to double
%90 = fsub double %89, 3.276800e+04
%91 = fdiv double %90, 8.192000e+03
store double %91, double* %10
%92 = load i32, i32* %8
%93 = call i64 @ReceiveULong(i32 %92)
%94 = sitofp i64 %93 to double
%95 = fsub double %94, 3.276800e+04
%96 = fdiv double %95, 8.192000e+03
store double %96, double* %11
%97 = load i32, i32* %8
%98 = call i64 @ReceiveULong(i32 %97)
%99 = sitofp i64 %98 to double
%100 = fsub double %99, 3.276800e+04
%101 = fdiv double %100, 8.192000e+03
store double %101, double* %12
%102 = load i8, i8* %13
%103 = zext i8 %102 to i32
%104 = load double, double* %10
%105 = load double, double* %11
%106 = load double, double* %12
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %103, double %104, double %105, double %106)
%108 = load i32, i32* %8
%109 = call i32 @TransmitCommand(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %108)
%110 = load i32, i32* %8
%111 = call zeroext i8 @ReceiveHeader(i32 %110)
store i8 %111, i8* %13
%112 = load i32, i32* %8
%113 = call i64 @ReceiveULong(i32 %112)
%114 = sitofp i64 %113 to double
%115 = fsub double %114, 4.096000e+03
%116 = fdiv double %115, 1.630000e+02
store double %116, double* %10
%117 = load i32, i32* %8
%118 = call i64 @ReceiveULong(i32 %117)
%119 = sitofp i64 %118 to double
%120 = fsub double %119, 4.096000e+03
%121 = fdiv double %120, 1.630000e+02
store double %121, double* %11
%122 = load i32, i32* %8
%123 = call i64 @ReceiveULong(i32 %122)
%124 = sitofp i64 %123 to double
%125 = fsub double %124, 4.096000e+03
%126 = fdiv double %125, 1.630000e+02
store double %126, double* %12
%127 = load i8, i8* %13
%128 = zext i8 %127 to i32
%129 = load double, double* %10
%130 = load double, double* %11
%131 = load double, double* %12
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %128, double %129, double %130, double %131)
%133 = load i32, i32* %8
%134 = call i32 @TransmitCommand(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %133)
%135 = load i32, i32* %8
%136 = call zeroext i8 @ReceiveHeader(i32 %135)
store i8 %136, i8* %13
%137 = load i32, i32* %8
%138 = call i64 @ReceiveULong(i32 %137)
%139 = sitofp i64 %138 to double
%140 = fsub double %139, 3.276800e+04
%141 = fdiv double %140, 1.310000e+02
store double %141, double* %10
%142 = load i32, i32* %8
%143 = call i64 @ReceiveULong(i32 %142)
%144 = sitofp i64 %143 to double
%145 = fsub double %144, 3.276800e+04
%146 = fdiv double %145, 1.310000e+02
store double %146, double* %11
%147 = load i32, i32* %8
%148 = call i64 @ReceiveULong(i32 %147)
%149 = sitofp i64 %148 to double
%150 = fsub double %149, 3.276800e+04
%151 = fdiv double %150, 1.310000e+02
store double %151, double* %12
%152 = load i8, i8* %13
%153 = zext i8 %152 to i32
%154 = load double, double* %10
%155 = load double, double* %11
%156 = load double, double* %12
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %153, double %154, double %155, double %156)
%158 = call i32 @usleep(i32 100000)
br label %82
159: ; preds = %61, %31, %16
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
%struct.termios = type { i32, i64*, i64, i64, i64 }
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@.str.1 = [31 x i8] c"Couldn't open device file: %s\0A\00"
@CS8 = global i32 0
@CREAD = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [11 x i8] c"promptOff\0A\00"
@.str.5 = [13 x i8] c"resetConfig\0A\00"
@.str.6 = [16 x i8] c"roboveroConfig\0A\00"
@TCIFLUSH = global i32 0
@.str.7 = [26 x i8] c"configAccel 1 1 1 1 32 4\0A\00"
@.str.8 = [21 x i8] c"configMag 1 0 96 19\0A\00"
@.str.9 = [27 x i8] c"configGyro 1 1 1 1 64 fa\0A\00"
@.str.10 = [11 x i8] c"readAccel\0A\00"
@.str.11 = [25 x i8] c"Accel:%c\09%.3f\09%.3f\09%.3f\0A\00"
@.str.12 = [9 x i8] c"readMag\0A\00"
@.str.13 = [23 x i8] c"Mag:%c\09%.3f\09%.3f\09%.3f\0A\00"
@.str.14 = [10 x i8] c"readGyro\0A\00"
@.str.15 = [24 x i8] c"Gyro:%c\09%.3f\09%.3f\09%.3f\0A\00"
@str = [32 x i8] c"Error setting serial attributes\00"
@str.16 = [65 x i8] c"Syntax is: robocomm [device file]\0AExample: robocomm /dev/ttyACM0\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.16, i64 0, i64 0))
br label %104
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_RDWR
%12 = load i32, i32* @O_NOCTTY
%13 = or i32 %12, %11
%14 = load i32, i32* @O_NDELAY
%15 = or i32 %13, %14
%16 = tail call i32 @open(i8* %10, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %104
20: ; preds = %8
%21 = call i32 @tcgetattr(i32 %16, %struct.termios* %3)
%22 = load i32, i32* @CS8
%23 = load i32, i32* @CREAD
%24 = or i32 %23, %22
%25 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%27 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%28 = bitcast i64* %26 to i8*
%29 = load i64*, i64** %27
%30 = load i64, i64* @VMIN
%31 = getelementptr inbounds i64, i64* %29, i64 %30
store i64 0, i64* %31
%32 = load i64, i64* @VTIME
%33 = getelementptr inbounds i64, i64* %29, i64 %32
store i64 0, i64* %33
%34 = load i32, i32* @B115200
%35 = call i32 @cfsetispeed(%struct.termios* %3, i32 %34)
%36 = load i32, i32* @B115200
%37 = call i32 @cfsetospeed(%struct.termios* %3, i32 %36)
%38 = load i32, i32* @TCSANOW
%39 = call i32 @tcsetattr(i32 %16, i32 %38, %struct.termios* %3)
%40 = icmp eq i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %20
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %104
43: ; preds = %20
%44 = call i32 @TransmitCommand(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%45 = call i32 @TransmitCommand(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%46 = call i32 @TransmitCommand(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%47 = call i32 @TransmitCommand(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %16)
%48 = call i32 @WaitForReception(i32 512)
%49 = load i32, i32* @TCIFLUSH
%50 = call i32 @tcflush(i32 %16, i32 %49)
%51 = call i32 @TransmitCommand(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %16)
%52 = call i32 @TransmitCommand(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %16)
%53 = call i32 @TransmitCommand(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %16)
br label %54
54: ; preds = %54, %43
%55 = call i32 @TransmitCommand(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %16)
%56 = call zeroext i8 @ReceiveHeader(i32 %16)
%57 = call i64 @ReceiveULong(i32 %16)
%58 = sitofp i64 %57 to double
%59 = fadd double %58, -3.276800e+04
%60 = fmul double %59, 0x3F20000000000000
%61 = call i64 @ReceiveULong(i32 %16)
%62 = sitofp i64 %61 to double
%63 = fadd double %62, -3.276800e+04
%64 = fmul double %63, 0x3F20000000000000
%65 = call i64 @ReceiveULong(i32 %16)
%66 = sitofp i64 %65 to double
%67 = fadd double %66, -3.276800e+04
%68 = fmul double %67, 0x3F20000000000000
%69 = zext i8 %56 to i32
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %69, double %60, double %64, double %68)
%71 = call i32 @TransmitCommand(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %16)
%72 = call zeroext i8 @ReceiveHeader(i32 %16)
%73 = call i64 @ReceiveULong(i32 %16)
%74 = sitofp i64 %73 to double
%75 = fadd double %74, -4.096000e+03
%76 = fdiv double %75, 1.630000e+02
%77 = call i64 @ReceiveULong(i32 %16)
%78 = sitofp i64 %77 to double
%79 = fadd double %78, -4.096000e+03
%80 = fdiv double %79, 1.630000e+02
%81 = call i64 @ReceiveULong(i32 %16)
%82 = sitofp i64 %81 to double
%83 = fadd double %82, -4.096000e+03
%84 = fdiv double %83, 1.630000e+02
%85 = zext i8 %72 to i32
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %85, double %76, double %80, double %84)
%87 = call i32 @TransmitCommand(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %16)
%88 = call zeroext i8 @ReceiveHeader(i32 %16)
%89 = call i64 @ReceiveULong(i32 %16)
%90 = sitofp i64 %89 to double
%91 = fadd double %90, -3.276800e+04
%92 = fdiv double %91, 1.310000e+02
%93 = call i64 @ReceiveULong(i32 %16)
%94 = sitofp i64 %93 to double
%95 = fadd double %94, -3.276800e+04
%96 = fdiv double %95, 1.310000e+02
%97 = call i64 @ReceiveULong(i32 %16)
%98 = sitofp i64 %97 to double
%99 = fadd double %98, -3.276800e+04
%100 = fdiv double %99, 1.310000e+02
%101 = zext i8 %88 to i32
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %101, double %92, double %96, double %100)
%103 = call i32 @usleep(i32 100000)
br label %54
104: ; preds = %41, %18, %6
ret i32 -1
}