#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*/ printf(char *, ...);
void KIONIX_ACCEL_process_screen_rotation(char tilt_pos_pre,
                                          char tilt_pos_cur) {
  if (tilt_pos_pre == tilt_pos_cur) {
    printf("Tilt State is prev(0x%02x) == curr(0x%02x) \n", tilt_pos_pre,
           tilt_pos_cur);
    return;
  }
  switch (tilt_pos_cur) {
  case 0x10:
    printf("X+,  Landscape LEFT \n");
    break;
  case 0x20:
    printf("X-,  Landscape RIGHT \n");
    break;
  case 0x04:
    printf("Y+,  Potrait UP \n");
    break;
  case 0x08:
    printf("Y-,  Potrait DOWN \n");
    break;
  case 0x01:
    printf("Z+,  Face UP \n");
    break;
  case 0x02:
    printf("Z-,  Face DOWN \n");
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<KIONIX_ACCEL_process_screen_rotation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x1(%rbp),%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jne    114f <KIONIX_ACCEL_process_screen_rotation+0x3f>
movsbl -0x1(%rbp),%esi
movsbl -0x2(%rbp),%edx
lea    0xf3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <KIONIX_ACCEL_process_screen_rotation+0xdb>
movsbl -0x2(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1f,%eax
ja     11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
mov    -0x10(%rbp),%rax
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
lea    0xf30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
lea    0xf34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
lea    0xf34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <KIONIX_ACCEL_process_screen_rotation+0xd6>
lea    0xf30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <KIONIX_ACCEL_process_screen_rotation+0xdb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KIONIX_ACCEL_process_screen_rotation>:
cmp    %sil,%dil
jne    1135 <KIONIX_ACCEL_process_screen_rotation+0x15>
lea    0xf54(%rip),%rdi
mov    %esi,%edx
xor    %eax,%eax
jmp    1040 <printf@plt>
add    $0xffffffff,%esi
cmp    $0x1f,%esi
ja     1165 <KIONIX_ACCEL_process_screen_rotation+0x45>
lea    0xebc(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf69(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf4d(%rip),%rdi
jmp    1030 <puts@plt>
ret
lea    0xf71(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf52(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf80(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xf5e(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"Tilt State is prev(0x%02x) == curr(0x%02x) \0A\00"
@.str.1 = [22 x i8] c"X+, Landscape LEFT \0A\00"
@.str.2 = [23 x i8] c"X-, Landscape RIGHT \0A\00"
@.str.3 = [18 x i8] c"Y+, Potrait UP \0A\00"
@.str.4 = [20 x i8] c"Y-, Potrait DOWN \0A\00"
@.str.5 = [15 x i8] c"Z+, Face UP \0A\00"
@.str.6 = [17 x i8] c"Z-, Face DOWN \0A\00"
define void @KIONIX_ACCEL_process_screen_rotation(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %6, %8
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14)
br label %32
16: ; preds = %2
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
switch i32 %18, label %31 [
i32 16, label %19
i32 32, label %21
i32 4, label %23
i32 8, label %25
i32 1, label %27
i32 2, label %29
]
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %31
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %31
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %31
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %31
27: ; preds = %16
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %31
29: ; preds = %16
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %16, %29, %27, %25, %23, %21, %19
br label %32
32: ; preds = %31, %10
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"Tilt State is prev(0x%02x) == curr(0x%02x) \0A\00"
@str = [16 x i8] c"Z-, Face DOWN \00"
@str.7 = [14 x i8] c"Z+, Face UP \00"
@str.8 = [19 x i8] c"Y-, Potrait DOWN \00"
@str.9 = [17 x i8] c"Y+, Potrait UP \00"
@str.10 = [22 x i8] c"X-, Landscape RIGHT \00"
@str.11 = [21 x i8] c"X+, Landscape LEFT \00"
define void @KIONIX_ACCEL_process_screen_rotation(i8 signext %0, i8 signext %1) {
%3 = sext i8 %1 to i32
%4 = icmp eq i8 %0, %1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %3)
br label %20
7: ; preds = %2
switch i32 %3, label %20 [
i32 16, label %8
i32 32, label %10
i32 4, label %12
i32 8, label %14
i32 1, label %16
i32 2, label %18
]
8: ; preds = %7
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
br label %20
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
br label %20
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %20
14: ; preds = %7
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
br label %20
16: ; preds = %7
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %20
18: ; preds = %7
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %8, %10, %12, %14, %16, %18, %7, %5
ret void
}