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

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ uint64_t;
struct timespec {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_ADDRCONFIG;
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ SOCK_DGRAM;
double accel_diff(float *, float *);
float accel_mag();
float accel_x();
float accel_y();
float accel_z();
float batt();
scalar_t__ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ close_sensors();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char const *, char const *, struct addrinfo *,
                       struct addrinfo **);
float gyro_x();
float gyro_y();
float gyro_z();
float light();
float mag_x();
float mag_y();
float mag_z();
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ open_sensors();
int /*<<< orphan*/ perror(char *);
int pressure();
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, scalar_t__);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
float temp();
scalar_t__ to_nanos(struct timespec);
int main(int argc, char **argv) {
  const char *hostname = 0;
  const char *portname = "9750";
  if (argc >= 2)
    hostname = argv[1];
  if (argc >= 3)
    portname = argv[2];
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_protocol = 0;
  hints.ai_flags = AI_ADDRCONFIG;
  struct addrinfo *res = 0;
  if (getaddrinfo(hostname, portname, &hints, &res) != 0) {
    perror("Could not resolve remote socket address");
    exit(1);
  }
  int sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if (sock < 0) {
    perror("Could not create socket");
    exit(1);
  }
  char buffer[60] = {0};
  unsigned char state = 0x00;
  open_sensors();
  struct timespec start, current;
  if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) {
    perror("Could not read clock");
    exit(1);
  }
  float current_accel_vec[3] = {0.0};
  float prev_accel_vec[3] = {0.0};
  unsigned int land_timeout = 0;
  while (1) {
    if (clock_gettime(CLOCK_MONOTONIC, &current) < 0) {
      perror("Could not read clock");
      exit(1);
    }
    uint64_t nanos = to_nanos(current) - to_nanos(start);
    *(uint64_t *)&buffer[0] = nanos;
    *(float *)&buffer[8] = gyro_x();
    *(float *)&buffer[12] = gyro_y();
    *(float *)&buffer[16] = gyro_z();
    *(float *)&buffer[20] = accel_x();
    *(float *)&buffer[24] = accel_y();
    *(float *)&buffer[28] = accel_z();
    *(float *)&buffer[32] = mag_x();
    *(float *)&buffer[36] = mag_y();
    *(float *)&buffer[40] = mag_z();
    *(float *)&buffer[44] = pressure();
    *(float *)&buffer[48] = temp();
    *(float *)&buffer[52] = light();
    *(float *)&buffer[56] = batt();
    current_accel_vec[0] = accel_x();
    current_accel_vec[1] = accel_y();
    current_accel_vec[2] = accel_z();
    float accel = accel_mag();
    printf("Pressure: %.3f ", pressure());
    printf("Accel Mag: %.3f ", accel);
    printf("Accel Diff: %.3f ", accel_diff(current_accel_vec, prev_accel_vec));
    printf("State: %d\n", state);
    fflush(stdout);
    switch (state) {
    case 0x00:
      if (pressure() > 100) {
        state = 0x01;
      }
      break;
    case 0x01:
      if (pressure() < 100 || accel > 14.0) {
        state = 0x02;
      }
      break;
    case 0x02:
      printf("land_timeout: %d\n", land_timeout);
      if (pressure() > 101 &&
          accel_diff(current_accel_vec, prev_accel_vec) < 0.2) {
        if (land_timeout++ > 10) {
          state = 0x03;
          system("/root/lander2017/lander/sensors/turn_servo.sh");
        }
      } else {
        land_timeout = 0;
      }
      break;
    case 0x03:
      if (sendto(sock, buffer, sizeof(buffer), 0, res->ai_addr,
                 res->ai_addrlen) < 0) {
        perror("Could not send sensor datagram");
      }
      break;
    default:
      state = 0x00;
    }
    prev_accel_vec[0] = current_accel_vec[0];
    prev_accel_vec[1] = current_accel_vec[1];
    prev_accel_vec[2] = current_accel_vec[2];
    sleep(1);
  }
  close_sensors();
  freeaddrinfo(res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xd38(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1302 <main+0x42>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1318 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2c9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2c69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1170 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1391 <main+0xd1>
lea    0xca3(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rdx
call   11e0 <socket@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    13cf <main+0x10f>
lea    0xc8d(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x3c,%edx
call   1070 <memset@plt>
movb   $0x0,-0x91(%rbp)
mov    $0x0,%al
call   10b0 <open_sensors@plt>
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
lea    -0x98(%rbp),%rsi
call   1040 <clock_gettime@plt>
cmp    $0x0,%rax
jge    1425 <main+0x165>
lea    0xc4f(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    -0xac(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
movl   $0x0,-0xbc(%rbp)
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rsi
call   1040 <clock_gettime@plt>
cmp    $0x0,%rax
jge    148a <main+0x1ca>
lea    0xbea(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0xa0(%rbp),%edi
call   11d0 <to_nanos@plt>
mov    %rax,-0xe8(%rbp)
mov    -0x98(%rbp),%edi
call   11d0 <to_nanos@plt>
mov    %rax,%rcx
mov    -0xe8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0xc8(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,-0x90(%rbp)
xor    %eax,%eax
mov    %al,-0xd9(%rbp)
call   1140 <gyro_x@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x88(%rbp)
ff
call   10a0 <gyro_y@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x84(%rbp)
ff
call   1160 <gyro_z@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x80(%rbp)
call   11a0 <accel_x@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x7c(%rbp)
call   10c0 <accel_y@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x78(%rbp)
call   1180 <accel_z@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x74(%rbp)
call   1090 <mag_x@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x70(%rbp)
call   10e0 <mag_y@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x6c(%rbp)
call   11c0 <mag_z@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x68(%rbp)
call   1190 <pressure@plt>
mov    %eax,%ecx
mov    -0xd9(%rbp),%al
cvtsi2ss %ecx,%xmm0
movss  %xmm0,-0x64(%rbp)
call   1120 <temp@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x60(%rbp)
call   1110 <light@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x5c(%rbp)
call   1030 <batt@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0x58(%rbp)
call   11a0 <accel_x@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0xac(%rbp)
ff
call   10c0 <accel_y@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0xa8(%rbp)
ff
call   1180 <accel_z@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0xa4(%rbp)
ff
call   1100 <accel_mag@plt>
mov    -0xd9(%rbp),%al
movss  %xmm0,-0xcc(%rbp)
ff
call   1190 <pressure@plt>
mov    %eax,%esi
lea    0xa73(%rip),%rdi
call   1060 <printf@plt>
cvttss2si -0xcc(%rbp),%rax
ff ff
mov    %eax,%esi
lea    0xa6c(%rip),%rdi
call   1060 <printf@plt>
lea    -0xac(%rbp),%rdi
lea    -0xb8(%rbp),%rsi
call   10d0 <accel_diff@plt>
cvttsd2si %xmm0,%rax
mov    %eax,%esi
lea    0xa57(%rip),%rdi
call   1060 <printf@plt>
movzbl -0x91(%rbp),%esi
lea    0xa56(%rip),%rdi
call   1060 <printf@plt>
mov    0x2965(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
movzbl -0x91(%rbp),%eax
mov    %rax,-0xd8(%rbp)
sub    $0x3,%rax
ja     17b9 <main+0x4f9>
mov    -0xd8(%rbp),%rax
lea    0x980(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1190 <pressure@plt>
cmp    $0x64,%eax
jle    16b0 <main+0x3f0>
movb   $0x1,-0x91(%rbp)
jmp    17c0 <main+0x500>
mov    $0x0,%al
call   1190 <pressure@plt>
cmp    $0x64,%eax
jl     16e3 <main+0x423>
movss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0x92f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    16ea <main+0x42a>
movb   $0x2,-0x91(%rbp)
jmp    17c0 <main+0x500>
mov    -0xbc(%rbp),%esi
lea    0x9bc(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1190 <pressure@plt>
cmp    $0x65,%eax
jle    176b <main+0x4ab>
lea    -0xac(%rbp),%rdi
lea    -0xb8(%rbp),%rsi
call   10d0 <accel_diff@plt>
movaps %xmm0,%xmm1
movsd  0x8d1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    176b <main+0x4ab>
mov    -0xbc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xbc(%rbp)
cmp    $0xa,%eax
jbe    1766 <main+0x4a6>
movb   $0x3,-0x91(%rbp)
lea    0x969(%rip),%rdi
call   1050 <system@plt>
jmp    1775 <main+0x4b5>
movl   $0x0,-0xbc(%rbp)
jmp    17c0 <main+0x500>
mov    -0x4c(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9d
mov    $0x3c,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
cmp    $0x0,%eax
jge    17b4 <main+0x4f4>
lea    0x949(%rip),%rdi
call   1130 <perror@plt>
jmp    17c0 <main+0x500>
movb   $0x0,-0x91(%rbp)
movss  -0xac(%rbp),%xmm0
ff
movss  %xmm0,-0xb8(%rbp)
ff
movss  -0xa8(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
movss  -0xa4(%rbp),%xmm0
ff
movss  %xmm0,-0xb0(%rbp)
ff
mov    $0x1,%edi
call   11b0 <sleep@plt>
jmp    1455 <main+0x195>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
lea    0xd44(%rip),%rbx
cmp    $0x2,%edi
jl     12e9 <main+0x29>
mov    0x8(%rsi),%r14
je     12ec <main+0x2c>
mov    0x10(%rsi),%rbx
jmp    12ec <main+0x2c>
xor    %r14d,%r14d
lea    0x88(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x9c(%rsp)
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x98(%rsp)
movq   $0x0,0x90(%rsp)
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xa0(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1170 <getaddrinfo@plt>
test   %rax,%rax
jne    1385 <main+0xc5>
mov    0x20(%rsp),%rax
mov    0x14(%rax),%edi
mov    0x10(%rax),%esi
mov    0x8(%rax),%rdx
call   11e0 <socket@plt>
mov    %eax,0x2c(%rsp)
test   %eax,%eax
jns    138e <main+0xce>
lea    0xcc6(%rip),%rdi
jmp    13ff <main+0x13f>
lea    0xc95(%rip),%rdi
jmp    13ff <main+0x13f>
xorps  %xmm0,%xmm0
movups %xmm0,0x6c(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
xor    %eax,%eax
call   10b0 <open_sensors@plt>
mov    0x2c2d(%rip),%r14
mov    (%r14),%edi
lea    0x18(%rsp),%rsi
call   1040 <clock_gettime@plt>
test   %rax,%rax
js     13f8 <main+0x138>
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
movl   $0x0,0x38(%rsp)
movq   $0x0,0x30(%rsp)
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
test   %rax,%rax
jns    140e <main+0x14e>
lea    0xc62(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    0x30(%rsp),%r12
lea    0xbf2(%rip),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1485 <main+0x1c5>
xor    %eax,%eax
call   1190 <pressure@plt>
cmp    $0x64,%eax
setl   %al
movss  0x14(%rsp),%xmm0
ucomiss 0xbce(%rip),%xmm0
seta   %bl
or     %al,%bl
add    $0x1,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  (%rsp),%xmm0
movss  %xmm0,0x30(%rsp)
mov    0x4(%rsp),%rax
mov    %rax,0x34(%rsp)
mov    $0x1,%edi
call   11b0 <sleep@plt>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
test   %rax,%rax
js     13f8 <main+0x138>
mov    %ebx,%r13d
mov    0x10(%rsp),%edi
call   11d0 <to_nanos@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%edi
call   11d0 <to_nanos@plt>
sub    %rax,%rbx
mov    %rbx,0x40(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1140 <gyro_x@plt>
movss  %xmm0,0x48(%rsp)
xor    %eax,%eax
call   10a0 <gyro_y@plt>
movss  %xmm0,0x4c(%rsp)
xor    %eax,%eax
call   1160 <gyro_z@plt>
movss  %xmm0,0x50(%rsp)
xor    %eax,%eax
call   11a0 <accel_x@plt>
movss  %xmm0,0x54(%rsp)
xor    %eax,%eax
call   10c0 <accel_y@plt>
movss  %xmm0,0x58(%rsp)
xor    %eax,%eax
call   1180 <accel_z@plt>
movss  %xmm0,0x5c(%rsp)
xor    %eax,%eax
call   1090 <mag_x@plt>
movss  %xmm0,0x60(%rsp)
xor    %eax,%eax
call   10e0 <mag_y@plt>
movss  %xmm0,0x64(%rsp)
xor    %eax,%eax
call   11c0 <mag_z@plt>
movss  %xmm0,0x68(%rsp)
xor    %eax,%eax
call   1190 <pressure@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x6c(%rsp)
xor    %eax,%eax
call   1120 <temp@plt>
movss  %xmm0,0x70(%rsp)
xor    %eax,%eax
call   1110 <light@plt>
movss  %xmm0,0x74(%rsp)
xor    %eax,%eax
call   1030 <batt@plt>
movss  %xmm0,0x78(%rsp)
xor    %eax,%eax
call   11a0 <accel_x@plt>
movss  %xmm0,(%rsp)
xor    %eax,%eax
call   10c0 <accel_y@plt>
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1180 <accel_z@plt>
movss  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1100 <accel_mag@plt>
movss  %xmm0,0x14(%rsp)
xor    %eax,%eax
call   1190 <pressure@plt>
lea    0xade(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
cvttss2si 0x14(%rsp),%rsi
lea    0xad9(%rip),%rdi
call   1060 <printf@plt>
mov    %rsp,%rdi
mov    %r12,%rsi
call   10d0 <accel_diff@plt>
cvttsd2si %xmm0,%rsi
lea    0xace(%rip),%rdi
call   1060 <printf@plt>
movzbl %r13b,%r13d
lea    0xad0(%rip),%rdi
mov    %r13d,%esi
call   1060 <printf@plt>
mov    0x29e0(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
cmp    $0x3,%r13b
ja     1450 <main+0x190>
movslq (%r15,%r13,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1190 <pressure@plt>
cmp    $0x65,%eax
setge  %bl
jmp    1450 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xa8d(%rip),%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
xor    %eax,%eax
call   1190 <pressure@plt>
mov    $0x2,%bl
cmp    $0x66,%eax
jl     16bc <main+0x3fc>
mov    %rsp,%rdi
mov    %r12,%rsi
call   10d0 <accel_diff@plt>
movsd  0x9ad(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    16bc <main+0x3fc>
mov    %rbp,%rax
add    $0x1,%ebp
cmp    $0xb,%eax
jb     16c3 <main+0x403>
lea    0xa5b(%rip),%rdi
call   1050 <system@plt>
mov    $0x3,%bl
jmp    1450 <main+0x190>
nopw   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rax
mov    (%rax),%r9d
mov    0x4(%rax),%r8d
mov    0x2c(%rsp),%edi
lea    0x40(%rsp),%rsi
mov    $0x3c,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
mov    $0x3,%bl
test   %eax,%eax
jns    1450 <main+0x190>
lea    0xa42(%rip),%rdi
call   1130 <perror@plt>
jmp    1450 <main+0x190>
xor    %ebp,%ebp
jmp    1450 <main+0x190>
jmp    1450 <main+0x190>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i64, i32, i32, i32 }
%struct.timespec = type { i32 }
@.str = [5 x i8] c"9750\00"
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [40 x i8] c"Could not resolve remote socket address\00"
@.str.2 = [24 x i8] c"Could not create socket\00"
@CLOCK_MONOTONIC = global i32 0
@.str.3 = [21 x i8] c"Could not read clock\00"
@.str.4 = [16 x i8] c"Pressure: %.3f \00"
@.str.5 = [17 x i8] c"Accel Mag: %.3f \00"
@.str.6 = [18 x i8] c"Accel Diff: %.3f \00"
@.str.7 = [11 x i8] c"State: %d\0A\00"
@stdout = global i32 0
@.str.8 = [18 x i8] c"land_timeout: %d\0A\00"
@.str.9 = [46 x i8] c"/root/lander2017/lander/sensors/turn_servo.sh\00"
@.str.10 = [31 x i8] c"Could not send sensor datagram\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca [60 x i8]
%12 = alloca i8
%13 = alloca %struct.timespec
%14 = alloca %struct.timespec
%15 = alloca [3 x float]
%16 = alloca [3 x float]
%17 = alloca i32
%18 = alloca i64
%19 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %7
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 2
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %6
br label %26
26: ; preds = %22, %2
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 3
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
store i8* %32, i8** %7
br label %33
33: ; preds = %29, %26
%34 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 32)
%35 = load i32, i32* @AF_UNSPEC
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %35, i32* %36
%37 = load i32, i32* @SOCK_DGRAM
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %37, i32* %38
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 2
store i64 0, i64* %39
%40 = load i32, i32* @AI_ADDRCONFIG
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %40, i32* %41
store %struct.addrinfo* null, %struct.addrinfo** %9
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = call i64 @getaddrinfo(i8* %42, i8* %43, %struct.addrinfo* %8, %struct.addrinfo** %9)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %33
%47 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %33
%50 = load %struct.addrinfo*, %struct.addrinfo** %9
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 4
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %9
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 3
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 2
%58 = load i64, i64* %57
%59 = call i32 @socket(i32 %52, i32 %55, i64 %58)
store i32 %59, i32* %10
%60 = load i32, i32* %10
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %49
%63 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %49
%66 = bitcast [60 x i8]* %11 to i8*
store i8 0, i8* %12
%67 = call i32 (...) @open_sensors()
%68 = load i32, i32* @CLOCK_MONOTONIC
%69 = call i64 @clock_gettime(i32 %68, %struct.timespec* %13)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %65
%72 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %65
%75 = bitcast [3 x float]* %15 to i8*
%76 = bitcast [3 x float]* %16 to i8*
store i32 0, i32* %17
br label %77
77: ; preds = %74, %207
%78 = load i32, i32* @CLOCK_MONOTONIC
%79 = call i64 @clock_gettime(i32 %78, %struct.timespec* %14)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %77
%85 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
%86 = load i32, i32* %85
%87 = call i64 @to_nanos(i32 %86)
%88 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%89 = load i32, i32* %88
%90 = call i64 @to_nanos(i32 %89)
%91 = sub nsw i64 %87, %90
store i64 %91, i64* %18
%92 = load i64, i64* %18
%93 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 0
%94 = bitcast i8* %93 to i64*
store i64 %92, i64* %94
%95 = call float (...) @gyro_x()
%96 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 8
%97 = bitcast i8* %96 to float*
store float %95, float* %97
%98 = call float (...) @gyro_y()
%99 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 12
%100 = bitcast i8* %99 to float*
store float %98, float* %100
%101 = call float (...) @gyro_z()
%102 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 16
%103 = bitcast i8* %102 to float*
store float %101, float* %103
%104 = call float (...) @accel_x()
%105 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 20
%106 = bitcast i8* %105 to float*
store float %104, float* %106
%107 = call float (...) @accel_y()
%108 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 24
%109 = bitcast i8* %108 to float*
store float %107, float* %109
%110 = call float (...) @accel_z()
%111 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 28
%112 = bitcast i8* %111 to float*
store float %110, float* %112
%113 = call float (...) @mag_x()
%114 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 32
%115 = bitcast i8* %114 to float*
store float %113, float* %115
%116 = call float (...) @mag_y()
%117 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 36
%118 = bitcast i8* %117 to float*
store float %116, float* %118
%119 = call float (...) @mag_z()
%120 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 40
%121 = bitcast i8* %120 to float*
store float %119, float* %121
%122 = call i32 (...) @pressure()
%123 = sitofp i32 %122 to float
%124 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 44
%125 = bitcast i8* %124 to float*
store float %123, float* %125
%126 = call float (...) @temp()
%127 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 48
%128 = bitcast i8* %127 to float*
store float %126, float* %128
%129 = call float (...) @light()
%130 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 52
%131 = bitcast i8* %130 to float*
store float %129, float* %131
%132 = call float (...) @batt()
%133 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 56
%134 = bitcast i8* %133 to float*
store float %132, float* %134
%135 = call float (...) @accel_x()
%136 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
store float %135, float* %136
%137 = call float (...) @accel_y()
%138 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
store float %137, float* %138
%139 = call float (...) @accel_z()
%140 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
store float %139, float* %140
%141 = call float (...) @accel_mag()
store float %141, float* %19
%142 = call i32 (...) @pressure()
%143 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %142)
%144 = load float, float* %19
%145 = fptoui float %144 to i32
%146 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %145)
%147 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%148 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%149 = call double @accel_diff(float* %147, float* %148)
%150 = fptoui double %149 to i32
%151 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %150)
%152 = load i8, i8* %12
%153 = zext i8 %152 to i32
%154 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %153)
%155 = load i32, i32* @stdout
%156 = call i32 @fflush(i32 %155)
%157 = load i8, i8* %12
%158 = zext i8 %157 to i32
switch i32 %158, label %206 [
i32 0, label %159
i32 1, label %164
i32 2, label %173
i32 3, label %192
]
159: ; preds = %84
%160 = call i32 (...) @pressure()
%161 = icmp sgt i32 %160, 100
br i1 %161, label %162, label %163
162: ; preds = %159
store i8 1, i8* %12
br label %163
163: ; preds = %162, %159
br label %207
164: ; preds = %84
%165 = call i32 (...) @pressure()
%166 = icmp slt i32 %165, 100
br i1 %166, label %171, label %167
167: ; preds = %164
%168 = load float, float* %19
%169 = fpext float %168 to double
%170 = fcmp ogt double %169, 1.400000e+01
br i1 %170, label %171, label %172
171: ; preds = %167, %164
store i8 2, i8* %12
br label %172
172: ; preds = %171, %167
br label %207
173: ; preds = %84
%174 = load i32, i32* %17
%175 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %174)
%176 = call i32 (...) @pressure()
%177 = icmp sgt i32 %176, 101
br i1 %177, label %178, label %190
178: ; preds = %173
%179 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%180 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%181 = call double @accel_diff(float* %179, float* %180)
%182 = fcmp olt double %181, 2.000000e-01
br i1 %182, label %183, label %190
183: ; preds = %178
%184 = load i32, i32* %17
%185 = add i32 %184, 1
store i32 %185, i32* %17
%186 = icmp ugt i32 %184, 10
br i1 %186, label %187, label %189
187: ; preds = %183
store i8 3, i8* %12
%188 = call i32 @system(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
br label %189
189: ; preds = %187, %183
br label %191
190: ; preds = %178, %173
store i32 0, i32* %17
br label %191
191: ; preds = %190, %189
br label %207
192: ; preds = %84
%193 = load i32, i32* %10
%194 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 0
%195 = load %struct.addrinfo*, %struct.addrinfo** %9
%196 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %195, i32 0, i32 1
%197 = load i32, i32* %196
%198 = load %struct.addrinfo*, %struct.addrinfo** %9
%199 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %198, i32 0, i32 0
%200 = load i32, i32* %199
%201 = call i32 @sendto(i32 %193, i8* %194, i32 60, i32 0, i32 %197, i32 %200)
%202 = icmp slt i32 %201, 0
br i1 %202, label %203, label %205
203: ; preds = %192
%204 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %205
205: ; preds = %203, %192
br label %207
206: ; preds = %84
store i8 0, i8* %12
br label %207
207: ; preds = %206, %205, %191, %172, %163
%208 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%209 = load float, float* %208
%210 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
store float %209, float* %210
%211 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%212 = load float, float* %211
%213 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
store float %212, float* %213
%214 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%215 = load float, float* %214
%216 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
store float %215, float* %216
%217 = call i32 @sleep(i32 1)
br label %77
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i64, i32, i32, i32 }
%struct.timespec = type { i32 }
@.str = [5 x i8] c"9750\00"
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_ADDRCONFIG = global i32 0
@.str.1 = [40 x i8] c"Could not resolve remote socket address\00"
@.str.2 = [24 x i8] c"Could not create socket\00"
@CLOCK_MONOTONIC = global i32 0
@.str.3 = [21 x i8] c"Could not read clock\00"
@.str.4 = [16 x i8] c"Pressure: %.3f \00"
@.str.5 = [17 x i8] c"Accel Mag: %.3f \00"
@.str.6 = [18 x i8] c"Accel Diff: %.3f \00"
@.str.7 = [11 x i8] c"State: %d\0A\00"
@stdout = global i32 0
@.str.8 = [18 x i8] c"land_timeout: %d\0A\00"
@.str.9 = [46 x i8] c"/root/lander2017/lander/sensors/turn_servo.sh\00"
@.str.10 = [31 x i8] c"Could not send sensor datagram\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [60 x i8]
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = icmp eq i32 %0, 2
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
br label %18
18: ; preds = %2, %15, %11
%19 = phi i8* [ %13, %15 ], [ %13, %11 ], [ null, %2 ]
%20 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
%21 = bitcast %struct.addrinfo* %3 to i8*
%22 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_DGRAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i64 0, i64* %27
%28 = load i32, i32* @AI_ADDRCONFIG
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %28, i32* %29
%30 = bitcast %struct.addrinfo** %4 to i8*
store %struct.addrinfo* null, %struct.addrinfo** %4
%31 = call i64 @getaddrinfo(i8* %19, i8* %20, %struct.addrinfo* %3, %struct.addrinfo** %4)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %18
%34 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %18
%37 = load %struct.addrinfo*, %struct.addrinfo** %4
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 4
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 3
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 2
%43 = load i64, i64* %42
%44 = call i32 @socket(i32 %39, i32 %41, i64 %43)
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %36
%47 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %36
%50 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%51 = call i32 (...) @open_sensors()
%52 = bitcast %struct.timespec* %6 to i8*
%53 = bitcast %struct.timespec* %7 to i8*
%54 = load i32, i32* @CLOCK_MONOTONIC
%55 = call i64 @clock_gettime(i32 %54, %struct.timespec* %6)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %49
%58 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %49
%61 = bitcast [3 x float]* %8 to i8*
%62 = bitcast [3 x float]* %9 to i8*
%63 = load i32, i32* @CLOCK_MONOTONIC
%64 = call i64 @clock_gettime(i32 %63, %struct.timespec* %7)
%65 = icmp slt i64 %64, 0
br i1 %65, label %102, label %66
66: ; preds = %60
%67 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 0
%68 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%69 = bitcast [60 x i8]* %5 to i64*
%70 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 8
%71 = bitcast i8* %70 to float*
%72 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 12
%73 = bitcast i8* %72 to float*
%74 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 16
%75 = bitcast i8* %74 to float*
%76 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 20
%77 = bitcast i8* %76 to float*
%78 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 24
%79 = bitcast i8* %78 to float*
%80 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 28
%81 = bitcast i8* %80 to float*
%82 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 32
%83 = bitcast i8* %82 to float*
%84 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 36
%85 = bitcast i8* %84 to float*
%86 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 40
%87 = bitcast i8* %86 to float*
%88 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 44
%89 = bitcast i8* %88 to float*
%90 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 48
%91 = bitcast i8* %90 to float*
%92 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 52
%93 = bitcast i8* %92 to float*
%94 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 56
%95 = bitcast i8* %94 to float*
%96 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%97 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
%98 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 2
%99 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%100 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%101 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
br label %105
102: ; preds = %174, %60
%103 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %66, %174
%106 = phi i32 [ 0, %66 ], [ %176, %174 ]
%107 = phi i8 [ 0, %66 ], [ %175, %174 ]
%108 = load i32, i32* %67
%109 = call i64 @to_nanos(i32 %108)
%110 = load i32, i32* %68
%111 = call i64 @to_nanos(i32 %110)
%112 = sub nsw i64 %109, %111
store i64 %112, i64* %69
%113 = call float (...) @gyro_x()
store float %113, float* %71
%114 = call float (...) @gyro_y()
store float %114, float* %73
%115 = call float (...) @gyro_z()
store float %115, float* %75
%116 = call float (...) @accel_x()
store float %116, float* %77
%117 = call float (...) @accel_y()
store float %117, float* %79
%118 = call float (...) @accel_z()
store float %118, float* %81
%119 = call float (...) @mag_x()
store float %119, float* %83
%120 = call float (...) @mag_y()
store float %120, float* %85
%121 = call float (...) @mag_z()
store float %121, float* %87
%122 = call i32 (...) @pressure()
%123 = sitofp i32 %122 to float
store float %123, float* %89
%124 = call float (...) @temp()
store float %124, float* %91
%125 = call float (...) @light()
store float %125, float* %93
%126 = call float (...) @batt()
store float %126, float* %95
%127 = call float (...) @accel_x()
store float %127, float* %96
%128 = call float (...) @accel_y()
store float %128, float* %97
%129 = call float (...) @accel_z()
store float %129, float* %98
%130 = call float (...) @accel_mag()
%131 = call i32 (...) @pressure()
%132 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %131)
%133 = fptoui float %130 to i32
%134 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %133)
%135 = call double @accel_diff(float* %96, float* %99)
%136 = fptoui double %135 to i32
%137 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %136)
%138 = zext i8 %107 to i32
%139 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %138)
%140 = load i32, i32* @stdout
%141 = call i32 @fflush(i32 %140)
switch i8 %107, label %174 [
i8 0, label %142
i8 1, label %146
i8 2, label %152
i8 3, label %164
]
142: ; preds = %105
%143 = call i32 (...) @pressure()
%144 = icmp sgt i32 %143, 100
%145 = zext i1 %144 to i8
br label %174
146: ; preds = %105
%147 = call i32 (...) @pressure()
%148 = icmp slt i32 %147, 100
%149 = fcmp ogt float %130, 1.400000e+01
%150 = select i1 %148, i1 true, i1 %149
%151 = select i1 %150, i8 2, i8 1
br label %174
152: ; preds = %105
%153 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %106)
%154 = call i32 (...) @pressure()
%155 = icmp sgt i32 %154, 101
br i1 %155, label %156, label %174
156: ; preds = %152
%157 = call double @accel_diff(float* %96, float* %99)
%158 = fcmp olt double %157, 2.000000e-01
br i1 %158, label %159, label %174
159: ; preds = %156
%160 = add i32 %106, 1
%161 = icmp ugt i32 %106, 10
br i1 %161, label %162, label %174
162: ; preds = %159
%163 = call i32 @system(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
br label %174
164: ; preds = %105
%165 = load %struct.addrinfo*, %struct.addrinfo** %4
%166 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %165, i64 0, i32 1
%167 = load i32, i32* %166
%168 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %165, i64 0, i32 0
%169 = load i32, i32* %168
%170 = call i32 @sendto(i32 %44, i8* %50, i32 60, i32 0, i32 %167, i32 %169)
%171 = icmp slt i32 %170, 0
br i1 %171, label %172, label %174
172: ; preds = %164
%173 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %174
174: ; preds = %146, %142, %105, %152, %156, %164, %172, %162, %159
%175 = phi i8 [ 3, %172 ], [ 3, %164 ], [ 3, %162 ], [ 2, %159 ], [ %145, %142 ], [ 2, %156 ], [ 2, %152 ], [ 0, %105 ], [ %151, %146 ]
%176 = phi i32 [ %106, %172 ], [ %106, %164 ], [ %160, %162 ], [ %160, %159 ], [ %106, %142 ], [ 0, %156 ], [ 0, %152 ], [ %106, %105 ], [ %106, %146 ]
%177 = load float, float* %96
store float %177, float* %99
%178 = load float, float* %97
store float %178, float* %100
%179 = load float, float* %98
store float %179, float* %101
%180 = call i32 @sleep(i32 1)
%181 = load i32, i32* @CLOCK_MONOTONIC
%182 = call i64 @clock_gettime(i32 %181, %struct.timespec* %7)
%183 = icmp slt i64 %182, 0
br i1 %183, label %102, label %105
}