char *get_str_nexthop_type(char flags) {
  if (((flags & (1 << (1))) != 0))
    return "IPV4_NH";
  if (((flags & (1 << (2))) != 0))
    return "IPV4_RSVP_NH";
  if (((flags & (1 << (3))) != 0))
    return "IPV4_LDP_NH";
  if (((flags & (1 << (4))) != 0))
    return "IPV4_SPRING_NH";
  if (((flags & (1 << (5))) != 0))
    return "RSVP_TRANSIT_NH";
  if (((flags & (1 << (6))) != 0))
    return "LDP_TRANSIT_NH";
  if (((flags & (1 << (7))) != 0))
    return "SPRING_TRANSIT_NH";
  return "UNKNOWN";
}


x86 assembly (clang, -O0):
<get_str_nexthop_type>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     112a <get_str_nexthop_type+0x2a>
lea    0xedf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     114a <get_str_nexthop_type+0x4a>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     116a <get_str_nexthop_type+0x6a>
lea    0xeb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     118a <get_str_nexthop_type+0x8a>
lea    0xea0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11aa <get_str_nexthop_type+0xaa>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11ca <get_str_nexthop_type+0xca>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
movsbl -0x9(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11ec <get_str_nexthop_type+0xec>
lea    0xe6c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f7 <get_str_nexthop_type+0xf7>
lea    0xe6e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_str_nexthop_type>:
test   $0x2,%dil
jne    113b <get_str_nexthop_type+0x3b>
test   $0x4,%dil
jne    1143 <get_str_nexthop_type+0x43>
test   $0x8,%dil
jne    114b <get_str_nexthop_type+0x4b>
test   $0x10,%dil
jne    1153 <get_str_nexthop_type+0x53>
test   $0x20,%dil
jne    115b <get_str_nexthop_type+0x5b>
test   $0x40,%dil
jne    1163 <get_str_nexthop_type+0x63>
test   $0x80,%dil
lea    0xf32(%rip),%rcx
lea    0xf19(%rip),%rax
cmove  %rcx,%rax
ret
lea    0xebe(%rip),%rax
ret
lea    0xebe(%rip),%rax
ret
lea    0xec3(%rip),%rax
ret
lea    0xec7(%rip),%rax
ret
lea    0xece(%rip),%rax
ret
lea    0xed6(%rip),%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"IPV4_NH\00"
@.str.1 = [13 x i8] c"IPV4_RSVP_NH\00"
@.str.2 = [12 x i8] c"IPV4_LDP_NH\00"
@.str.3 = [15 x i8] c"IPV4_SPRING_NH\00"
@.str.4 = [16 x i8] c"RSVP_TRANSIT_NH\00"
@.str.5 = [15 x i8] c"LDP_TRANSIT_NH\00"
@.str.6 = [18 x i8] c"SPRING_TRANSIT_NH\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
define i8* @get_str_nexthop_type(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 = and i32 %5, 2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %46
9: ; preds = %1
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = and i32 %11, 4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %46
15: ; preds = %9
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = and i32 %17, 8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %46
21: ; preds = %15
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = and i32 %23, 16
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %46
27: ; preds = %21
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = and i32 %29, 32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %46
33: ; preds = %27
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = and i32 %35, 64
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %46
39: ; preds = %33
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = and i32 %41, 128
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %39
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %46
45: ; preds = %39
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %46
46: ; preds = %45, %44, %38, %32, %26, %20, %14, %8
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@.str = [8 x i8] c"IPV4_NH\00"
@.str.1 = [13 x i8] c"IPV4_RSVP_NH\00"
@.str.2 = [12 x i8] c"IPV4_LDP_NH\00"
@.str.3 = [15 x i8] c"IPV4_SPRING_NH\00"
@.str.4 = [16 x i8] c"RSVP_TRANSIT_NH\00"
@.str.5 = [15 x i8] c"LDP_TRANSIT_NH\00"
@.str.6 = [18 x i8] c"SPRING_TRANSIT_NH\00"
@.str.7 = [8 x i8] c"UNKNOWN\00"
define i8* @get_str_nexthop_type(i8 signext %0) {
%2 = zext i8 %0 to i32
%3 = and i32 %2, 2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %24
5: ; preds = %1
%6 = and i32 %2, 4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = and i32 %2, 8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = and i32 %2, 16
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = and i32 %2, 32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = and i32 %2, 64
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = and i32 %2, 128
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0)
br label %24
24: ; preds = %20, %17, %14, %11, %8, %5, %1
%25 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %14 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), %17 ], [ %23, %20 ]
ret i8* %25
}