#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 */
char *_channel_name(unsigned long channel) {
  static struct {
    unsigned long chan;
    char *desc;
  } tab[] = {{0x0001, "device"}, {0x0002, "poll"},   {0x0004, "client"},
             {0x0008, "action"}, {0x0010, "memory"}, {0x0020, "telnet"},
             {0, NULL}};
  int i = 0;
  while (tab[i].chan != 0) {
    if (tab[i].chan == channel)
      break;
    i++;
  }
  return (tab[i].chan == 0 ? "<unknown>" : tab[i].desc);
}


x86 assembly (clang, -O0):
<_channel_name>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2f16(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     115d <_channel_name+0x5d>
movslq -0xc(%rbp),%rcx
lea    0x2efa(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rax
cmp    -0x8(%rbp),%rax
jne    114f <_channel_name+0x4f>
jmp    115d <_channel_name+0x5d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <_channel_name+0xf>
movslq -0xc(%rbp),%rcx
lea    0x2ec8(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
jne    1189 <_channel_name+0x89>
lea    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11a3 <_channel_name+0xa3>
movslq -0xc(%rbp),%rcx
lea    0x2e9c(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_channel_name>:
lea    0xfa1(%rip),%rax
add    $0xffffffffffffffff,%rdi
cmp    $0x1f,%rdi
ja     1154 <_channel_name+0x54>
xor    %ecx,%ecx
lea    0xee6(%rip),%rdx
movslq (%rdx,%rdi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
mov    $0x1,%ecx
jmp    1144 <_channel_name+0x44>
mov    $0x2,%ecx
jmp    1144 <_channel_name+0x44>
mov    $0x3,%ecx
jmp    1144 <_channel_name+0x44>
mov    $0x4,%ecx
jmp    1144 <_channel_name+0x44>
mov    $0x5,%ecx
shl    $0x4,%rcx
lea    0x2c91(%rip),%rax
mov    0x8(%rcx,%rax,1),%rax
ret

LLVM IR (-O0):
%struct.anon = type { i64, i8* }
@_channel_name.tab = internal global [7 x %struct.anon] [%struct.anon { i64 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i64 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i64 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i64 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i64 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i64 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon zeroinitializer]
@.str = [7 x i8] c"device\00"
@.str.1 = [5 x i8] c"poll\00"
@.str.2 = [7 x i8] c"client\00"
@.str.3 = [7 x i8] c"action\00"
@.str.4 = [7 x i8] c"memory\00"
@.str.5 = [7 x i8] c"telnet\00"
@.str.6 = [10 x i8] c"<unknown>\00"
define i8* @_channel_name(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
br label %4
4: ; preds = %20, %1
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @_channel_name.tab, i64 0, i64 %6
%8 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %4
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @_channel_name.tab, i64 0, i64 %13
%15 = getelementptr inbounds %struct.anon, %struct.anon* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* %2
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %11
br label %23
20: ; preds = %11
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %4
23: ; preds = %19, %4
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @_channel_name.tab, i64 0, i64 %25
%27 = getelementptr inbounds %struct.anon, %struct.anon* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
br label %37
31: ; preds = %23
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @_channel_name.tab, i64 0, i64 %33
%35 = getelementptr inbounds %struct.anon, %struct.anon* %34, i32 0, i32 1
%36 = load i8*, i8** %35
br label %37
37: ; preds = %31, %30
%38 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %30 ], [ %36, %31 ]
ret i8* %38
}

LLVM IR (-O2):
%struct.anon = type { i64, i8* }
@_channel_name.tab = internal unnamed_addr constant [7 x %struct.anon] [%struct.anon { i64 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i64 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i64 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i64 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i64 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i64 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon zeroinitializer]
@.str = [7 x i8] c"device\00"
@.str.1 = [5 x i8] c"poll\00"
@.str.2 = [7 x i8] c"client\00"
@.str.3 = [7 x i8] c"action\00"
@.str.4 = [7 x i8] c"memory\00"
@.str.5 = [7 x i8] c"telnet\00"
@.str.6 = [10 x i8] c"<unknown>\00"
define i8* @_channel_name(i64 %0) {
switch i64 %0, label %11 [
i64 1, label %7
i64 2, label %2
i64 4, label %3
i64 8, label %4
i64 16, label %5
i64 32, label %6
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %6, %5, %4, %3, %2
%8 = phi i64 [ 0, %1 ], [ 1, %2 ], [ 2, %3 ], [ 3, %4 ], [ 4, %5 ], [ 5, %6 ]
%9 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @_channel_name.tab, i64 0, i64 %8, i32 1
%10 = load i8*, i8** %9
br label %11
11: ; preds = %1, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %1 ]
ret i8* %12
}