#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_MC501CB(unsigned char val) {
  unsigned char uTemp;
  switch (val) {
  case 1:
    VIM_SIF_I2cWriteByte(0x03, 0x03);
    VIM_SIF_I2cWriteByte(0x10, 0x10);
    VIM_SIF_I2cWriteByte(0x38, 0x01);
    VIM_SIF_I2cWriteByte(0x39, 0x24);
    VIM_SIF_I2cWriteByte(0x3a, 0xf8);
    VIM_USER_DelayMs(50);
    VIM_SIF_I2cWriteByte(0x10, 0x9c);
    break;
  case 2:
    VIM_SIF_I2cWriteByte(0x03, 0x03);
    VIM_SIF_I2cWriteByte(0x10, 0x00);
    VIM_SIF_I2cWriteByte(0x38, 0x00);
    VIM_SIF_I2cWriteByte(0x39, 0xf4);
    VIM_SIF_I2cWriteByte(0x3a, 0x24);
    VIM_USER_DelayMs(50);
    VIM_SIF_I2cWriteByte(0x10, 0x8c);
    break;
  case 4:
    VIM_SIF_I2cWriteByte(0x03, 0x03);
    VIM_SIF_I2cReadByte(0x10, &uTemp);
    if (uTemp == 0x9c) {
      VIM_SIF_I2cWriteByte(0x10, 0x10);
      VIM_SIF_I2cWriteByte(0x38, 0x02);
      VIM_SIF_I2cWriteByte(0x39, 0x49);
      VIM_SIF_I2cWriteByte(0x3a, 0xf0);
      VIM_USER_DelayMs(50);
      VIM_SIF_I2cWriteByte(0x10, 0x9c);
    } else {
      VIM_SIF_I2cWriteByte(0x10, 0x00);
      VIM_SIF_I2cWriteByte(0x38, 0x01);
      VIM_SIF_I2cWriteByte(0x39, 0xe8);
      VIM_SIF_I2cWriteByte(0x3a, 0x48);
      VIM_USER_DelayMs(50);
      VIM_SIF_I2cWriteByte(0x10, 0x8c);
    }
    break;
  case 3:
    VIM_SIF_I2cWriteByte(0x03, 0x03);
    VIM_SIF_I2cReadByte(0x10, &uTemp);
    if (uTemp == 0x9c) {
      VIM_SIF_I2cWriteByte(0x10, 0x10);
      VIM_SIF_I2cWriteByte(0x38, 0x01);
      VIM_SIF_I2cWriteByte(0x39, 0x24);
      VIM_SIF_I2cWriteByte(0x3a, 0xf8);
      VIM_USER_DelayMs(50);
      VIM_SIF_I2cWriteByte(0x10, 0x9c);
    } else {
      VIM_SIF_I2cWriteByte(0x10, 0x00);
      VIM_SIF_I2cWriteByte(0x38, 0x00);
      VIM_SIF_I2cWriteByte(0x39, 0xf4);
      VIM_SIF_I2cWriteByte(0x3a, 0x24);
      VIM_USER_DelayMs(50);
      VIM_SIF_I2cWriteByte(0x10, 0x8c);
    }
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<SensorSetMode_MC501CB>:
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     13d6 <SensorSetMode_MC501CB+0x2a6>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf8,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x9c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    13db <SensorSetMode_MC501CB+0x2ab>
mov    $0x3,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xf4,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x8c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    13db <SensorSetMode_MC501CB+0x2ab>
mov    $0x3,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x2(%rbp),%eax
cmp    $0x9c,%eax
jne    12ab <SensorSetMode_MC501CB+0x17b>
mov    $0x10,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x49,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf0,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x9c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    12fd <SensorSetMode_MC501CB+0x1cd>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xe8,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x48,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x8c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    13db <SensorSetMode_MC501CB+0x2ab>
mov    $0x3,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x2(%rbp),%eax
cmp    $0x9c,%eax
jne    1382 <SensorSetMode_MC501CB+0x252>
mov    $0x10,%esi
mov    %esi,%edi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf8,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x9c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    13d1 <SensorSetMode_MC501CB+0x2a1>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xf4,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x8c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    13db <SensorSetMode_MC501CB+0x2ab>
jmp    13db <SensorSetMode_MC501CB+0x2ab>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SensorSetMode_MC501CB>:
push   %rax
add    $0xff,%dil
cmp    $0x3,%dil
ja     137c <SensorSetMode_MC501CB+0x24c>
movzbl %dil,%eax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3,%edi
mov    $0x3,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
mov    $0x10,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf8,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x9c,%esi
pop    %rax
jmp    1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3,%edi
mov    $0x3,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
lea    0x7(%rsp),%rsi
mov    $0x10,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
cmpb   $0x9c,0x7(%rsp)
jne    12f7 <SensorSetMode_MC501CB+0x1c7>
mov    $0x10,%edi
mov    $0x10,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf8,%esi
jmp    127a <SensorSetMode_MC501CB+0x14a>
mov    $0x3,%edi
mov    $0x3,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
lea    0x7(%rsp),%rsi
mov    $0x10,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
cmpb   $0x9c,0x7(%rsp)
jne    132a <SensorSetMode_MC501CB+0x1fa>
mov    $0x10,%edi
mov    $0x10,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x2,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0x49,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0xf0,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x9c,%esi
jmp    1377 <SensorSetMode_MC501CB+0x247>
mov    $0x3,%edi
mov    $0x3,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xf4,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x24,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x8c,%esi
pop    %rax
jmp    1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xf4,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x24,%esi
jmp    135e <SensorSetMode_MC501CB+0x22e>
mov    $0x10,%edi
xor    %esi,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x38,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x39,%edi
mov    $0xe8,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x3a,%edi
mov    $0x48,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x32,%edi
call   1050 <VIM_USER_DelayMs@plt>
mov    $0x10,%edi
mov    $0x8c,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
pop    %rax
ret

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

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