#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*/ calcP();
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();
      calcP();
    }
  }
}


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    11fb <lookForEnd+0x9b>
jmp    1191 <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    11f6 <lookForEnd+0x96>
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    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <checkWallAhead@plt>
mov    $0x0,%al
call   1080 <calcP@plt>
jmp    1191 <lookForEnd+0x31>
jmp    11fb <lookForEnd+0x9b>
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    11ef <lookForEnd+0x8f>
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    11ef <lookForEnd+0x8f>
lea    0xe67(%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    %eax,%eax
call   1080 <calcP@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     11a0 <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 %20
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 %19
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()
%18 = call i32 (...) @calcP()
br label %7
19: ; preds = %7
br label %20
20: ; preds = %19, %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 %22
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 %22
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 (...) @calcP()
%18 = tail call i32 @get_side_ir_dist(i32 0)
%19 = shl nsw i32 %18, 1
%20 = tail call i32 @get_front_ir_dist(i32 0)
%21 = icmp slt i32 %19, %20
br i1 %21, label %11, label %22
22: ; preds = %11, %6, %0
ret void
}