#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 *i915_get_channel_swizzle(uint32_t select) {
  switch (select & 0x7) {
  case 0:
    return (select & 8) ? "-x" : "x";
  case 1:
    return (select & 8) ? "-y" : "y";
  case 2:
    return (select & 8) ? "-z" : "z";
  case 3:
    return (select & 8) ? "-w" : "w";
  case 4:
    return (select & 8) ? "-0" : "0";
  case 5:
    return (select & 8) ? "-1" : "1";
  default:
    return (select & 8) ? "-bad" : "bad";
  }
}


x86 assembly (clang, -O0):
<i915_get_channel_swizzle>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7,%eax
mov    %rax,-0x18(%rbp)
sub    $0x5,%eax
ja     1206 <i915_get_channel_swizzle+0x106>
mov    -0x18(%rbp),%rax
lea    0xedb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xede(%rip),%rax
lea    0xed6(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xebd(%rip),%rax
lea    0xeb5(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xe9c(%rip),%rax
lea    0xe94(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xe7b(%rip),%rax
lea    0xe73(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xe5a(%rip),%rax
lea    0xe52(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xe39(%rip),%rax
lea    0xe31(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <i915_get_channel_swizzle+0x125>
mov    -0xc(%rbp),%edx
and    $0x8,%edx
lea    0xe18(%rip),%rax
lea    0xe10(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<i915_get_channel_swizzle>:
mov    %edi,%eax
and    $0x7,%eax
cmp    $0x5,%eax
ja     1131 <i915_get_channel_swizzle+0x31>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
test   $0x8,%dil
lea    0xef4(%rip),%rcx
lea    0xeec(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xeef(%rip),%rcx
lea    0xee7(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xec9(%rip),%rcx
lea    0xec1(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xeb5(%rip),%rcx
lea    0xead(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xea1(%rip),%rcx
lea    0xe99(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xe8d(%rip),%rcx
lea    0xe85(%rip),%rax
cmove  %rcx,%rax
ret
test   $0x8,%dil
lea    0xe79(%rip),%rcx
lea    0xe71(%rip),%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-x\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [3 x i8] c"-y\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [3 x i8] c"-z\00"
@.str.5 = [2 x i8] c"z\00"
@.str.6 = [3 x i8] c"-w\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [3 x i8] c"-0\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [3 x i8] c"-1\00"
@.str.11 = [2 x i8] c"1\00"
@.str.12 = [5 x i8] c"-bad\00"
@.str.13 = [4 x i8] c"bad\00"
define i8* @i915_get_channel_swizzle(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 7
switch i32 %5, label %42 [
i32 0, label %6
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %30
i32 5, label %36
]
6: ; preds = %1
%7 = load i32, i32* %3
%8 = and i32 %7, 8
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
store i8* %11, i8** %2
br label %48
12: ; preds = %1
%13 = load i32, i32* %3
%14 = and i32 %13, 8
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
store i8* %17, i8** %2
br label %48
18: ; preds = %1
%19 = load i32, i32* %3
%20 = and i32 %19, 8
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
store i8* %23, i8** %2
br label %48
24: ; preds = %1
%25 = load i32, i32* %3
%26 = and i32 %25, 8
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
store i8* %29, i8** %2
br label %48
30: ; preds = %1
%31 = load i32, i32* %3
%32 = and i32 %31, 8
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
store i8* %35, i8** %2
br label %48
36: ; preds = %1
%37 = load i32, i32* %3
%38 = and i32 %37, 8
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
store i8* %41, i8** %2
br label %48
42: ; preds = %1
%43 = load i32, i32* %3
%44 = and i32 %43, 8
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0)
store i8* %47, i8** %2
br label %48
48: ; preds = %42, %36, %30, %24, %18, %12, %6
%49 = load i8*, i8** %2
ret i8* %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"-x\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [3 x i8] c"-y\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [3 x i8] c"-z\00"
@.str.5 = [2 x i8] c"z\00"
@.str.6 = [3 x i8] c"-w\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [3 x i8] c"-0\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [3 x i8] c"-1\00"
@.str.11 = [2 x i8] c"1\00"
@.str.12 = [5 x i8] c"-bad\00"
@.str.13 = [4 x i8] c"bad\00"
define i8* @i915_get_channel_swizzle(i32 %0) {
%2 = and i32 %0, 7
switch i32 %2, label %27 [
i32 0, label %3
i32 1, label %7
i32 2, label %11
i32 3, label %15
i32 4, label %19
i32 5, label %23
]
3: ; preds = %1
%4 = and i32 %0, 8
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
br label %31
7: ; preds = %1
%8 = and i32 %0, 8
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
br label %31
11: ; preds = %1
%12 = and i32 %0, 8
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
br label %31
15: ; preds = %1
%16 = and i32 %0, 8
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0)
br label %31
19: ; preds = %1
%20 = and i32 %0, 8
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0)
br label %31
23: ; preds = %1
%24 = and i32 %0, 8
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0)
br label %31
27: ; preds = %1
%28 = and i32 %0, 8
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0)
br label %31
31: ; preds = %27, %23, %19, %15, %11, %7, %3
%32 = phi i8* [ %30, %27 ], [ %26, %23 ], [ %22, %19 ], [ %18, %15 ], [ %14, %11 ], [ %10, %7 ], [ %6, %3 ]
ret i8* %32
}