#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_nxtcolorsensor_data_mode();
unsigned char __startrek_read_nxtcolorsensor_mode();
int /*<<< orphan*/ __startrek_write_nxtcolorsensor_mode(unsigned char);
void bg_nxtcolorsensor(_Bool take_long_time) {
  unsigned char tmp;
  unsigned char tmp___0;
  unsigned char tmp___1;
  {
    tmp___0 = __startrek_read_nxtcolorsensor_data_mode();
    tmp___1 = __startrek_read_nxtcolorsensor_mode();
    if (tmp___0 != tmp___1) {
      tmp = __startrek_read_nxtcolorsensor_data_mode();
      __startrek_write_nxtcolorsensor_mode(tmp);
    }
    return;
  }
}


x86 assembly (clang, -O0):
<bg_nxtcolorsensor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
and    $0x1,%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1050 <__startrek_read_nxtcolorsensor_data_mode@plt>
mov    %al,-0x3(%rbp)
mov    $0x0,%al
call   1040 <__startrek_read_nxtcolorsensor_mode@plt>
mov    %al,-0x4(%rbp)
movzbl -0x3(%rbp),%eax
movzbl -0x4(%rbp),%ecx
cmp    %ecx,%eax
je     1177 <bg_nxtcolorsensor+0x47>
mov    $0x0,%al
call   1050 <__startrek_read_nxtcolorsensor_data_mode@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%edi
call   1030 <__startrek_write_nxtcolorsensor_mode@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bg_nxtcolorsensor>:
push   %rbx
xor    %eax,%eax
call   1050 <__startrek_read_nxtcolorsensor_data_mode@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <__startrek_read_nxtcolorsensor_mode@plt>
cmp    %al,%bl
jne    1147 <bg_nxtcolorsensor+0x17>
pop    %rbx
ret
xor    %eax,%eax
call   1050 <__startrek_read_nxtcolorsensor_data_mode@plt>
movzbl %al,%edi
pop    %rbx
jmp    1030 <__startrek_write_nxtcolorsensor_mode@plt>

LLVM IR (-O0):
define void @bg_nxtcolorsensor(i1 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = zext i1 %0 to i8
store i8 %6, i8* %2
%7 = call zeroext i8 (...) @__startrek_read_nxtcolorsensor_data_mode()
store i8 %7, i8* %4
%8 = call zeroext i8 (...) @__startrek_read_nxtcolorsensor_mode()
store i8 %8, i8* %5
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = load i8, i8* %5
%12 = zext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = call zeroext i8 (...) @__startrek_read_nxtcolorsensor_data_mode()
store i8 %15, i8* %3
%16 = load i8, i8* %3
%17 = call i32 @__startrek_write_nxtcolorsensor_mode(i8 zeroext %16)
br label %18
18: ; preds = %14, %1
ret void
}

LLVM IR (-O2):
define void @bg_nxtcolorsensor(i1 zeroext %0) {
%2 = tail call zeroext i8 (...) @__startrek_read_nxtcolorsensor_data_mode()
%3 = tail call zeroext i8 (...) @__startrek_read_nxtcolorsensor_mode()
%4 = icmp eq i8 %2, %3
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call zeroext i8 (...) @__startrek_read_nxtcolorsensor_data_mode()
%7 = tail call i32 @__startrek_write_nxtcolorsensor_mode(i8 zeroext %6)
br label %8
8: ; preds = %5, %1
ret void
}