#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*/ VIM_SIF_I2cReadByte(int, unsigned char *);
int /*<<< orphan*/ VIM_SIF_I2cWriteByte(int, unsigned char);
void SensorSetMirrorFlip_MC501CB(unsigned char val) {
  unsigned char x;
  VIM_SIF_I2cWriteByte(0x03, 0x00);
  VIM_SIF_I2cReadByte(0x11, &x);
  if (val == 0)
    val = 3;
  else if (val == 3)
    val = 0;
  VIM_SIF_I2cWriteByte(0x11, (unsigned char)((x & 0xfc) | (val & 0x03)));
}


x86 assembly (clang, -O0):
<SensorSetMirrorFlip_MC501CB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x3,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x11,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    115e <SensorSetMirrorFlip_MC501CB+0x3e>
movb   $0x3,-0x1(%rbp)
jmp    1174 <SensorSetMirrorFlip_MC501CB+0x54>
movzbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    116f <SensorSetMirrorFlip_MC501CB+0x4f>
movb   $0x0,-0x1(%rbp)
jmp    1174 <SensorSetMirrorFlip_MC501CB+0x54>
movzbl -0x2(%rbp),%eax
and    $0xfc,%eax
movzbl -0x1(%rbp),%ecx
and    $0x3,%ecx
or     %ecx,%eax
mov    $0x11,%edi
movzbl %al,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SensorSetMirrorFlip_MC501CB>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0x3,%r14d
xor    %ebp,%ebp
mov    $0x3,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
lea    0xf(%rsp),%rsi
mov    $0x11,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
mov    %ebx,%eax
and    $0x3,%al
cmp    $0x3,%bl
movzbl %al,%eax
cmove  %ebp,%eax
test   %ebx,%ebx
cmove  %r14d,%eax
mov    0xf(%rsp),%cl
and    $0xfc,%cl
or     %al,%cl
movzbl %cl,%esi
mov    $0x11,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @SensorSetMirrorFlip_MC501CB(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = call i32 @VIM_SIF_I2cWriteByte(i32 3, i8 zeroext 0)
%5 = call i32 @VIM_SIF_I2cReadByte(i32 17, i8* %3)
%6 = load i8, i8* %2
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i8 3, i8* %2
br label %16
10: ; preds = %1
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 3
br i1 %13, label %14, label %15
14: ; preds = %10
store i8 0, i8* %2
br label %15
15: ; preds = %14, %10
br label %16
16: ; preds = %15, %9
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = and i32 %18, 252
%20 = load i8, i8* %2
%21 = zext i8 %20 to i32
%22 = and i32 %21, 3
%23 = or i32 %19, %22
%24 = trunc i32 %23 to i8
%25 = call i32 @VIM_SIF_I2cWriteByte(i32 17, i8 zeroext %24)
ret void
}

LLVM IR (-O2):
define void @SensorSetMirrorFlip_MC501CB(i8 zeroext %0) {
%2 = alloca i8
%3 = tail call i32 @VIM_SIF_I2cWriteByte(i32 3, i8 zeroext 0)
%4 = call i32 @VIM_SIF_I2cReadByte(i32 17, i8* %2)
%5 = icmp eq i8 %0, 0
%6 = icmp eq i8 %0, 3
%7 = and i8 %0, 3
%8 = select i1 %6, i8 0, i8 %7
%9 = select i1 %5, i8 3, i8 %8
%10 = load i8, i8* %2
%11 = and i8 %10, -4
%12 = or i8 %11, %9
%13 = call i32 @VIM_SIF_I2cWriteByte(i32 17, i8 zeroext %12)
ret void
}