#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 /*<<< orphan*/ create_drive_straight(int);
int get_create_lfcliff_amt();
int get_create_rfcliff_amt();
int /*<<< orphan*/ printf(char *);
double seconds();
int /*<<< orphan*/ turnLeft(int);
int /*<<< orphan*/ turnRight(int);
void goAlongLine(double time) {
  printf("Following the black line!\n");
  int left, right, speed = 100;
  double sTime, cTime = 0;
  sTime = seconds();
  create_drive_straight(speed);
  while (cTime - sTime <= time) {
    left = get_create_lfcliff_amt();
    right = get_create_rfcliff_amt();
    if (left < 800) {
      turnLeft(1);
      cTime = cTime - 500;
      create_drive_straight(speed);
    }
    if (right < 800) {
      turnRight(1);
      cTime = cTime - 500;
      create_drive_straight(speed);
    }
    cTime = seconds();
  }
}


x86 assembly (clang, -O0):
<goAlongLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x64,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <seconds@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <create_drive_straight@plt>
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1254 <goAlongLine+0xe4>
mov    $0x0,%al
call   1080 <get_create_lfcliff_amt@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1090 <get_create_rfcliff_amt@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x320,-0xc(%rbp)
jge    120e <goAlongLine+0x9e>
mov    $0x1,%edi
call   1070 <turnLeft@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <create_drive_straight@plt>
cmpl   $0x320,-0x10(%rbp)
jge    1243 <goAlongLine+0xd3>
mov    $0x1,%edi
call   1060 <turnRight@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xdce(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <create_drive_straight@plt>
mov    $0x0,%al
call   1030 <seconds@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    11ac <goAlongLine+0x3c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<goAlongLine>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <seconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x64,%edi
call   1050 <create_drive_straight@plt>
xorpd  %xmm0,%xmm0
jmp    11b7 <goAlongLine+0x47>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <seconds@plt>
subsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     1215 <goAlongLine+0xa5>
xor    %eax,%eax
call   1080 <get_create_lfcliff_amt@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <get_create_rfcliff_amt@plt>
mov    %eax,%ebx
cmp    $0x31f,%ebp
jg     11f7 <goAlongLine+0x87>
mov    $0x1,%edi
call   1070 <turnLeft@plt>
mov    $0x64,%edi
call   1050 <create_drive_straight@plt>
cmp    $0x31f,%ebx
jg     11b0 <goAlongLine+0x40>
mov    $0x1,%edi
call   1060 <turnRight@plt>
mov    $0x64,%edi
call   1050 <create_drive_straight@plt>
jmp    11b0 <goAlongLine+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Following the black line!\0A\00"
define void @goAlongLine(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 100, i32* %5
store double 0.000000e+00, double* %7
%9 = call double (...) @seconds()
store double %9, double* %6
%10 = load i32, i32* %5
%11 = call i32 @create_drive_straight(i32 %10)
br label %12
12: ; preds = %38, %1
%13 = load double, double* %7
%14 = load double, double* %6
%15 = fsub double %13, %14
%16 = load double, double* %2
%17 = fcmp ole double %15, %16
br i1 %17, label %18, label %40
18: ; preds = %12
%19 = call i32 (...) @get_create_lfcliff_amt()
store i32 %19, i32* %3
%20 = call i32 (...) @get_create_rfcliff_amt()
store i32 %20, i32* %4
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 800
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = call i32 @turnLeft(i32 1)
%25 = load double, double* %7
%26 = fsub double %25, 5.000000e+02
store double %26, double* %7
%27 = load i32, i32* %5
%28 = call i32 @create_drive_straight(i32 %27)
br label %29
29: ; preds = %23, %18
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 800
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 @turnRight(i32 1)
%34 = load double, double* %7
%35 = fsub double %34, 5.000000e+02
store double %35, double* %7
%36 = load i32, i32* %5
%37 = call i32 @create_drive_straight(i32 %36)
br label %38
38: ; preds = %32, %29
%39 = call double (...) @seconds()
store double %39, double* %7
br label %12
40: ; preds = %12
ret void
}

LLVM IR (-O2):
@str = [26 x i8] c"Following the black line!\00"
define void @goAlongLine(double %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%3 = tail call double (...) @seconds()
%4 = tail call i32 @create_drive_straight(i32 100)
%5 = fsub double 0.000000e+00, %3
%6 = fcmp ugt double %5, %0
br i1 %6, label %23, label %7
7: ; preds = %1, %19
%8 = tail call i32 (...) @get_create_lfcliff_amt()
%9 = tail call i32 (...) @get_create_rfcliff_amt()
%10 = icmp slt i32 %8, 800
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @turnLeft(i32 1)
%13 = tail call i32 @create_drive_straight(i32 100)
br label %14
14: ; preds = %11, %7
%15 = icmp slt i32 %9, 800
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = tail call i32 @turnRight(i32 1)
%18 = tail call i32 @create_drive_straight(i32 100)
br label %19
19: ; preds = %16, %14
%20 = tail call double (...) @seconds()
%21 = fsub double %20, %3
%22 = fcmp ugt double %21, %0
br i1 %22, label %23, label %7
23: ; preds = %19, %1
ret void
}