#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_exit(int);
int /*<<< orphan*/ aria_init(int, char **);
int /*<<< orphan*/ arrobot_connect();
scalar_t__ arrobot_get_front_bumper(int);
scalar_t__ arrobot_get_rear_bumper(int);
double arrobot_getbatteryvoltage();
int arrobot_getnumsonar();
double arrobot_getrotvel();
double arrobot_getth();
double arrobot_getvel();
double arrobot_getx();
double arrobot_gety();
int arrobot_isleftstalled();
int arrobot_isrightstalled();
double arrobot_length();
int arrobot_num_front_bumpers();
int arrobot_num_rear_bumpers();
double arrobot_radius();
double arrobot_width();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  aria_init(argc, argv);
  if (!arrobot_connect()) {
    puts("Could not connect to robot. Exiting.");
    usleep(2000);
    aria_exit(1);
  }
  usleep(1000);
  printf(
      "Width=%.1f Length=%.1f Radius=%.1f NumFrontBumps=%d NumRearBumps=%d\n",
      arrobot_width(), arrobot_length(), arrobot_radius(),
      arrobot_num_front_bumpers(), arrobot_num_rear_bumpers());
  while (1) {
    int i;
    printf("X=%.1f Y=%.1f Th=%.1f Vel=%.1f RotVel=%.1f Bat=%.1f NumSon=%d "
           "LeftStall=%d RightStall=%d\n",
           arrobot_getx(), arrobot_gety(), arrobot_getth(), arrobot_getvel(),
           arrobot_getrotvel(), arrobot_getbatteryvoltage(),
           arrobot_getnumsonar(), arrobot_isleftstalled(),
           arrobot_isrightstalled());
    for (i = 0; i < arrobot_num_front_bumpers(); ++i)
      if (arrobot_get_front_bumper(i))
        printf("Front bumper %d pressed.\n", i);
    for (i = 0; i < arrobot_num_rear_bumpers(); ++i)
      if (arrobot_get_rear_bumper(i))
        printf("Rear bumper %d pressed.\n", i);
    usleep(2000);
  }
  aria_exit(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   10f0 <aria_init@plt>
mov    $0x0,%al
call   10d0 <arrobot_connect@plt>
cmp    $0x0,%eax
jne    12b2 <main+0x52>
lea    0xd67(%rip),%rdi
call   1040 <puts@plt>
mov    $0x7d0,%edi
call   1180 <usleep@plt>
mov    $0x1,%edi
call   1050 <aria_exit@plt>
mov    $0x3e8,%edi
call   1180 <usleep@plt>
mov    $0x0,%al
call   1030 <arrobot_width@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1070 <arrobot_length@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1130 <arrobot_radius@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   10c0 <arrobot_num_front_bumpers@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   10a0 <arrobot_num_rear_bumpers@plt>
mov    -0x2c(%rbp),%esi
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xd19(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10e0 <arrobot_getx@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x64(%rbp)
mov    $0x0,%al
call   1170 <arrobot_gety@plt>
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   1100 <arrobot_getth@plt>
movsd  %xmm0,-0x58(%rbp)
mov    $0x0,%al
call   1110 <arrobot_getvel@plt>
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1090 <arrobot_getrotvel@plt>
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1160 <arrobot_getbatteryvoltage@plt>
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   10b0 <arrobot_getnumsonar@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1150 <arrobot_isleftstalled@plt>
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   1080 <arrobot_isrightstalled@plt>
mov    -0x64(%rbp),%esi
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    %eax,%r8d
lea    0xcc6(%rip),%rdi
mov    $0x5,%al
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    $0x0,%al
call   10c0 <arrobot_num_front_bumpers@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    1402 <main+0x1a2>
mov    -0x14(%rbp),%edi
call   1120 <arrobot_get_front_bumper@plt>
cmp    $0x0,%rax
je     13ef <main+0x18f>
mov    -0x14(%rbp),%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13f4 <main+0x194>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13b2 <main+0x152>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    $0x0,%al
call   10a0 <arrobot_num_rear_bumpers@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    1459 <main+0x1f9>
mov    -0x14(%rbp),%edi
call   1140 <arrobot_get_rear_bumper@plt>
cmp    $0x0,%rax
je     1446 <main+0x1e6>
mov    -0x14(%rbp),%esi
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    144b <main+0x1eb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1409 <main+0x1a9>
mov    $0x7d0,%edi
call   1180 <usleep@plt>
jmp    1313 <main+0xb3>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
call   10f0 <aria_init@plt>
xor    %eax,%eax
call   10d0 <arrobot_connect@plt>
test   %eax,%eax
jne    129e <main+0x3e>
lea    0xd7b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x7d0,%edi
call   1180 <usleep@plt>
mov    $0x1,%edi
call   1050 <aria_exit@plt>
mov    $0x3e8,%edi
call   1180 <usleep@plt>
xor    %eax,%eax
call   1030 <arrobot_width@plt>
cvttsd2si %xmm0,%ebx
xor    %eax,%eax
call   1070 <arrobot_length@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1130 <arrobot_radius@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   10c0 <arrobot_num_front_bumpers@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <arrobot_num_rear_bumpers@plt>
lea    0xd42(%rip),%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebp,%edx
mov    %eax,%ecx
mov    $0x2,%al
call   1060 <printf@plt>
lea    0xd68(%rip),%r14
lea    0xdbb(%rip),%r15
lea    0xdce(%rip),%r13
jmp    132a <main+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x7d0,%edi
call   1180 <usleep@plt>
xor    %eax,%eax
call   10e0 <arrobot_getx@plt>
cvttsd2si %xmm0,%r12d
xor    %eax,%eax
call   1170 <arrobot_gety@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1100 <arrobot_getth@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1110 <arrobot_getvel@plt>
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
call   1090 <arrobot_getrotvel@plt>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1160 <arrobot_getbatteryvoltage@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   10b0 <arrobot_getnumsonar@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1150 <arrobot_isleftstalled@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <arrobot_isrightstalled@plt>
mov    %r14,%rdi
mov    %r12d,%esi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm4
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
mov    $0x5,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   10c0 <arrobot_num_front_bumpers@plt>
test   %eax,%eax
jle    1400 <main+0x1a0>
xor    %ebp,%ebp
jmp    13de <main+0x17e>
nop
add    $0x1,%ebp
xor    %eax,%eax
call   10c0 <arrobot_num_front_bumpers@plt>
cmp    %eax,%ebp
jge    1400 <main+0x1a0>
mov    %ebp,%edi
call   1120 <arrobot_get_front_bumper@plt>
test   %rax,%rax
je     13d0 <main+0x170>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13d0 <main+0x170>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <arrobot_num_rear_bumpers@plt>
test   %eax,%eax
jle    1320 <main+0xc0>
xor    %ebp,%ebp
jmp    1432 <main+0x1d2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
xor    %eax,%eax
call   10a0 <arrobot_num_rear_bumpers@plt>
cmp    %eax,%ebp
jge    1320 <main+0xc0>
mov    %ebp,%edi
call   1140 <arrobot_get_rear_bumper@plt>
test   %rax,%rax
je     1420 <main+0x1c0>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1420 <main+0x1c0>

LLVM IR (-O0):
@.str = [37 x i8] c"Could not connect to robot. Exiting.\00"
@.str.1 = [69 x i8] c"Width=%.1f Length=%.1f Radius=%.1f NumFrontBumps=%d NumRearBumps=%d\0A\00"
@.str.2 = [90 x i8] c"X=%.1f Y=%.1f Th=%.1f Vel=%.1f RotVel=%.1f Bat=%.1f NumSon=%d LeftStall=%d RightStall=%d\0A\00"
@.str.3 = [26 x i8] c"Front bumper %d pressed.\0A\00"
@.str.4 = [25 x i8] c"Rear bumper %d pressed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @aria_init(i32 %7, i8** %8)
%10 = call i32 (...) @arrobot_connect()
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @usleep(i32 2000)
%15 = call i32 @aria_exit(i32 1)
br label %16
16: ; preds = %12, %2
%17 = call i32 @usleep(i32 1000)
%18 = call double (...) @arrobot_width()
%19 = fptosi double %18 to i32
%20 = call double (...) @arrobot_length()
%21 = call double (...) @arrobot_radius()
%22 = call i32 (...) @arrobot_num_front_bumpers()
%23 = call i32 (...) @arrobot_num_rear_bumpers()
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i32 %19, double %20, double %21, i32 %22, i32 %23)
br label %25
25: ; preds = %16, %68
%26 = call double (...) @arrobot_getx()
%27 = fptosi double %26 to i32
%28 = call double (...) @arrobot_gety()
%29 = call double (...) @arrobot_getth()
%30 = call double (...) @arrobot_getvel()
%31 = call double (...) @arrobot_getrotvel()
%32 = call double (...) @arrobot_getbatteryvoltage()
%33 = call i32 (...) @arrobot_getnumsonar()
%34 = call i32 (...) @arrobot_isleftstalled()
%35 = call i32 (...) @arrobot_isrightstalled()
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i32 %27, double %28, double %29, double %30, double %31, double %32, i32 %33, i32 %34, i32 %35)
store i32 0, i32* %6
br label %37
37: ; preds = %49, %25
%38 = load i32, i32* %6
%39 = call i32 (...) @arrobot_num_front_bumpers()
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %52
41: ; preds = %37
%42 = load i32, i32* %6
%43 = call i64 @arrobot_get_front_bumper(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %6
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %41
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %37
52: ; preds = %37
store i32 0, i32* %6
br label %53
53: ; preds = %65, %52
%54 = load i32, i32* %6
%55 = call i32 (...) @arrobot_num_rear_bumpers()
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %68
57: ; preds = %53
%58 = load i32, i32* %6
%59 = call i64 @arrobot_get_rear_bumper(i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = load i32, i32* %6
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %57
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %53
68: ; preds = %53
%69 = call i32 @usleep(i32 2000)
br label %25
}

LLVM IR (-O2):
@.str = [37 x i8] c"Could not connect to robot. Exiting.\00"
@.str.1 = [69 x i8] c"Width=%.1f Length=%.1f Radius=%.1f NumFrontBumps=%d NumRearBumps=%d\0A\00"
@.str.2 = [90 x i8] c"X=%.1f Y=%.1f Th=%.1f Vel=%.1f RotVel=%.1f Bat=%.1f NumSon=%d LeftStall=%d RightStall=%d\0A\00"
@.str.3 = [26 x i8] c"Front bumper %d pressed.\0A\00"
@.str.4 = [25 x i8] c"Rear bumper %d pressed.\0A\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 %10
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @usleep(i32 2000)
%9 = tail call i32 @aria_exit(i32 1)
br label %10
10: ; preds = %6, %2
%11 = tail call i32 @usleep(i32 1000)
%12 = tail call double (...) @arrobot_width()
%13 = fptosi double %12 to i32
%14 = tail call double (...) @arrobot_length()
%15 = tail call double (...) @arrobot_radius()
%16 = tail call i32 (...) @arrobot_num_front_bumpers()
%17 = tail call i32 (...) @arrobot_num_rear_bumpers()
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i32 %13, double %14, double %15, i32 %16, i32 %17)
br label %19
19: ; preds = %10, %56
%20 = tail call double (...) @arrobot_getx()
%21 = fptosi double %20 to i32
%22 = tail call double (...) @arrobot_gety()
%23 = tail call double (...) @arrobot_getth()
%24 = tail call double (...) @arrobot_getvel()
%25 = tail call double (...) @arrobot_getrotvel()
%26 = tail call double (...) @arrobot_getbatteryvoltage()
%27 = tail call i32 (...) @arrobot_getnumsonar()
%28 = tail call i32 (...) @arrobot_isleftstalled()
%29 = tail call i32 (...) @arrobot_isrightstalled()
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i32 %21, double %22, double %23, double %24, double %25, double %26, i32 %27, i32 %28, i32 %29)
%31 = tail call i32 (...) @arrobot_num_front_bumpers()
%32 = icmp sgt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %42, %19
%34 = tail call i32 (...) @arrobot_num_rear_bumpers()
%35 = icmp sgt i32 %34, 0
br i1 %35, label %46, label %56
36: ; preds = %19, %42
%37 = phi i32 [ %43, %42 ], [ 0, %19 ]
%38 = tail call i64 @arrobot_get_front_bumper(i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %42
42: ; preds = %36, %40
%43 = add nuw nsw i32 %37, 1
%44 = tail call i32 (...) @arrobot_num_front_bumpers()
%45 = icmp slt i32 %43, %44
br i1 %45, label %36, label %33
46: ; preds = %33, %52
%47 = phi i32 [ %53, %52 ], [ 0, %33 ]
%48 = tail call i64 @arrobot_get_rear_bumper(i32 %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %52
52: ; preds = %46, %50
%53 = add nuw nsw i32 %47, 1
%54 = tail call i32 (...) @arrobot_num_rear_bumpers()
%55 = icmp slt i32 %53, %54
br i1 %55, label %46, label %56
56: ; preds = %52, %33
%57 = tail call i32 @usleep(i32 2000)
br label %19
}