#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_I2cReadWord(int, unsigned short *);
int /*<<< orphan*/ VIM_SIF_I2cWriteWord(int, unsigned short);
void SensorSetMirrorFlip_MT9V111(unsigned char val) {
  unsigned short x;
  if (val == 0x00)
    val = 0x03;
  else if (val == 0x03)
    val = 0x00;
  VIM_SIF_I2cWriteWord(0x01, 4);
  VIM_SIF_I2cReadWord(0x20, &x);
  x &= 0x3f5f;
  x |= (val & 0x03) << 14;
  x |= (val & 0x01) << 5;
  x |= (val & 0x02) << 6;
  VIM_SIF_I2cWriteWord(0x20, x);
}


x86 assembly (clang, -O0):
<SensorSetMirrorFlip_MT9V111>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    1144 <SensorSetMirrorFlip_MT9V111+0x24>
movb   $0x3,-0x1(%rbp)
jmp    115a <SensorSetMirrorFlip_MT9V111+0x3a>
movzbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    1155 <SensorSetMirrorFlip_MT9V111+0x35>
movb   $0x0,-0x1(%rbp)
jmp    115a <SensorSetMirrorFlip_MT9V111+0x3a>
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <VIM_SIF_I2cWriteWord@plt>
mov    $0x20,%edi
lea    -0x4(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadWord@plt>
movzwl -0x4(%rbp),%eax
and    $0x3f5f,%eax
mov    %ax,-0x4(%rbp)
movzbl -0x1(%rbp),%ecx
and    $0x3,%ecx
shl    $0xe,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
movzbl -0x1(%rbp),%ecx
and    $0x1,%ecx
shl    $0x5,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
movzbl -0x1(%rbp),%ecx
and    $0x2,%ecx
shl    $0x6,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
mov    $0x20,%edi
movzwl -0x4(%rbp),%esi
call   1040 <VIM_SIF_I2cWriteWord@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SensorSetMirrorFlip_MT9V111>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
cmp    $0x3,%dil
cmovne %edi,%eax
test   %edi,%edi
mov    $0x3,%ebx
cmovne %eax,%ebx
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <VIM_SIF_I2cWriteWord@plt>
lea    0xe(%rsp),%rsi
mov    $0x20,%edi
call   1030 <VIM_SIF_I2cReadWord@plt>
movzwl 0xe(%rsp),%eax
and    $0x3f5f,%eax
mov    %ebx,%ecx
shl    $0xe,%ecx
or     %eax,%ecx
mov    %ebx,%eax
shl    $0x5,%eax
and    $0x20,%eax
or     %ecx,%eax
and    $0x2,%ebx
shl    $0x6,%ebx
or     %eax,%ebx
mov    %bx,0xe(%rsp)
movzwl %bx,%esi
mov    $0x20,%edi
call   1040 <VIM_SIF_I2cWriteWord@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @SensorSetMirrorFlip_MT9V111(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i16
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 3, i8* %2
br label %14
8: ; preds = %1
%9 = load i8, i8* %2
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 0, i8* %2
br label %13
13: ; preds = %12, %8
br label %14
14: ; preds = %13, %7
%15 = call i32 @VIM_SIF_I2cWriteWord(i32 1, i16 zeroext 4)
%16 = call i32 @VIM_SIF_I2cReadWord(i32 32, i16* %3)
%17 = load i16, i16* %3
%18 = zext i16 %17 to i32
%19 = and i32 %18, 16223
%20 = trunc i32 %19 to i16
store i16 %20, i16* %3
%21 = load i8, i8* %2
%22 = zext i8 %21 to i32
%23 = and i32 %22, 3
%24 = shl i32 %23, 14
%25 = load i16, i16* %3
%26 = zext i16 %25 to i32
%27 = or i32 %26, %24
%28 = trunc i32 %27 to i16
store i16 %28, i16* %3
%29 = load i8, i8* %2
%30 = zext i8 %29 to i32
%31 = and i32 %30, 1
%32 = shl i32 %31, 5
%33 = load i16, i16* %3
%34 = zext i16 %33 to i32
%35 = or i32 %34, %32
%36 = trunc i32 %35 to i16
store i16 %36, i16* %3
%37 = load i8, i8* %2
%38 = zext i8 %37 to i32
%39 = and i32 %38, 2
%40 = shl i32 %39, 6
%41 = load i16, i16* %3
%42 = zext i16 %41 to i32
%43 = or i32 %42, %40
%44 = trunc i32 %43 to i16
store i16 %44, i16* %3
%45 = load i16, i16* %3
%46 = call i32 @VIM_SIF_I2cWriteWord(i32 32, i16 zeroext %45)
ret void
}

LLVM IR (-O2):
define void @SensorSetMirrorFlip_MT9V111(i8 zeroext %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = icmp eq i8 %0, 0
%5 = icmp eq i8 %0, 3
%6 = select i1 %5, i8 0, i8 %0
%7 = select i1 %4, i8 3, i8 %6
%8 = zext i8 %7 to i16
%9 = tail call i32 @VIM_SIF_I2cWriteWord(i32 1, i16 zeroext 4)
%10 = call i32 @VIM_SIF_I2cReadWord(i32 32, i16* %2)
%11 = load i16, i16* %2
%12 = and i16 %11, 16223
%13 = shl i16 %8, 14
%14 = or i16 %12, %13
%15 = shl nuw nsw i16 %8, 5
%16 = and i16 %15, 32
%17 = or i16 %14, %16
%18 = shl nuw nsw i16 %8, 6
%19 = and i16 %18, 128
%20 = or i16 %17, %19
store i16 %20, i16* %2
%21 = call i32 @VIM_SIF_I2cWriteWord(i32 32, i16 zeroext %20)
ret void
}