#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__ abs(int);
scalar_t__ distanceNotTraveled(int);
int inchesToEncoder(float);
int /*<<< orphan*/ initalizeEncoders();
int /*<<< orphan*/ leftSpeed(int);
int /*<<< orphan*/ rightSpeed(int);
int /*<<< orphan*/ wait1Msec(int);
void straight(int power, float inches) {
  int encoder = inchesToEncoder(inches);
  int currentPower = 0;
  initalizeEncoders();
  while (distanceNotTraveled(encoder)) {
    if (abs(currentPower) < abs(power)) {
      if (power > 0) {
        currentPower++;
      }
      if (power < 0) {
        currentPower--;
      }
      wait1Msec(20);
    }
    rightSpeed(currentPower);
    leftSpeed(currentPower);
  }
  rightSpeed(0);
  leftSpeed(0);
}


x86 assembly (clang, -O0):
<straight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1070 <inchesToEncoder@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <initalizeEncoders@plt>
mov    -0xc(%rbp),%edi
call   1090 <distanceNotTraveled@plt>
cmp    $0x0,%rax
je     1216 <straight+0xa6>
mov    -0x10(%rbp),%edi
call   1050 <abs@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <abs@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jge    1201 <straight+0x91>
cmpl   $0x0,-0x4(%rbp)
jle    11e4 <straight+0x74>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    11f7 <straight+0x87>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    $0x14,%edi
call   1080 <wait1Msec@plt>
mov    -0x10(%rbp),%edi
call   1030 <rightSpeed@plt>
mov    -0x10(%rbp),%edi
call   1060 <leftSpeed@plt>
jmp    119b <straight+0x2b>
xor    %edi,%edi
call   1030 <rightSpeed@plt>
xor    %edi,%edi
call   1060 <leftSpeed@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<straight>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
call   1070 <inchesToEncoder@plt>
mov    %eax,%r15d
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <initalizeEncoders@plt>
mov    %r15d,%edi
call   1090 <distanceNotTraveled@plt>
test   %rax,%rax
je     11f1 <straight+0x81>
xor    %eax,%eax
test   %r14d,%r14d
setg   %al
mov    %r14d,%r12d
sar    $0x1f,%r12d
add    %eax,%r12d
jmp    11cb <straight+0x5b>
nopl   (%rax)
mov    %ebx,%edi
call   1030 <rightSpeed@plt>
mov    %ebx,%edi
call   1060 <leftSpeed@plt>
mov    %r15d,%edi
call   1090 <distanceNotTraveled@plt>
test   %rax,%rax
je     11f1 <straight+0x81>
mov    %ebx,%edi
call   1050 <abs@plt>
mov    %rax,%rbp
mov    %r14d,%edi
call   1050 <abs@plt>
cmp    %rax,%rbp
jge    11b0 <straight+0x40>
add    %r12d,%ebx
mov    $0x14,%edi
call   1080 <wait1Msec@plt>
jmp    11b0 <straight+0x40>
xor    %edi,%edi
call   1030 <rightSpeed@plt>
xor    %edi,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <leftSpeed@plt>

LLVM IR (-O0):
define void @straight(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store float %1, float* %4
%7 = load float, float* %4
%8 = call i32 @inchesToEncoder(float %7)
store i32 %8, i32* %5
store i32 0, i32* %6
%9 = call i32 (...) @initalizeEncoders()
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %5
%12 = call i64 @distanceNotTraveled(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %10
%15 = load i32, i32* %6
%16 = call i64 @abs(i32 %15)
%17 = load i32, i32* %3
%18 = call i64 @abs(i32 %17)
%19 = icmp slt i64 %16, %18
br i1 %19, label %20, label %34
20: ; preds = %14
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %3
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %6
%31 = add nsw i32 %30, -1
store i32 %31, i32* %6
br label %32
32: ; preds = %29, %26
%33 = call i32 @wait1Msec(i32 20)
br label %34
34: ; preds = %32, %14
%35 = load i32, i32* %6
%36 = call i32 @rightSpeed(i32 %35)
%37 = load i32, i32* %6
%38 = call i32 @leftSpeed(i32 %37)
br label %10
39: ; preds = %10
%40 = call i32 @rightSpeed(i32 0)
%41 = call i32 @leftSpeed(i32 0)
ret void
}

LLVM IR (-O2):
define void @straight(i32 %0, float %1) {
%3 = tail call i32 @inchesToEncoder(float %1)
%4 = tail call i32 (...) @initalizeEncoders()
%5 = tail call i64 @distanceNotTraveled(i32 %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
%9 = zext i1 %8 to i32
%10 = ashr i32 %0, 31
%11 = add nsw i32 %10, %9
br label %12
12: ; preds = %7, %20
%13 = phi i32 [ 0, %7 ], [ %21, %20 ]
%14 = tail call i64 @abs(i32 %13)
%15 = tail call i64 @abs(i32 %0)
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = add i32 %11, %13
%19 = tail call i32 @wait1Msec(i32 20)
br label %20
20: ; preds = %17, %12
%21 = phi i32 [ %18, %17 ], [ %13, %12 ]
%22 = tail call i32 @rightSpeed(i32 %21)
%23 = tail call i32 @leftSpeed(i32 %21)
%24 = tail call i64 @distanceNotTraveled(i32 %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %12
26: ; preds = %20, %2
%27 = tail call i32 @rightSpeed(i32 0)
%28 = tail call i32 @leftSpeed(i32 0)
ret void
}