#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 */
unsigned int samsung_get_base_gpio_part1();
unsigned int samsung_get_base_gpio_part2();
unsigned int samsung_get_base_gpio_part3();
unsigned int samsung_get_base_gpio_part4();
unsigned int s5p_gpio_base(int gpio) {
  unsigned gpio_part = (((gpio) >> (24)) & (0xff));
  switch (gpio_part) {
  case 1:
    return samsung_get_base_gpio_part1();
  case 2:
    return samsung_get_base_gpio_part2();
  case 3:
    return samsung_get_base_gpio_part3();
  case 4:
    return samsung_get_base_gpio_part4();
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<s5p_gpio_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movzbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11b7 <s5p_gpio_base+0x77>
mov    -0x18(%rbp),%rax
lea    0xe8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <samsung_get_base_gpio_part1@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <s5p_gpio_base+0x7e>
mov    $0x0,%al
call   1040 <samsung_get_base_gpio_part2@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <s5p_gpio_base+0x7e>
mov    $0x0,%al
call   1050 <samsung_get_base_gpio_part3@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <s5p_gpio_base+0x7e>
mov    $0x0,%al
call   1030 <samsung_get_base_gpio_part4@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <s5p_gpio_base+0x7e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s5p_gpio_base>:
shr    $0x18,%edi
add    $0xff,%dil
cmp    $0x3,%dil
ja     1168 <s5p_gpio_base+0x28>
movzbl %dil,%eax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
jmp    1060 <samsung_get_base_gpio_part1@plt>
xor    %eax,%eax
ret
xor    %eax,%eax
jmp    1040 <samsung_get_base_gpio_part2@plt>
xor    %eax,%eax
jmp    1050 <samsung_get_base_gpio_part3@plt>
xor    %eax,%eax
jmp    1030 <samsung_get_base_gpio_part4@plt>

LLVM IR (-O0):
define i32 @s5p_gpio_base(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = ashr i32 %5, 24
%7 = and i32 %6, 255
store i32 %7, i32* %4
%8 = load i32, i32* %4
switch i32 %8, label %17 [
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
]
9: ; preds = %1
%10 = call i32 (...) @samsung_get_base_gpio_part1()
store i32 %10, i32* %2
br label %18
11: ; preds = %1
%12 = call i32 (...) @samsung_get_base_gpio_part2()
store i32 %12, i32* %2
br label %18
13: ; preds = %1
%14 = call i32 (...) @samsung_get_base_gpio_part3()
store i32 %14, i32* %2
br label %18
15: ; preds = %1
%16 = call i32 (...) @samsung_get_base_gpio_part4()
store i32 %16, i32* %2
br label %18
17: ; preds = %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %15, %13, %11, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @s5p_gpio_base(i32 %0) {
%2 = lshr i32 %0, 24
%3 = trunc i32 %2 to i8
switch i8 %3, label %12 [
i8 1, label %4
i8 2, label %6
i8 3, label %8
i8 4, label %10
]
4: ; preds = %1
%5 = tail call i32 (...) @samsung_get_base_gpio_part1()
br label %12
6: ; preds = %1
%7 = tail call i32 (...) @samsung_get_base_gpio_part2()
br label %12
8: ; preds = %1
%9 = tail call i32 (...) @samsung_get_base_gpio_part3()
br label %12
10: ; preds = %1
%11 = tail call i32 (...) @samsung_get_base_gpio_part4()
br label %12
12: ; preds = %1, %10, %8, %6, %4
%13 = phi i32 [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ 0, %1 ]
ret i32 %13
}