void Writer(void) {
  int sign;
  _Bool tmp___0;
  unsigned char tmp___1;
  int tmp___2;
  _Bool tmp___3;
  int tmp___4;
  _Bool tmp___5;
  {
    tmp___0 = __startrek_read_output();
    if (tmp___0 == 1) {
      sign = 1;
    } else {
      sign = -1;
    }
    tmp___1 = __startrek_read_W_state();
    switch (tmp___1) {
    case 0:
      break;
    case 1:
      tmp___5 = move_motor(1, 30, sign * 180, sign);
      if (tmp___5) {
        __startrek_write_W_state(0);
        tmp___2 = nxt_motor_get_count(1);
        nxt_motor_set_count(1, tmp___2 % 180);
        tmp___3 = __startrek_read_input();
        if (tmp___3) {
          tmp___4 = 0;
        } else {
          tmp___4 = 1;
        }
        __startrek_write_input(tmp___4);
      }
      break;
    }
    TerminateTask();
    return;
  }
}


x86 assembly (clang, -O0):
<Writer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1080 <__startrek_read_output@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
jne    11c7 <Writer+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11ce <Writer+0x3e>
movl   $0xffffffff,-0x4(%rbp)
xor    %eax,%eax
call   1050 <__startrek_read_W_state@plt>
mov    %al,-0x6(%rbp)
movzbl -0x6(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     11fd <Writer+0x6d>
jmp    11ec <Writer+0x5c>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1202 <Writer+0x72>
jmp    12a1 <Writer+0x111>
jmp    12a1 <Writer+0x111>
imul   $0xb4,-0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
mov    $0x1e,%esi
mov    $0x0,%al
call   1040 <move_motor@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
mov    %al,-0x15(%rbp)
testb  $0x1,-0x15(%rbp)
je     129c <Writer+0x10c>
xor    %edi,%edi
mov    $0x0,%al
call   10a0 <__startrek_write_W_state@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1060 <nxt_motor_get_count@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    $0x1,%edi
mov    $0x0,%al
call   1070 <nxt_motor_set_count@plt>
mov    $0x0,%al
call   10b0 <__startrek_read_input@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
mov    %al,-0xd(%rbp)
testb  $0x1,-0xd(%rbp)
je     128b <Writer+0xfb>
movl   $0x0,-0x14(%rbp)
jmp    1292 <Writer+0x102>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1030 <__startrek_write_input@plt>
jmp    12a1 <Writer+0x111>
mov    $0x0,%al
call   1090 <TerminateTask@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Writer>:
push   %rbx
xor    %eax,%eax
call   1080 <__startrek_read_output@plt>
cmp    $0x1,%eax
sbb    %ebx,%ebx
xor    %eax,%eax
call   1050 <__startrek_read_W_state@plt>
cmp    $0x1,%al
jne    1221 <Writer+0x91>
or     $0x1,%ebx
imul   $0xb4,%ebx,%edx
mov    $0x1,%edi
mov    $0x1e,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <move_motor@plt>
test   %eax,%eax
je     1221 <Writer+0x91>
xor    %edi,%edi
xor    %eax,%eax
call   10a0 <__startrek_write_W_state@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <nxt_motor_get_count@plt>
movslq %eax,%rsi
imul   $0xffffffffb60b60b7,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x7,%eax
add    %ecx,%eax
imul   $0xb4,%eax,%eax
sub    %eax,%esi
mov    $0x1,%edi
xor    %eax,%eax
call   1070 <nxt_motor_set_count@plt>
xor    %eax,%eax
call   10b0 <__startrek_read_input@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1030 <__startrek_write_input@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <TerminateTask@plt>

LLVM IR (-O0):
define void @Writer() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8
%8 = call i32 (...) @__startrek_read_output()
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i8
store i8 %10, i8* %2
%11 = load i8, i8* %2
%12 = trunc i8 %11 to i1
%13 = zext i1 %12 to i32
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 1, i32* %1
br label %17
16: ; preds = %0
store i32 -1, i32* %1
br label %17
17: ; preds = %16, %15
%18 = call i32 (...) @__startrek_read_W_state()
%19 = trunc i32 %18 to i8
store i8 %19, i8* %3
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
switch i32 %21, label %49 [
i32 0, label %22
i32 1, label %23
]
22: ; preds = %17
br label %49
23: ; preds = %17
%24 = load i32, i32* %1
%25 = mul nsw i32 %24, 180
%26 = load i32, i32* %1
%27 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @move_motor to i32 (i32, i32, i32, i32, ...)*)(i32 1, i32 30, i32 %25, i32 %26)
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i8
store i8 %29, i8* %7
%30 = load i8, i8* %7
%31 = trunc i8 %30 to i1
br i1 %31, label %32, label %48
32: ; preds = %23
%33 = call i32 (i32, ...) bitcast (i32 (...)* @__startrek_write_W_state to i32 (i32, ...)*)(i32 0)
%34 = call i32 (i32, ...) bitcast (i32 (...)* @nxt_motor_get_count to i32 (i32, ...)*)(i32 1)
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = srem i32 %35, 180
%37 = call i32 (i32, i32, ...) bitcast (i32 (...)* @nxt_motor_set_count to i32 (i32, i32, ...)*)(i32 1, i32 %36)
%38 = call i32 (...) @__startrek_read_input()
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i8
store i8 %40, i8* %5
%41 = load i8, i8* %5
%42 = trunc i8 %41 to i1
br i1 %42, label %43, label %44
43: ; preds = %32
store i32 0, i32* %6
br label %45
44: ; preds = %32
store i32 1, i32* %6
br label %45
45: ; preds = %44, %43
%46 = load i32, i32* %6
%47 = call i32 (i32, ...) bitcast (i32 (...)* @__startrek_write_input to i32 (i32, ...)*)(i32 %46)
br label %48
48: ; preds = %45, %23
br label %49
49: ; preds = %17, %48, %22
%50 = call i32 (...) @TerminateTask()
ret void
}

LLVM IR (-O2):
define void @Writer() {
%1 = tail call i32 (...) @__startrek_read_output()
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i32 -1, i32 1
%4 = tail call i32 (...) @__startrek_read_W_state()
%5 = and i32 %4, 255
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %20
7: ; preds = %0
%8 = mul nsw i32 %3, 180
%9 = tail call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @move_motor to i32 (i32, i32, i32, i32, ...)*)(i32 1, i32 30, i32 %8, i32 %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %7
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @__startrek_write_W_state to i32 (i32, ...)*)(i32 0)
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @nxt_motor_get_count to i32 (i32, ...)*)(i32 1)
%14 = srem i32 %13, 180
%15 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @nxt_motor_set_count to i32 (i32, i32, ...)*)(i32 1, i32 %14)
%16 = tail call i32 (...) @__startrek_read_input()
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @__startrek_write_input to i32 (i32, ...)*)(i32 %18)
br label %20
20: ; preds = %7, %11, %0
%21 = tail call i32 (...) @TerminateTask()
ret void
}