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

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ aria_init(int, char **);
int /*<<< orphan*/ arrobot_connect();
int /*<<< orphan*/ arrobot_disconnect();
double arrobot_getbatteryvoltage();
double arrobot_getleftvel();
int arrobot_getnumsonar();
double arrobot_getrightvel();
double arrobot_getrotvel();
double arrobot_getsonarrange(int);
double arrobot_getth();
double arrobot_getvel();
double arrobot_getx();
double arrobot_gety();
int arrobot_isstalled();
double arrobot_length();
double arrobot_radius();
int /*<<< orphan*/ arrobot_setrotvel(int);
int /*<<< orphan*/ arrobot_setvel(int);
double arrobot_width();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  aria_init(argc, argv);
  while (1) {
    if (!arrobot_connect())
      return 1;
    printf("radius=%.2f, length=%.2fmm, width=%.2fmm\n", arrobot_radius(),
           arrobot_length(), arrobot_width());
    arrobot_setvel(200);
    arrobot_setrotvel(10);
    for (int c = 0; c < 10; ++c) {
      arrobot_connect();
      printf("x=%.1f y=%.1f th=%.1f vel=%.1f rotvel=%.1f left=%.1f right=%.1f "
             "stall=%d battv=%.1f\n",
             arrobot_getx(), arrobot_gety(), arrobot_getth(), arrobot_getvel(),
             arrobot_getrotvel(), arrobot_getleftvel(), arrobot_getrightvel(),
             arrobot_isstalled(), arrobot_getbatteryvoltage());
      printf("sonar");
      for (int i = 0; i < arrobot_getnumsonar(); ++i) {
        printf(" %d=%f", i, arrobot_getsonarrange(i));
      }
      puts("");
      sleep(1);
    }
    arrobot_disconnect();
    puts("disconnected, reconnecting in 5 sec...");
    sleep(5);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1110 <aria_init@plt>
mov    $0x0,%al
call   10b0 <arrobot_connect@plt>
cmp    $0x0,%eax
jne    129d <main+0x3d>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1140 <arrobot_radius@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <arrobot_length@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <arrobot_width@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
lea    0xd30(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
mov    $0xc8,%edi
call   1090 <arrobot_setvel@plt>
mov    $0xa,%edi
call   10c0 <arrobot_setrotvel@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    141f <main+0x1bf>
mov    $0x0,%al
call   10b0 <arrobot_connect@plt>
mov    $0x0,%al
call   1100 <arrobot_getx@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1160 <arrobot_gety@plt>
movsd  %xmm0,-0x68(%rbp)
mov    $0x0,%al
call   1120 <arrobot_getth@plt>
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   1130 <arrobot_getvel@plt>
movsd  %xmm0,-0x58(%rbp)
mov    $0x0,%al
call   1070 <arrobot_getrotvel@plt>
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   10d0 <arrobot_getleftvel@plt>
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   10e0 <arrobot_getrightvel@plt>
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   10f0 <arrobot_isstalled@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1150 <arrobot_getbatteryvoltage@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  -0x50(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
mov    -0x34(%rbp),%esi
movaps %xmm0,%xmm7
movsd  -0x30(%rbp),%xmm0
lea    0xc92(%rip),%rdi
mov    $0x8,%al
call   1050 <printf@plt>
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    $0x0,%al
call   10a0 <arrobot_getnumsonar@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    13fb <main+0x19b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x18(%rbp),%edi
call   1180 <arrobot_getsonarrange@plt>
mov    -0x70(%rbp),%esi
lea    0xc9f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    13b4 <main+0x154>
lea    0xc7c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1170 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12f2 <main+0x92>
mov    $0x0,%al
call   1080 <arrobot_disconnect@plt>
lea    0xc5f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
call   1170 <sleep@plt>
jmp    1282 <main+0x22>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
call   1120 <aria_init@plt>
xor    %eax,%eax
call   10c0 <arrobot_connect@plt>
test   %eax,%eax
je     1446 <main+0x1d6>
lea    0xd91(%rip),%r15
lea    0xddf(%rip),%r12
lea    0xdde(%rip),%rbx
lea    0xdde(%rip),%r13
jmp    12d8 <main+0x68>
xor    %eax,%eax
call   1090 <arrobot_disconnect@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    $0x5,%edi
call   1180 <sleep@plt>
xor    %eax,%eax
call   10c0 <arrobot_connect@plt>
test   %eax,%eax
je     1446 <main+0x1d6>
xor    %eax,%eax
call   1150 <arrobot_radius@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <arrobot_length@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <arrobot_width@plt>
movaps %xmm0,%xmm2
lea    0xcfe(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x3,%al
call   1060 <printf@plt>
mov    $0xc8,%edi
call   10a0 <arrobot_setvel@plt>
mov    $0xa,%edi
call   10d0 <arrobot_setrotvel@plt>
xor    %r14d,%r14d
jmp    1352 <main+0xe2>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1180 <sleep@plt>
add    $0x1,%r14d
cmp    $0xa,%r14d
je     12b0 <main+0x40>
xor    %eax,%eax
call   10c0 <arrobot_connect@plt>
xor    %eax,%eax
call   1110 <arrobot_getx@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1170 <arrobot_gety@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1130 <arrobot_getth@plt>
movsd  %xmm0,0x30(%rsp)
xor    %eax,%eax
call   1140 <arrobot_getvel@plt>
movsd  %xmm0,0x28(%rsp)
xor    %eax,%eax
call   1080 <arrobot_getrotvel@plt>
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
call   10e0 <arrobot_getleftvel@plt>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   10f0 <arrobot_getrightvel@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1100 <arrobot_isstalled@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1160 <arrobot_getbatteryvoltage@plt>
movaps %xmm0,%xmm7
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
movsd  0x10(%rsp),%xmm6
mov    %ebp,%esi
mov    $0x8,%al
call   1060 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10b0 <arrobot_getnumsonar@plt>
test   %eax,%eax
jle    1330 <main+0xc0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1190 <arrobot_getsonarrange@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%ebp
xor    %eax,%eax
call   10b0 <arrobot_getnumsonar@plt>
cmp    %eax,%ebp
jl     1420 <main+0x1b0>
jmp    1330 <main+0xc0>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"radius=%.2f, length=%.2fmm, width=%.2fmm\0A\00"
@.str.1 = [85 x i8] c"x=%.1f y=%.1f th=%.1f vel=%.1f rotvel=%.1f left=%.1f right=%.1f stall=%d battv=%.1f\0A\00"
@.str.2 = [6 x i8] c"sonar\00"
@.str.3 = [7 x i8] c" %d=%f\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [39 x i8] c"disconnected, reconnecting in 5 sec...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @aria_init(i32 %8, i8** %9)
br label %11
11: ; preds = %2, %56
%12 = call i32 (...) @arrobot_connect()
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11
ret i32 1
15: ; preds = %11
%16 = call double (...) @arrobot_radius()
%17 = call double (...) @arrobot_length()
%18 = call double (...) @arrobot_width()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), double %16, double %17, double %18)
%20 = call i32 @arrobot_setvel(i32 200)
%21 = call i32 @arrobot_setrotvel(i32 10)
store i32 0, i32* %6
br label %22
22: ; preds = %53, %15
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %56
25: ; preds = %22
%26 = call i32 (...) @arrobot_connect()
%27 = call double (...) @arrobot_getx()
%28 = call double (...) @arrobot_gety()
%29 = call double (...) @arrobot_getth()
%30 = call double (...) @arrobot_getvel()
%31 = call double (...) @arrobot_getrotvel()
%32 = call double (...) @arrobot_getleftvel()
%33 = call double (...) @arrobot_getrightvel()
%34 = call i32 (...) @arrobot_isstalled()
%35 = call double (...) @arrobot_getbatteryvoltage()
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.1, i64 0, i64 0), double %27, double %28, double %29, double %30, double %31, double %32, double %33, i32 %34, double %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %38
38: ; preds = %47, %25
%39 = load i32, i32* %7
%40 = call i32 (...) @arrobot_getnumsonar()
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i32, i32* %7
%44 = load i32, i32* %7
%45 = call double @arrobot_getsonarrange(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %43, double %45)
br label %47
47: ; preds = %42
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %38
50: ; preds = %38
%51 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 @sleep(i32 1)
br label %53
53: ; preds = %50
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %22
56: ; preds = %22
%57 = call i32 (...) @arrobot_disconnect()
%58 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%59 = call i32 @sleep(i32 5)
br label %11
}

LLVM IR (-O2):
@.str = [42 x i8] c"radius=%.2f, length=%.2fmm, width=%.2fmm\0A\00"
@.str.1 = [85 x i8] c"x=%.1f y=%.1f th=%.1f vel=%.1f rotvel=%.1f left=%.1f right=%.1f stall=%d battv=%.1f\0A\00"
@.str.2 = [6 x i8] c"sonar\00"
@.str.3 = [7 x i8] c" %d=%f\00"
@.str.5 = [39 x i8] c"disconnected, reconnecting in 5 sec...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @aria_init(i32 %0, i8** %1)
%4 = tail call i32 (...) @arrobot_connect()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %14, %2
ret i32 1
7: ; preds = %2, %14
%8 = tail call double (...) @arrobot_radius()
%9 = tail call double (...) @arrobot_length()
%10 = tail call double (...) @arrobot_width()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), double %8, double %9, double %10)
%12 = tail call i32 @arrobot_setvel(i32 200)
%13 = tail call i32 @arrobot_setrotvel(i32 10)
br label %20
14: ; preds = %36
%15 = tail call i32 (...) @arrobot_disconnect()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @sleep(i32 5)
%18 = tail call i32 (...) @arrobot_connect()
%19 = icmp eq i32 %18, 0
br i1 %19, label %6, label %7
20: ; preds = %7, %36
%21 = phi i32 [ 0, %7 ], [ %39, %36 ]
%22 = tail call i32 (...) @arrobot_connect()
%23 = tail call double (...) @arrobot_getx()
%24 = tail call double (...) @arrobot_gety()
%25 = tail call double (...) @arrobot_getth()
%26 = tail call double (...) @arrobot_getvel()
%27 = tail call double (...) @arrobot_getrotvel()
%28 = tail call double (...) @arrobot_getleftvel()
%29 = tail call double (...) @arrobot_getrightvel()
%30 = tail call i32 (...) @arrobot_isstalled()
%31 = tail call double (...) @arrobot_getbatteryvoltage()
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @.str.1, i64 0, i64 0), double %23, double %24, double %25, double %26, double %27, double %28, double %29, i32 %30, double %31)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%34 = tail call i32 (...) @arrobot_getnumsonar()
%35 = icmp sgt i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %41, %20
%37 = tail call i32 @putchar(i32 10)
%38 = tail call i32 @sleep(i32 1)
%39 = add nuw nsw i32 %21, 1
%40 = icmp eq i32 %39, 10
br i1 %40, label %14, label %20
41: ; preds = %20, %41
%42 = phi i32 [ %45, %41 ], [ 0, %20 ]
%43 = tail call double @arrobot_getsonarrange(i32 %42)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %42, double %43)
%45 = add nuw nsw i32 %42, 1
%46 = tail call i32 (...) @arrobot_getnumsonar()
%47 = icmp slt i32 %45, %46
br i1 %47, label %41, label %36
}