#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*/ assert(int);
char swiz_to_channel(const char swiz) {
  if ((swiz == 'r') || (swiz == 'x'))
    return 0;
  if ((swiz == 'g') || (swiz == 'y'))
    return 1;
  if ((swiz == 'b') || (swiz == 'z'))
    return 2;
  if ((swiz == 'a') || (swiz == 'w'))
    return 3;
  assert(0 && "Should have been caught by semantic analysis.");
  return 0;
}


x86 assembly (clang, -O0):
<swiz_to_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x72,%eax
je     1138 <swiz_to_channel+0x28>
movsbl -0x2(%rbp),%eax
cmp    $0x78,%eax
jne    1141 <swiz_to_channel+0x31>
movb   $0x0,-0x1(%rbp)
jmp    11b5 <swiz_to_channel+0xa5>
movsbl -0x2(%rbp),%eax
cmp    $0x67,%eax
je     115b <swiz_to_channel+0x4b>
movsbl -0x2(%rbp),%eax
cmp    $0x79,%eax
jne    1164 <swiz_to_channel+0x54>
movb   $0x1,-0x1(%rbp)
jmp    11b5 <swiz_to_channel+0xa5>
movsbl -0x2(%rbp),%eax
cmp    $0x62,%eax
je     117e <swiz_to_channel+0x6e>
movsbl -0x2(%rbp),%eax
cmp    $0x7a,%eax
jne    1187 <swiz_to_channel+0x77>
movb   $0x2,-0x1(%rbp)
jmp    11b5 <swiz_to_channel+0xa5>
movsbl -0x2(%rbp),%eax
cmp    $0x61,%eax
je     11a1 <swiz_to_channel+0x91>
movsbl -0x2(%rbp),%eax
cmp    $0x77,%eax
jne    11aa <swiz_to_channel+0x9a>
movb   $0x3,-0x1(%rbp)
jmp    11b5 <swiz_to_channel+0xa5>
xor    %edi,%edi
call   1030 <assert@plt>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swiz_to_channel>:
push   %rbx
add    $0x9f,%dil
cmp    $0x19,%dil
ja     113d <swiz_to_channel+0x2d>
xor    %ebx,%ebx
movzbl %dil,%eax
lea    0xed8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3,%bl
jmp    1146 <swiz_to_channel+0x36>
mov    $0x2,%bl
jmp    1146 <swiz_to_channel+0x36>
mov    $0x1,%bl
jmp    1146 <swiz_to_channel+0x36>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @swiz_to_channel(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 114
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 120
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i8 0, i8* %2
br label %41
12: ; preds = %7
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 103
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 121
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i8 1, i8* %2
br label %41
21: ; preds = %16
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 98
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 122
br i1 %28, label %29, label %30
29: ; preds = %25, %21
store i8 2, i8* %2
br label %41
30: ; preds = %25
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 97
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8, i8* %3
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 119
br i1 %37, label %38, label %39
38: ; preds = %34, %30
store i8 3, i8* %2
br label %41
39: ; preds = %34
%40 = call i32 @assert(i32 0)
store i8 0, i8* %2
br label %41
41: ; preds = %39, %38, %29, %20, %11
%42 = load i8, i8* %2
ret i8 %42
}

LLVM IR (-O2):
define signext i8 @swiz_to_channel(i8 signext %0) {
switch i8 %0, label %2 [
i8 120, label %7
i8 114, label %7
i8 121, label %4
i8 103, label %4
i8 122, label %5
i8 98, label %5
i8 119, label %6
i8 97, label %6
]
2: ; preds = %1
%3 = tail call i32 @assert(i32 0)
br label %7
4: ; preds = %1, %1
br label %7
5: ; preds = %1, %1
br label %7
6: ; preds = %1, %1
br label %7
7: ; preds = %1, %1, %6, %5, %4, %2
%8 = phi i8 [ 0, %2 ], [ 0, %1 ], [ 0, %1 ], [ 1, %4 ], [ 2, %5 ], [ 3, %6 ]
ret i8 %8
}