#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_SIV100B(unsigned char val) {
  unsigned char x;
  if (val == 0x01)
    val = 0x2;
  else if (val == 0x02)
    val = 0x01;
  VIM_SIF_I2cReadByte(0x04, &x);
  x &= 0xfc;
  x |= (val & 0x03);
  VIM_SIF_I2cWriteByte(0x04, x);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1144 <SensorSetMirrorFlip_SIV100B+0x24>
movb   $0x2,-0x1(%rbp)
jmp    115a <SensorSetMirrorFlip_SIV100B+0x3a>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    1155 <SensorSetMirrorFlip_SIV100B+0x35>
movb   $0x1,-0x1(%rbp)
jmp    115a <SensorSetMirrorFlip_SIV100B+0x3a>
mov    $0x4,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x2(%rbp),%eax
and    $0xfc,%eax
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%ecx
and    $0x3,%ecx
movzbl -0x2(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x2(%rbp)
mov    $0x4,%edi
movzbl -0x2(%rbp),%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
and    $0x3,%al
cmp    $0x2,%dil
movzbl %al,%eax
mov    $0x1,%ecx
cmovne %eax,%ecx
cmp    $0x1,%dil
mov    $0x2,%ebx
cmovne %ecx,%ebx
lea    0xf(%rsp),%rsi
mov    $0x4,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
mov    0xf(%rsp),%al
and    $0xfc,%al
or     %bl,%al
mov    %al,0xf(%rsp)
movzbl %al,%esi
mov    $0x4,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

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