#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_MT9V112(unsigned char val) {
  unsigned short x;
  val &= 0x03;
  if (val == 0x01)
    val = 0x2;
  else if (val == 0x02)
    val = 0x01;
  else if (val == 0x00)
    val = 0x03;
  else if (val == 0x03)
    val = 0x00;
  VIM_SIF_I2cWriteWord(0xf0, 0);
  VIM_SIF_I2cReadWord(0x20, &x);
  x &= 0xfffc;
  x |= val;
  VIM_SIF_I2cWriteWord(0x20, x);
}


x86 assembly (clang, -O0):
<SensorSetMirrorFlip_MT9V112>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x3,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    114e <SensorSetMirrorFlip_MT9V112+0x2e>
movb   $0x2,-0x1(%rbp)
jmp    119a <SensorSetMirrorFlip_MT9V112+0x7a>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    1164 <SensorSetMirrorFlip_MT9V112+0x44>
movb   $0x1,-0x1(%rbp)
jmp    1195 <SensorSetMirrorFlip_MT9V112+0x75>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    117a <SensorSetMirrorFlip_MT9V112+0x5a>
movb   $0x3,-0x1(%rbp)
jmp    1190 <SensorSetMirrorFlip_MT9V112+0x70>
movzbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    118b <SensorSetMirrorFlip_MT9V112+0x6b>
movb   $0x0,-0x1(%rbp)
jmp    1190 <SensorSetMirrorFlip_MT9V112+0x70>
jmp    1195 <SensorSetMirrorFlip_MT9V112+0x75>
jmp    119a <SensorSetMirrorFlip_MT9V112+0x7a>
mov    $0xf0,%edi
xor    %esi,%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    $0xfffc,%eax
mov    %ax,-0x4(%rbp)
movzbl -0x1(%rbp),%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_MT9V112>:
push   %rbx
sub    $0x10,%rsp
not    %dil
and    $0x3,%dil
movzbl %dil,%ebx
mov    $0xf0,%edi
xor    %esi,%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    $0xfffffffc,%eax
or     %ebx,%eax
mov    %ax,0xe(%rsp)
movzwl %ax,%esi
mov    $0x20,%edi
call   1040 <VIM_SIF_I2cWriteWord@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @SensorSetMirrorFlip_MT9V112(i8 zeroext %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = and i8 %0, 3
%5 = xor i8 %4, 3
%6 = zext i8 %5 to i16
%7 = tail call i32 @VIM_SIF_I2cWriteWord(i32 240, i16 zeroext 0)
%8 = call i32 @VIM_SIF_I2cReadWord(i32 32, i16* %2)
%9 = load i16, i16* %2
%10 = and i16 %9, -4
%11 = or i16 %10, %6
store i16 %11, i16* %2
%12 = call i32 @VIM_SIF_I2cWriteWord(i32 32, i16 zeroext %11)
ret void
}