#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, int);
int /*<<< orphan*/ VIM_USER_DelayMs(int);
void SensorSetMode_SIV100A(unsigned char val) {
  unsigned char uTemp;
  switch (val) {
  case 1:
    VIM_SIF_I2cWriteByte(0x40, 0x02);
    VIM_SIF_I2cWriteByte(0x33, 0x05);
    VIM_USER_DelayMs(100);
    VIM_SIF_I2cWriteByte(0x40, 0x9f);
    VIM_USER_DelayMs(100);
    break;
  case 2:
    VIM_SIF_I2cWriteByte(0x40, 0x00);
    VIM_SIF_I2cWriteByte(0x33, 0x06);
    VIM_USER_DelayMs(100);
    VIM_SIF_I2cWriteByte(0x40, 0x9d);
    VIM_USER_DelayMs(100);
    break;
  case 4:
    VIM_SIF_I2cReadByte(0x40, &uTemp);
    if ((uTemp & 0x02) == 0x02) {
      VIM_SIF_I2cWriteByte(0x40, 0x02);
      VIM_SIF_I2cWriteByte(0x33, 0x0a);
      VIM_USER_DelayMs(100);
      VIM_SIF_I2cWriteByte(0x40, 0x9f);
      VIM_USER_DelayMs(100);
    } else {
      VIM_SIF_I2cWriteByte(0x40, 0x00);
      VIM_SIF_I2cWriteByte(0x33, 0x0c);
      VIM_USER_DelayMs(100);
      VIM_SIF_I2cWriteByte(0x40, 0x9d);
      VIM_USER_DelayMs(100);
    }
    break;
  case 3:
    VIM_SIF_I2cReadByte(0x40, &uTemp);
    if ((uTemp & 0x02) == 0x02) {
      VIM_SIF_I2cWriteByte(0x40, 0x02);
      VIM_SIF_I2cWriteByte(0x33, 0x05);
      VIM_USER_DelayMs(100);
      VIM_SIF_I2cWriteByte(0x40, 0x9e);
      VIM_USER_DelayMs(100);
    } else {
      VIM_SIF_I2cWriteByte(0x40, 0x00);
      VIM_SIF_I2cWriteByte(0x33, 0x06);
      VIM_USER_DelayMs(100);
      VIM_SIF_I2cWriteByte(0x40, 0x9c);
      VIM_USER_DelayMs(100);
    }
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     133f <SensorSetMode_SIV100A+0x20f>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x5,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9f,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    1344 <SensorSetMode_SIV100A+0x214>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x6,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9d,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    1344 <SensorSetMode_SIV100A+0x214>
mov    $0x40,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x2(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
jne    1255 <SensorSetMode_SIV100A+0x125>
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0xa,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9f,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    1293 <SensorSetMode_SIV100A+0x163>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0xc,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9d,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    1344 <SensorSetMode_SIV100A+0x214>
mov    $0x40,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x2(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
jne    12fc <SensorSetMode_SIV100A+0x1cc>
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x5,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9e,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    133a <SensorSetMode_SIV100A+0x20a>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x6,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
jmp    1344 <SensorSetMode_SIV100A+0x214>
jmp    1344 <SensorSetMode_SIV100A+0x214>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rax
add    $0xff,%dil
cmp    $0x3,%dil
ja     12da <SensorSetMode_SIV100A+0x1aa>
movzbl %dil,%eax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x5,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9f,%esi
jmp    1255 <SensorSetMode_SIV100A+0x125>
lea    0x7(%rsp),%rsi
mov    $0x40,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
testb  $0x2,0x7(%rsp)
jne    1265 <SensorSetMode_SIV100A+0x135>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x6,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9c,%esi
jmp    12cb <SensorSetMode_SIV100A+0x19b>
lea    0x7(%rsp),%rsi
mov    $0x40,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
testb  $0x2,0x7(%rsp)
jne    1299 <SensorSetMode_SIV100A+0x169>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0xc,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9d,%esi
jmp    12cb <SensorSetMode_SIV100A+0x19b>
mov    $0x40,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x6,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9d,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
pop    %rax
jmp    1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0x5,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9e,%esi
jmp    12cb <SensorSetMode_SIV100A+0x19b>
mov    $0x40,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x33,%edi
mov    $0xa,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x40,%edi
mov    $0x9f,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x64,%edi
call   1050 <VIM_USER_DelayMs@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @SensorSetMode_SIV100A(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
switch i32 %5, label %56 [
i32 1, label %6
i32 2, label %12
i32 4, label %18
i32 3, label %37
]
6: ; preds = %1
%7 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%8 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 5)
%9 = call i32 @VIM_USER_DelayMs(i32 100)
%10 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 159)
%11 = call i32 @VIM_USER_DelayMs(i32 100)
br label %57
12: ; preds = %1
%13 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%14 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 6)
%15 = call i32 @VIM_USER_DelayMs(i32 100)
%16 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 157)
%17 = call i32 @VIM_USER_DelayMs(i32 100)
br label %57
18: ; preds = %1
%19 = call i32 @VIM_SIF_I2cReadByte(i32 64, i8* %3)
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = and i32 %21, 2
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%26 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 10)
%27 = call i32 @VIM_USER_DelayMs(i32 100)
%28 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 159)
%29 = call i32 @VIM_USER_DelayMs(i32 100)
br label %36
30: ; preds = %18
%31 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%32 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 12)
%33 = call i32 @VIM_USER_DelayMs(i32 100)
%34 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 157)
%35 = call i32 @VIM_USER_DelayMs(i32 100)
br label %36
36: ; preds = %30, %24
br label %57
37: ; preds = %1
%38 = call i32 @VIM_SIF_I2cReadByte(i32 64, i8* %3)
%39 = load i8, i8* %3
%40 = zext i8 %39 to i32
%41 = and i32 %40, 2
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%45 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 5)
%46 = call i32 @VIM_USER_DelayMs(i32 100)
%47 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 158)
%48 = call i32 @VIM_USER_DelayMs(i32 100)
br label %55
49: ; preds = %37
%50 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%51 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 6)
%52 = call i32 @VIM_USER_DelayMs(i32 100)
%53 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 156)
%54 = call i32 @VIM_USER_DelayMs(i32 100)
br label %55
55: ; preds = %49, %43
br label %57
56: ; preds = %1
br label %57
57: ; preds = %56, %55, %36, %12, %6
ret void
}

LLVM IR (-O2):
define void @SensorSetMode_SIV100A(i8 zeroext %0) {
%2 = alloca i8
switch i8 %0, label %49 [
i8 1, label %3
i8 2, label %9
i8 4, label %15
i8 3, label %32
]
3: ; preds = %1
%4 = tail call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%5 = tail call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 5)
%6 = tail call i32 @VIM_USER_DelayMs(i32 100)
%7 = tail call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 159)
%8 = tail call i32 @VIM_USER_DelayMs(i32 100)
br label %49
9: ; preds = %1
%10 = tail call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%11 = tail call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 6)
%12 = tail call i32 @VIM_USER_DelayMs(i32 100)
%13 = tail call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 157)
%14 = tail call i32 @VIM_USER_DelayMs(i32 100)
br label %49
15: ; preds = %1
%16 = call i32 @VIM_SIF_I2cReadByte(i32 64, i8* %2)
%17 = load i8, i8* %2
%18 = and i8 %17, 2
%19 = icmp eq i8 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%22 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 10)
%23 = call i32 @VIM_USER_DelayMs(i32 100)
%24 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 159)
%25 = call i32 @VIM_USER_DelayMs(i32 100)
br label %49
26: ; preds = %15
%27 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%28 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 12)
%29 = call i32 @VIM_USER_DelayMs(i32 100)
%30 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 157)
%31 = call i32 @VIM_USER_DelayMs(i32 100)
br label %49
32: ; preds = %1
%33 = call i32 @VIM_SIF_I2cReadByte(i32 64, i8* %2)
%34 = load i8, i8* %2
%35 = and i8 %34, 2
%36 = icmp eq i8 %35, 0
br i1 %36, label %43, label %37
37: ; preds = %32
%38 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 2)
%39 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 5)
%40 = call i32 @VIM_USER_DelayMs(i32 100)
%41 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 158)
%42 = call i32 @VIM_USER_DelayMs(i32 100)
br label %49
43: ; preds = %32
%44 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 0)
%45 = call i32 @VIM_SIF_I2cWriteByte(i32 51, i32 6)
%46 = call i32 @VIM_USER_DelayMs(i32 100)
%47 = call i32 @VIM_SIF_I2cWriteByte(i32 64, i32 156)
%48 = call i32 @VIM_USER_DelayMs(i32 100)
br label %49
49: ; preds = %1, %37, %43, %20, %26, %9, %3
ret void
}