#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 get_front_ir_dist(int);
int get_us_dist();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_motors(int, int);
void checkWallAhead() {
  int usDist = get_us_dist();
  if (usDist < 30 && get_front_ir_dist(1) > 35) {
    while (usDist > 15) {
      set_motors(10, 10);
      usDist = get_us_dist();
    }
    printf("STOPPED");
    while (1) {
      set_motors(0, 0);
    }
  }
}


x86 assembly (clang, -O0):
<checkWallAhead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <get_us_dist@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1e,-0x4(%rbp)
jge    11b3 <checkWallAhead+0x73>
mov    $0x1,%edi
call   1040 <get_front_ir_dist@plt>
cmp    $0x23,%eax
jle    11b3 <checkWallAhead+0x73>
jmp    1174 <checkWallAhead+0x34>
cmpl   $0xf,-0x4(%rbp)
jle    1199 <checkWallAhead+0x59>
mov    $0xa,%esi
mov    %esi,%edi
call   1060 <set_motors@plt>
mov    $0x0,%al
call   1050 <get_us_dist@plt>
mov    %eax,-0x4(%rbp)
jmp    1174 <checkWallAhead+0x34>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1060 <set_motors@plt>
jmp    11a5 <checkWallAhead+0x65>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkWallAhead>:
push   %rbx
xor    %eax,%eax
call   1050 <get_us_dist@plt>
cmp    $0x1d,%eax
jg     11ab <checkWallAhead+0x6b>
mov    %eax,%ebx
mov    $0x1,%edi
call   1040 <get_front_ir_dist@plt>
cmp    $0x24,%eax
jl     11ab <checkWallAhead+0x6b>
cmp    $0x10,%ebx
jl     118b <checkWallAhead+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
mov    $0xa,%esi
call   1060 <set_motors@plt>
xor    %eax,%eax
call   1050 <get_us_dist@plt>
cmp    $0xf,%eax
jg     1170 <checkWallAhead+0x30>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
xor    %esi,%esi
call   1060 <set_motors@plt>
jmp    11a0 <checkWallAhead+0x60>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"STOPPED\00"
define void @checkWallAhead() {
%1 = alloca i32
%2 = call i32 (...) @get_us_dist()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 30
br i1 %4, label %5, label %19
5: ; preds = %0
%6 = call i32 @get_front_ir_dist(i32 1)
%7 = icmp sgt i32 %6, 35
br i1 %7, label %8, label %19
8: ; preds = %5
br label %9
9: ; preds = %12, %8
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 15
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @set_motors(i32 10, i32 10)
%14 = call i32 (...) @get_us_dist()
store i32 %14, i32* %1
br label %9
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %17
%18 = call i32 @set_motors(i32 0, i32 0)
br label %17
19: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"STOPPED\00"
define void @checkWallAhead() {
%1 = tail call i32 (...) @get_us_dist()
%2 = icmp slt i32 %1, 30
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = tail call i32 @get_front_ir_dist(i32 1)
%5 = icmp sgt i32 %4, 35
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = icmp sgt i32 %1, 15
br i1 %7, label %8, label %12
8: ; preds = %6, %8
%9 = tail call i32 @set_motors(i32 10, i32 10)
%10 = tail call i32 (...) @get_us_dist()
%11 = icmp sgt i32 %10, 15
br i1 %11, label %8, label %12
12: ; preds = %8, %6
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %14, %12
%15 = tail call i32 @set_motors(i32 0, i32 0)
br label %14
16: ; preds = %3, %0
ret void
}