#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 */
scalar_t__ getBumpsAndWheelDrops();
scalar_t__ getCliffs();
scalar_t__ getOvercurrent();
double getTime();
int stopWait() {
  int shouldStop = 0;
  static int overCurrentOn = 0;
  static double overCurrentStart = 0;
  if (getOvercurrent() > 0) {
    if (overCurrentOn == 1) {
      if ((getTime() - overCurrentStart) > .3) {
        shouldStop++;
        overCurrentOn = 0;
      }
    } else {
      overCurrentOn = 1;
      overCurrentStart = getTime();
    }
  } else {
    overCurrentOn = 0;
  }
  shouldStop += getBumpsAndWheelDrops() + getCliffs();
  return shouldStop;
}


x86 assembly (clang, -O0):
<stopWait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getOvercurrent@plt>
cmp    $0x0,%rax
jle    11c4 <stopWait+0x84>
cmpl   $0x1,0x2ee1(%rip)
jne    11a6 <stopWait+0x66>
mov    $0x0,%al
call   1030 <getTime@plt>
subsd  0x2ed4(%rip),%xmm0
movsd  0xe7c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a1 <stopWait+0x61>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,0x2ea7(%rip)
jmp    11bf <stopWait+0x7f>
movl   $0x1,0x2e98(%rip)
mov    $0x0,%al
call   1030 <getTime@plt>
movsd  %xmm0,0x2e91(%rip)
jmp    11ce <stopWait+0x8e>
movl   $0x0,0x2e7a(%rip)
mov    $0x0,%al
call   1050 <getBumpsAndWheelDrops@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getCliffs@plt>
mov    -0x10(%rbp),%rcx
add    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stopWait>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getOvercurrent@plt>
test   %rax,%rax
jle    1184 <stopWait+0x44>
cmpb   $0x1,0x2ef1(%rip)
jne    1190 <stopWait+0x50>
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <getTime@plt>
subsd  0x2ee5(%rip),%xmm0
ucomisd 0xe8d(%rip),%xmm0
jbe    11a9 <stopWait+0x69>
movb   $0x0,0x2ecc(%rip)
mov    $0x1,%r14d
jmp    11a9 <stopWait+0x69>
movb   $0x0,0x2ebd(%rip)
xor    %r14d,%r14d
jmp    11a9 <stopWait+0x69>
movb   $0x1,0x2eb1(%rip)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <getTime@plt>
movsd  %xmm0,0x2ea7(%rip)
xor    %eax,%eax
call   1050 <getBumpsAndWheelDrops@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <getCliffs@plt>
add    %r14d,%ebx
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stopWait.overCurrentOn = internal global i32 0
@stopWait.overCurrentStart = internal global double 0.000000e+00
define i32 @stopWait() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @getOvercurrent()
%3 = icmp sgt i64 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %0
%5 = load i32, i32* @stopWait.overCurrentOn
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = call double (...) @getTime()
%9 = load double, double* @stopWait.overCurrentStart
%10 = fsub double %8, %9
%11 = fcmp ogt double %10, 3.000000e-01
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
store i32 0, i32* @stopWait.overCurrentOn
br label %15
15: ; preds = %12, %7
br label %18
16: ; preds = %4
store i32 1, i32* @stopWait.overCurrentOn
%17 = call double (...) @getTime()
store double %17, double* @stopWait.overCurrentStart
br label %18
18: ; preds = %16, %15
br label %20
19: ; preds = %0
store i32 0, i32* @stopWait.overCurrentOn
br label %20
20: ; preds = %19, %18
%21 = call i64 (...) @getBumpsAndWheelDrops()
%22 = call i64 (...) @getCliffs()
%23 = add nsw i64 %21, %22
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %1
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@stopWait.overCurrentOn = internal unnamed_addr global i1 false
@stopWait.overCurrentStart = internal unnamed_addr global double 0.000000e+00
define i32 @stopWait() {
%1 = tail call i64 (...) @getOvercurrent()
%2 = icmp sgt i64 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = load i1, i1* @stopWait.overCurrentOn
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = tail call double (...) @getTime()
%7 = load double, double* @stopWait.overCurrentStart
%8 = fsub double %6, %7
%9 = fcmp ogt double %8, 3.000000e-01
br i1 %9, label %10, label %14
10: ; preds = %5
store i1 false, i1* @stopWait.overCurrentOn
br label %14
11: ; preds = %3
store i1 true, i1* @stopWait.overCurrentOn
%12 = tail call double (...) @getTime()
store double %12, double* @stopWait.overCurrentStart
br label %14
13: ; preds = %0
store i1 false, i1* @stopWait.overCurrentOn
br label %14
14: ; preds = %11, %10, %5, %13
%15 = phi i64 [ 1, %10 ], [ 0, %5 ], [ 0, %11 ], [ 0, %13 ]
%16 = tail call i64 (...) @getBumpsAndWheelDrops()
%17 = tail call i64 (...) @getCliffs()
%18 = add i64 %16, %15
%19 = add i64 %18, %17
%20 = trunc i64 %19 to i32
ret i32 %20
}