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


x86 assembly (clang, -O0):
<straight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <initalizeEncoders@plt>
mov    -0x8(%rbp),%edi
call   1050 <abs@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <abs@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
jge    11d2 <straight+0x82>
cmpl   $0x0,-0x4(%rbp)
jle    11a0 <straight+0x50>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    11b3 <straight+0x63>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    $0x14,%edi
call   1070 <wait1Msec@plt>
mov    -0x8(%rbp),%edi
call   1030 <rightSpeed@plt>
mov    -0x8(%rbp),%edi
call   1060 <leftSpeed@plt>
jmp    1169 <straight+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<straight>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %eax,%eax
call   1040 <initalizeEncoders@plt>
xor    %edi,%edi
call   1050 <abs@plt>
mov    %rax,%rbp
mov    %r14d,%edi
call   1050 <abs@plt>
cmp    %rax,%rbp
jge    11c2 <straight+0x72>
xor    %eax,%eax
test   %r14d,%r14d
setg   %al
mov    %r14d,%r15d
sar    $0x1f,%r15d
add    %eax,%r15d
mov    %r15d,%ebp
nopl   (%rax)
mov    $0x14,%edi
call   1070 <wait1Msec@plt>
mov    %ebp,%edi
call   1030 <rightSpeed@plt>
mov    %ebp,%edi
call   1060 <leftSpeed@plt>
mov    %ebp,%edi
call   1050 <abs@plt>
mov    %rax,%rbx
mov    %r14d,%edi
call   1050 <abs@plt>
add    %r15d,%ebp
cmp    %rax,%rbx
jl     1190 <straight+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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