#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 */
typedef int uint32_t;

/* Variables and functions */
const char *get_965_element_component(uint32_t data, int component) {
  uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
  switch (component_control) {
  case 0:
    return "nostore";
  case 1:
    switch (component) {
    case 0:
      return "X";
    case 1:
      return "Y";
    case 2:
      return "Z";
    case 3:
      return "W";
    default:
      return "fail";
    }
  case 2:
    return "0.0";
  case 3:
    return "1.0";
  case 4:
    return "0x1";
  case 5:
    return "VID";
  default:
    return "fail";
  }
}


x86 assembly (clang, -O0):
<get_965_element_component>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%dl
mov    $0x3,%cl
sub    %dl,%cl
shl    $0x2,%cl
add    $0x10,%cl
sar    %cl,%eax
and    $0x7,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x5,%rax
ja     120c <get_965_element_component+0x10c>
mov    -0x20(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
mov    -0x10(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11bc <get_965_element_component+0xbc>
mov    -0x28(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe9f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe83(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe6a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe5e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe46(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <get_965_element_component+0x117>
lea    0xe25(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_965_element_component>:
lea    0x0(,%rsi,4),%eax
mov    $0x1c,%cl
sub    %al,%cl
sar    %cl,%edi
and    $0x7,%edi
cmp    $0x5,%edi
ja     1143 <get_965_element_component+0x43>
lea    0xf0c(%rip),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
cmp    $0x4,%esi
jae    1143 <get_965_element_component+0x43>
movslq %esi,%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xeee(%rip),%rax
ret
lea    0xeeb(%rip),%rax
ret
lea    0xee7(%rip),%rax
ret
lea    0xee3(%rip),%rax
ret
lea    0xedf(%rip),%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"nostore\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"Y\00"
@.str.3 = [2 x i8] c"Z\00"
@.str.4 = [2 x i8] c"W\00"
@.str.5 = [5 x i8] c"fail\00"
@.str.6 = [4 x i8] c"0.0\00"
@.str.7 = [4 x i8] c"1.0\00"
@.str.8 = [4 x i8] c"0x1\00"
@.str.9 = [4 x i8] c"VID\00"
define i8* @get_965_element_component(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = sub nsw i32 3, %8
%10 = mul nsw i32 %9, 4
%11 = add nsw i32 16, %10
%12 = ashr i32 %7, %11
%13 = and i32 %12, 7
store i32 %13, i32* %6
%14 = load i32, i32* %6
switch i32 %14, label %27 [
i32 0, label %15
i32 1, label %16
i32 2, label %23
i32 3, label %24
i32 4, label %25
i32 5, label %26
]
15: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3
br label %28
16: ; preds = %2
%17 = load i32, i32* %5
switch i32 %17, label %22 [
i32 0, label %18
i32 1, label %19
i32 2, label %20
i32 3, label %21
]
18: ; preds = %16
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %28
19: ; preds = %16
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %28
20: ; preds = %16
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %28
21: ; preds = %16
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %28
22: ; preds = %16
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %28
23: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %28
24: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %28
25: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %28
26: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %28
27: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %28
28: ; preds = %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %15
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@.str = [8 x i8] c"nostore\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"Y\00"
@.str.3 = [2 x i8] c"Z\00"
@.str.4 = [2 x i8] c"W\00"
@.str.5 = [5 x i8] c"fail\00"
@.str.6 = [4 x i8] c"0.0\00"
@.str.7 = [4 x i8] c"1.0\00"
@.str.8 = [4 x i8] c"0x1\00"
@.str.9 = [4 x i8] c"VID\00"
@reltable.get_965_element_component = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_965_element_component to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_965_element_component to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_965_element_component to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_965_element_component to i64)) to i32)]
define i8* @get_965_element_component(i32 %0, i32 %1) {
%3 = mul i32 %1, -4
%4 = add i32 %3, 28
%5 = ashr i32 %0, %4
%6 = and i32 %5, 7
switch i32 %6, label %13 [
i32 0, label %18
i32 1, label %7
i32 2, label %9
i32 3, label %10
i32 4, label %11
i32 5, label %12
]
7: ; preds = %2
%8 = icmp ult i32 %1, 4
br i1 %8, label %14, label %18
9: ; preds = %2
br label %18
10: ; preds = %2
br label %18
11: ; preds = %2
br label %18
12: ; preds = %2
br label %18
13: ; preds = %2
br label %18
14: ; preds = %7
%15 = sext i32 %1 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.get_965_element_component to i8*), i64 %16)
br label %18
18: ; preds = %7, %14, %2, %13, %12, %11, %10, %9
%19 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), %11 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ], [ %17, %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %7 ]
ret i8* %19
}