#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*/ checkWallAhead();
int get_front_ir_dist(int /*<<< orphan*/);
int get_side_ir_dist(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ set_motors(int, int);
void lookForEnd() {
  if (2 * get_side_ir_dist(0) < get_front_ir_dist(0) - 4) {
    while (2 * get_side_ir_dist(0) < get_front_ir_dist(0)) {
      set_motors(30, 70);
      printf("UTURN SL%d FL%d\n", get_side_ir_dist(0), get_front_ir_dist(0));
      checkWallAhead();
    }
  }
}


x86 assembly (clang, -O0):
<lookForEnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
sub    $0x4,%ecx
cmp    %ecx,%eax
jge    11e4 <lookForEnd+0x94>
jmp    1181 <lookForEnd+0x31>
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
jge    11df <lookForEnd+0x8f>
mov    $0x1e,%edi
mov    $0x46,%esi
call   1070 <set_motors@plt>
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <checkWallAhead@plt>
jmp    1181 <lookForEnd+0x31>
jmp    11e4 <lookForEnd+0x94>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookForEnd>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
mov    %eax,%ebx
add    %eax,%ebx
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
add    $0xfffffffc,%eax
cmp    %eax,%ebx
jge    11d8 <lookForEnd+0x88>
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
mov    %eax,%ebx
add    %eax,%ebx
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
cmp    %eax,%ebx
jge    11d8 <lookForEnd+0x88>
lea    0xe77(%rip),%rbx
nopl   0x0(%rax)
mov    $0x1e,%edi
mov    $0x46,%esi
call   1070 <set_motors@plt>
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
mov    %eax,%ebp
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <checkWallAhead@plt>
xor    %edi,%edi
call   1040 <get_side_ir_dist@plt>
mov    %eax,%ebp
add    %eax,%ebp
xor    %edi,%edi
call   1060 <get_front_ir_dist@plt>
cmp    %eax,%ebp
jl     1190 <lookForEnd+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"UTURN SL%d FL%d\0A\00"
define void @lookForEnd() {
%1 = call i32 @get_side_ir_dist(i32 0)
%2 = mul nsw i32 2, %1
%3 = call i32 @get_front_ir_dist(i32 0)
%4 = sub nsw i32 %3, 4
%5 = icmp slt i32 %2, %4
br i1 %5, label %6, label %19
6: ; preds = %0
br label %7
7: ; preds = %12, %6
%8 = call i32 @get_side_ir_dist(i32 0)
%9 = mul nsw i32 2, %8
%10 = call i32 @get_front_ir_dist(i32 0)
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = call i32 @set_motors(i32 30, i32 70)
%14 = call i32 @get_side_ir_dist(i32 0)
%15 = call i32 @get_front_ir_dist(i32 0)
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
%17 = call i32 (...) @checkWallAhead()
br label %7
18: ; preds = %7
br label %19
19: ; preds = %18, %0
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"UTURN SL%d FL%d\0A\00"
define void @lookForEnd() {
%1 = tail call i32 @get_side_ir_dist(i32 0)
%2 = shl nsw i32 %1, 1
%3 = tail call i32 @get_front_ir_dist(i32 0)
%4 = add nsw i32 %3, -4
%5 = icmp slt i32 %2, %4
br i1 %5, label %6, label %21
6: ; preds = %0
%7 = tail call i32 @get_side_ir_dist(i32 0)
%8 = shl nsw i32 %7, 1
%9 = tail call i32 @get_front_ir_dist(i32 0)
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %6, %11
%12 = tail call i32 @set_motors(i32 30, i32 70)
%13 = tail call i32 @get_side_ir_dist(i32 0)
%14 = tail call i32 @get_front_ir_dist(i32 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = tail call i32 (...) @checkWallAhead()
%17 = tail call i32 @get_side_ir_dist(i32 0)
%18 = shl nsw i32 %17, 1
%19 = tail call i32 @get_front_ir_dist(i32 0)
%20 = icmp slt i32 %18, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %6, %0
ret void
}