#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 gyro_init();
scalar_t__ gyro_overrun();
int /*<<< orphan*/ gyro_read(int *, int *, int *);
scalar_t__ gyro_ready();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int success = gyro_init();
  if (!success) {
    return 1;
  }
  int dx, dy, dz;
  int count = 0;
  while (1) {
    if (gyro_ready()) {
      gyro_read(&dx, &dy, &dz);
      count++;
      if (1) {
        printf("%8d %8d %8d %s\n", dx, dy, dz, gyro_overrun() ? "overrun" : "");
      } else {
        if (gyro_overrun()) {
          printf("overrun (%d)\n", count);
        }
      }
      if (count > 200 && 0) {
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <gyro_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    117f <main+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    122c <main+0xdc>
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1070 <gyro_ready@plt>
cmp    $0x0,%rax
je     1220 <main+0xd0>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <gyro_read@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <gyro_overrun@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    %rax,%rdi
lea    0xe32(%rip),%r8
lea    0xe2c(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%r8
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0xc8,-0x18(%rbp)
jle    121b <main+0xcb>
xor    %eax,%eax
test   $0x1,%al
jne    1216 <main+0xc6>
jmp    121b <main+0xcb>
jmp    1225 <main+0xd5>
jmp    1220 <main+0xd0>
jmp    1186 <main+0x36>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <gyro_init@plt>
test   %eax,%eax
je     11d1 <main+0x81>
lea    0xe9f(%rip),%r15
lea    0xe99(%rip),%r12
lea    0xe82(%rip),%r13
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <gyro_ready@plt>
test   %rax,%rax
je     1180 <main+0x30>
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <gyro_read@plt>
mov    0x14(%rsp),%ebp
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%r14d
xor    %eax,%eax
call   1050 <gyro_overrun@plt>
test   %rax,%rax
mov    %r12,%r8
cmove  %r15,%r8
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1180 <main+0x30>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%8d %8d %8d %s\0A\00"
@.str.1 = [8 x i8] c"overrun\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @gyro_init()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %0
store i32 1, i32* %1
br label %34
11: ; preds = %0
store i32 0, i32* %6
br label %12
12: ; preds = %11, %32
%13 = call i64 (...) @gyro_ready()
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = call i32 @gyro_read(i32* %3, i32* %4, i32* %5)
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i64 (...) @gyro_overrun()
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20, i32 %21, i8* %25)
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 200
br i1 %28, label %29, label %31
29: ; preds = %15
br i1 false, label %30, label %31
30: ; preds = %29
br label %33
31: ; preds = %29, %15
br label %32
32: ; preds = %31, %12
br label %12
33: ; preds = %30
store i32 0, i32* %1
br label %34
34: ; preds = %33, %10
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [16 x i8] c"%8d %8d %8d %s\0A\00"
@.str.1 = [8 x i8] c"overrun\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 (...) @gyro_init()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
ret i32 1
7: ; preds = %0
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
br label %11
11: ; preds = %23, %7
%12 = call i64 (...) @gyro_ready()
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = call i32 @gyro_read(i32* %1, i32* %2, i32* %3)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i64 (...) @gyro_overrun()
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i32 %18, i8* %21)
br label %23
23: ; preds = %14, %11
br label %11
}