#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 *version_service_bit_to_str(int bit) {
  assert(bit >= 0 && bit < 64);
  switch (bit) {
  case 0:
    return "NODE_NETWORK";
    break;
  case 1:
    return "NODE_GETUTXO";
    break;
  case 2:
    return "NODE_BLOOM";
    break;
  case 3:
    return "NODE_WITNESS";
    break;
  case 10:
    return "NODE_NETWORK_LIMITED";
    break;
  }
  return "UNKNOWN";
}


x86 assembly (clang, -O0):
<version_service_bit_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     1134 <version_service_bit_to_str+0x24>
cmpl   $0x40,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0xa,%rax
ja     11b7 <version_service_bit_to_str+0xa7>
mov    -0x18(%rbp),%rax
lea    0xea2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <version_service_bit_to_str+0xb2>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <version_service_bit_to_str+0xb2>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <version_service_bit_to_str+0xb2>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <version_service_bit_to_str+0xb2>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <version_service_bit_to_str+0xb2>
lea    0xeb5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<version_service_bit_to_str>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x40,%ebx
setb   %dil
call   1030 <assert@plt>
cmp    $0xa,%ebx
ja     1139 <version_service_bit_to_str+0x29>
movslq %ebx,%rax
lea    0xf20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rbx
ret
lea    0xf07(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"NODE_NETWORK\00"
@.str.1 = [13 x i8] c"NODE_GETUTXO\00"
@.str.2 = [11 x i8] c"NODE_BLOOM\00"
@.str.3 = [13 x i8] c"NODE_WITNESS\00"
@.str.4 = [21 x i8] c"NODE_NETWORK_LIMITED\00"
@.str.5 = [8 x i8] c"UNKNOWN\00"
define i8* @version_service_bit_to_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 64
br label %9
9: ; preds = %6, %1
%10 = phi i1 [ false, %1 ], [ %8, %6 ]
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %3
switch i32 %13, label %19 [
i32 0, label %14
i32 1, label %15
i32 2, label %16
i32 3, label %17
i32 10, label %18
]
14: ; preds = %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %20
15: ; preds = %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %20
16: ; preds = %9
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
17: ; preds = %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %20
18: ; preds = %9
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %20
19: ; preds = %9
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %19, %18, %17, %16, %15, %14
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"NODE_NETWORK\00"
@.str.1 = [13 x i8] c"NODE_GETUTXO\00"
@.str.2 = [11 x i8] c"NODE_BLOOM\00"
@.str.3 = [13 x i8] c"NODE_WITNESS\00"
@.str.4 = [21 x i8] c"NODE_NETWORK_LIMITED\00"
@.str.5 = [8 x i8] c"UNKNOWN\00"
@reltable.version_service_bit_to_str = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.3 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.4 to i64), i64 ptrtoint ([11 x i32]* @reltable.version_service_bit_to_str to i64)) to i32)]
define i8* @version_service_bit_to_str(i32 %0) {
%2 = icmp ult i32 %0, 64
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = icmp ult i32 %0, 11
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %0 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.version_service_bit_to_str to i8*), i64 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %1 ]
ret i8* %11
}