#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 SensorSetMode_S5KA3AFX(unsigned char val) {
  unsigned char temp;
  VIM_SIF_I2cWriteByte(0xef, 01);
  VIM_SIF_I2cReadByte(0x70, &temp);
  switch (val) {
  case 1:
    temp |= 0x0c;
    VIM_SIF_I2cWriteByte(0x70, temp);
    break;
  case 2:
    temp &= 0xfb;
    VIM_SIF_I2cWriteByte(0x70, temp);
    break;
  case 4:
    VIM_SIF_I2cWriteByte(0xb5, 0xc0);
    VIM_SIF_I2cWriteByte(0xaf, 0x15);
    VIM_SIF_I2cWriteByte(0xe2, 0x16);
    VIM_SIF_I2cWriteByte(0xe3, 0x13);
    break;
  case 3:
    temp &= 0xf3;
    VIM_SIF_I2cWriteByte(0x70, temp);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<SensorSetMode_S5KA3AFX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0xef,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0x70,%edi
lea    -0x2(%rbp),%rsi
call   1030 <VIM_SIF_I2cReadByte@plt>
movzbl -0x1(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1211 <SensorSetMode_S5KA3AFX+0xf1>
mov    -0x10(%rbp),%rax
lea    0xe94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl -0x2(%rbp),%eax
or     $0xc,%eax
mov    %al,-0x2(%rbp)
mov    $0x70,%edi
movzbl -0x2(%rbp),%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    1216 <SensorSetMode_S5KA3AFX+0xf6>
movzbl -0x2(%rbp),%eax
and    $0xfb,%eax
mov    %al,-0x2(%rbp)
mov    $0x70,%edi
movzbl -0x2(%rbp),%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    1216 <SensorSetMode_S5KA3AFX+0xf6>
mov    $0xb5,%edi
mov    $0xc0,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xaf,%edi
mov    $0x15,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xe2,%edi
mov    $0x16,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xe3,%edi
mov    $0x13,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    1216 <SensorSetMode_S5KA3AFX+0xf6>
movzbl -0x2(%rbp),%eax
and    $0xf3,%eax
mov    %al,-0x2(%rbp)
mov    $0x70,%edi
movzbl -0x2(%rbp),%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
jmp    1216 <SensorSetMode_S5KA3AFX+0xf6>
jmp    1216 <SensorSetMode_S5KA3AFX+0xf6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SensorSetMode_S5KA3AFX>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0xef,%edi
mov    $0x1,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
lea    0xf(%rsp),%rsi
mov    $0x70,%edi
call   1030 <VIM_SIF_I2cReadByte@plt>
add    $0xff,%bl
cmp    $0x3,%bl
ja     11c4 <SensorSetMode_S5KA3AFX+0xa4>
movzbl %bl,%eax
lea    0xea9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl 0xf(%rsp),%esi
or     $0xc,%esi
jmp    117c <SensorSetMode_S5KA3AFX+0x5c>
movzbl 0xf(%rsp),%esi
and    $0xfffffffb,%esi
jmp    117c <SensorSetMode_S5KA3AFX+0x5c>
movzbl 0xf(%rsp),%esi
and    $0xfffffff3,%esi
mov    %sil,0xf(%rsp)
mov    $0x70,%edi
jmp    11bf <SensorSetMode_S5KA3AFX+0x9f>
mov    $0xb5,%edi
mov    $0xc0,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xaf,%edi
mov    $0x15,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xe2,%edi
mov    $0x16,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
mov    $0xe3,%edi
mov    $0x13,%esi
call   1040 <VIM_SIF_I2cWriteByte@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @SensorSetMode_S5KA3AFX(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = call i32 @VIM_SIF_I2cWriteByte(i32 239, i8 zeroext 1)
%5 = call i32 @VIM_SIF_I2cReadByte(i32 112, i8* %3)
%6 = load i8, i8* %2
%7 = zext i8 %6 to i32
switch i32 %7, label %34 [
i32 1, label %8
i32 2, label %15
i32 4, label %22
i32 3, label %27
]
8: ; preds = %1
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = or i32 %10, 12
%12 = trunc i32 %11 to i8
store i8 %12, i8* %3
%13 = load i8, i8* %3
%14 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %13)
br label %35
15: ; preds = %1
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = and i32 %17, 251
%19 = trunc i32 %18 to i8
store i8 %19, i8* %3
%20 = load i8, i8* %3
%21 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %20)
br label %35
22: ; preds = %1
%23 = call i32 @VIM_SIF_I2cWriteByte(i32 181, i8 zeroext -64)
%24 = call i32 @VIM_SIF_I2cWriteByte(i32 175, i8 zeroext 21)
%25 = call i32 @VIM_SIF_I2cWriteByte(i32 226, i8 zeroext 22)
%26 = call i32 @VIM_SIF_I2cWriteByte(i32 227, i8 zeroext 19)
br label %35
27: ; preds = %1
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = and i32 %29, 243
%31 = trunc i32 %30 to i8
store i8 %31, i8* %3
%32 = load i8, i8* %3
%33 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %32)
br label %35
34: ; preds = %1
br label %35
35: ; preds = %34, %27, %22, %15, %8
ret void
}

LLVM IR (-O2):
define void @SensorSetMode_S5KA3AFX(i8 zeroext %0) {
%2 = alloca i8
%3 = tail call i32 @VIM_SIF_I2cWriteByte(i32 239, i8 zeroext 1)
%4 = call i32 @VIM_SIF_I2cReadByte(i32 112, i8* %2)
switch i8 %0, label %22 [
i8 1, label %5
i8 2, label %9
i8 4, label %13
i8 3, label %18
]
5: ; preds = %1
%6 = load i8, i8* %2
%7 = or i8 %6, 12
store i8 %7, i8* %2
%8 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %7)
br label %22
9: ; preds = %1
%10 = load i8, i8* %2
%11 = and i8 %10, -5
store i8 %11, i8* %2
%12 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %11)
br label %22
13: ; preds = %1
%14 = call i32 @VIM_SIF_I2cWriteByte(i32 181, i8 zeroext -64)
%15 = call i32 @VIM_SIF_I2cWriteByte(i32 175, i8 zeroext 21)
%16 = call i32 @VIM_SIF_I2cWriteByte(i32 226, i8 zeroext 22)
%17 = call i32 @VIM_SIF_I2cWriteByte(i32 227, i8 zeroext 19)
br label %22
18: ; preds = %1
%19 = load i8, i8* %2
%20 = and i8 %19, -13
store i8 %20, i8* %2
%21 = call i32 @VIM_SIF_I2cWriteByte(i32 112, i8 zeroext %20)
br label %22
22: ; preds = %1, %18, %13, %9, %5
ret void
}