#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 INT_MIN;
int drive(short, short);
int waitDistance(int, int);
int driveDistance(short vel, short rad, int dist, int interrupt) {
  int ret = 0;
  if (drive(vel, rad) == -1 ||
      (ret = waitDistance(dist, interrupt)) == INT_MIN || drive(0, 0) == -1)
    return INT_MIN;
  return ret;
}


x86 assembly (clang, -O0):
<driveDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %di,%si
mov    %si,-0x6(%rbp)
mov    %ax,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x6(%rbp),%ax
movswl %ax,%edi
movswl -0x8(%rbp),%esi
call   1040 <drive@plt>
cmp    $0xffffffff,%eax
je     118b <driveDistance+0x6b>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <waitDistance@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     118b <driveDistance+0x6b>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <drive@plt>
cmp    $0xffffffff,%eax
jne    119c <driveDistance+0x7c>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <driveDistance+0x82>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<driveDistance>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
call   1040 <drive@plt>
cmp    $0xffffffff,%eax
je     1155 <driveDistance+0x35>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <waitDistance@plt>
mov    %eax,%ebx
mov    0x2ea5(%rip),%rax
cmp    (%rax),%ebx
je     1155 <driveDistance+0x35>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <drive@plt>
cmp    $0xffffffff,%eax
jne    115e <driveDistance+0x3e>
mov    0x2e8c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @driveDistance(i16 signext %0, i16 signext %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i16
%7 = alloca i16
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i16 %0, i16* %6
store i16 %1, i16* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 0, i32* %10
%11 = load i16, i16* %6
%12 = load i16, i16* %7
%13 = call i32 @drive(i16 signext %11, i16 signext %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %24, label %15
15: ; preds = %4
%16 = load i32, i32* %8
%17 = load i32, i32* %9
%18 = call i32 @waitDistance(i32 %16, i32 %17)
store i32 %18, i32* %10
%19 = load i32, i32* @INT_MIN
%20 = icmp eq i32 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = call i32 @drive(i16 signext 0, i16 signext 0)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %21, %15, %4
%25 = load i32, i32* @INT_MIN
store i32 %25, i32* %5
br label %28
26: ; preds = %21
%27 = load i32, i32* %10
store i32 %27, i32* %5
br label %28
28: ; preds = %26, %24
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @driveDistance(i16 signext %0, i16 signext %1, i32 %2, i32 %3) {
%5 = tail call i32 @drive(i16 signext %0, i16 signext %1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i32 @waitDistance(i32 %2, i32 %3)
%9 = load i32, i32* @INT_MIN
%10 = icmp eq i32 %8, %9
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @drive(i16 signext 0, i16 signext 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %11, %7, %4
%15 = load i32, i32* @INT_MIN
br label %16
16: ; preds = %11, %14
%17 = phi i32 [ %15, %14 ], [ %8, %11 ]
ret i32 %17
}