#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 */
unsigned char __startrek_read_nxtway_gs_mode();
int /*<<< orphan*/ __startrek_write_cmd_forward(int);
int /*<<< orphan*/ __startrek_write_cmd_turn(int /*<<< orphan*/);
int /*<<< orphan*/ __startrek_write_obstacle_flag(int);
unsigned char ecrobot_get_sonar_sensor(int);
void OSEK_Task_ts2(void) {
  unsigned char tmp;
  unsigned char tmp___0;
  {
    __startrek_write_obstacle_flag(0);
    tmp = __startrek_read_nxtway_gs_mode();
    if (tmp == 2) {
      tmp___0 = ecrobot_get_sonar_sensor(4);
      if ((int)tmp___0 <= 25) {
        __startrek_write_obstacle_flag(1);
        __startrek_write_cmd_forward(-100);
        __startrek_write_cmd_turn(0);
      }
    }
    return;
  }
}


x86 assembly (clang, -O0):
<OSEK_Task_ts2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <__startrek_write_obstacle_flag@plt>
mov    $0x0,%al
call   1040 <__startrek_read_nxtway_gs_mode@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    11b0 <OSEK_Task_ts2+0x60>
mov    $0x4,%edi
call   1070 <ecrobot_get_sonar_sensor@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x19,%eax
jg     11ab <OSEK_Task_ts2+0x5b>
mov    $0x1,%edi
call   1060 <__startrek_write_obstacle_flag@plt>
mov    $0xffffff9c,%edi
call   1050 <__startrek_write_cmd_forward@plt>
xor    %edi,%edi
call   1030 <__startrek_write_cmd_turn@plt>
jmp    11b0 <OSEK_Task_ts2+0x60>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OSEK_Task_ts2>:
push   %rax
xor    %edi,%edi
call   1060 <__startrek_write_obstacle_flag@plt>
xor    %eax,%eax
call   1040 <__startrek_read_nxtway_gs_mode@plt>
cmp    $0x2,%al
jne    118d <OSEK_Task_ts2+0x3d>
mov    $0x4,%edi
call   1070 <ecrobot_get_sonar_sensor@plt>
cmp    $0x19,%al
ja     118d <OSEK_Task_ts2+0x3d>
mov    $0x1,%edi
call   1060 <__startrek_write_obstacle_flag@plt>
mov    $0xffffff9c,%edi
call   1050 <__startrek_write_cmd_forward@plt>
xor    %edi,%edi
pop    %rax
jmp    1030 <__startrek_write_cmd_turn@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @OSEK_Task_ts2() {
%1 = alloca i8
%2 = alloca i8
%3 = call i32 @__startrek_write_obstacle_flag(i32 0)
%4 = call zeroext i8 (...) @__startrek_read_nxtway_gs_mode()
store i8 %4, i8* %1
%5 = load i8, i8* %1
%6 = zext i8 %5 to i32
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %18
8: ; preds = %0
%9 = call zeroext i8 @ecrobot_get_sonar_sensor(i32 4)
store i8 %9, i8* %2
%10 = load i8, i8* %2
%11 = zext i8 %10 to i32
%12 = icmp sle i32 %11, 25
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 @__startrek_write_obstacle_flag(i32 1)
%15 = call i32 @__startrek_write_cmd_forward(i32 -100)
%16 = call i32 @__startrek_write_cmd_turn(i32 0)
br label %17
17: ; preds = %13, %8
br label %18
18: ; preds = %17, %0
ret void
}

LLVM IR (-O2):
define void @OSEK_Task_ts2() {
%1 = tail call i32 @__startrek_write_obstacle_flag(i32 0)
%2 = tail call zeroext i8 (...) @__startrek_read_nxtway_gs_mode()
%3 = icmp eq i8 %2, 2
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = tail call zeroext i8 @ecrobot_get_sonar_sensor(i32 4)
%6 = icmp ult i8 %5, 26
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = tail call i32 @__startrek_write_obstacle_flag(i32 1)
%9 = tail call i32 @__startrek_write_cmd_forward(i32 -100)
%10 = tail call i32 @__startrek_write_cmd_turn(i32 0)
br label %11
11: ; preds = %4, %7, %0
ret void
}