#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 biscDrive(int, int);
int biscDriveStop();
int biscWaitDistance(int);
int biscDriveDistance(int velocity, int radius, int distanceMM) {
  if ((velocity > 0 && distanceMM < 0) || (velocity < 0 && distanceMM > 0))
    return -1;
  if (biscDrive(velocity, radius) == -1)
    return -1;
  if (biscWaitDistance(distanceMM) == -1)
    return -1;
  if (biscDriveStop() == -1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<biscDriveDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1155 <biscDriveDistance+0x25>
cmpl   $0x0,-0x10(%rbp)
jl     1169 <biscDriveDistance+0x39>
cmpl   $0x0,-0x8(%rbp)
jge    1175 <biscDriveDistance+0x45>
cmpl   $0x0,-0x10(%rbp)
jle    1175 <biscDriveDistance+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <biscDriveDistance+0xa5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <biscDrive@plt>
cmp    $0xffffffff,%eax
jne    1195 <biscDriveDistance+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <biscDriveDistance+0xa5>
mov    -0x10(%rbp),%edi
call   1040 <biscWaitDistance@plt>
cmp    $0xffffffff,%eax
jne    11b2 <biscDriveDistance+0x82>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <biscDriveDistance+0xa5>
mov    $0x0,%al
call   1050 <biscDriveStop@plt>
cmp    $0xffffffff,%eax
jne    11ce <biscDriveDistance+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <biscDriveDistance+0xa5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<biscDriveDistance>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    $0xffffffff,%ebx
test   %edi,%edi
jle    1142 <biscDriveDistance+0x12>
test   %ebp,%ebp
js     1171 <biscDriveDistance+0x41>
test   %edi,%edi
jns    114a <biscDriveDistance+0x1a>
test   %ebp,%ebp
jg     1171 <biscDriveDistance+0x41>
call   1030 <biscDrive@plt>
cmp    $0xffffffff,%eax
je     1171 <biscDriveDistance+0x41>
mov    %ebp,%edi
call   1040 <biscWaitDistance@plt>
cmp    $0xffffffff,%eax
je     1171 <biscDriveDistance+0x41>
xor    %eax,%eax
call   1050 <biscDriveStop@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
neg    %ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @biscDriveDistance(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10, %3
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %7
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16, %10
store i32 -1, i32* %4
br label %36
20: ; preds = %16, %13
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 @biscDrive(i32 %21, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -1, i32* %4
br label %36
26: ; preds = %20
%27 = load i32, i32* %7
%28 = call i32 @biscWaitDistance(i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 -1, i32* %4
br label %36
31: ; preds = %26
%32 = call i32 (...) @biscDriveStop()
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 -1, i32* %4
br label %36
35: ; preds = %31
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34, %30, %25, %19
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @biscDriveDistance(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %0, 0
%5 = icmp slt i32 %2, 0
%6 = and i1 %4, %5
br i1 %6, label %21, label %7
7: ; preds = %3
%8 = icmp slt i32 %0, 0
%9 = icmp sgt i32 %2, 0
%10 = and i1 %8, %9
br i1 %10, label %21, label %11
11: ; preds = %7
%12 = tail call i32 @biscDrive(i32 %0, i32 %1)
%13 = icmp eq i32 %12, -1
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 @biscWaitDistance(i32 %2)
%16 = icmp eq i32 %15, -1
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i32 (...) @biscDriveStop()
%19 = icmp eq i32 %18, -1
%20 = sext i1 %19 to i32
br label %21
21: ; preds = %17, %14, %11, %3, %7
%22 = phi i32 [ -1, %7 ], [ -1, %3 ], [ -1, %11 ], [ -1, %14 ], [ %20, %17 ]
ret i32 %22
}