char *dhcp6_stcodestr(code)
int code;
{
  static char genstr[sizeof("code255") + 1];
  if (code > 255)
    return "INVALID code";
  switch (code) {
  case 0:
    return "success";
  case 1:
    return "unspec failure";
  case 6:
    return "auth fail";
  case 7:
    return "address unavailable";
  case 2:
    return "no addresses";
  case 3:
    return "no binding";
  case 8:
    return "confirm no match";
  case 4:
    return "not on-link";
  case 5:
    return "use multicast";
  default:
    sprintf(genstr, "code%d", code);
    return (genstr);
  }
}


x86 assembly (clang, -O0):
<dhcp6_stcodestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jle    1138 <dhcp6_stcodestr+0x28>
lea    0xef5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x8,%rax
ja     11ed <dhcp6_stcodestr+0xdd>
mov    -0x18(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xebf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
lea    0xeb7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1210 <dhcp6_stcodestr+0x100>
mov    -0xc(%rbp),%edx
lea    0x2e32(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2e1d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcp6_stcodestr>:
push   %rbx
cmp    $0xff,%edi
jle    1122 <dhcp6_stcodestr+0x12>
lea    0xee0(%rip),%rbx
jmp    1154 <dhcp6_stcodestr+0x44>
mov    %edi,%edx
cmp    $0x9,%edi
jae    113c <dhcp6_stcodestr+0x2c>
movslq %edx,%rax
lea    0xf59(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1154 <dhcp6_stcodestr+0x44>
lea    0x2ee6(%rip),%rbx
lea    0xf3b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@dhcp6_stcodestr.genstr = internal global [9 x i8] zeroinitializer
@.str = [13 x i8] c"INVALID code\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [15 x i8] c"unspec failure\00"
@.str.3 = [10 x i8] c"auth fail\00"
@.str.4 = [20 x i8] c"address unavailable\00"
@.str.5 = [13 x i8] c"no addresses\00"
@.str.6 = [11 x i8] c"no binding\00"
@.str.7 = [17 x i8] c"confirm no match\00"
@.str.8 = [12 x i8] c"not on-link\00"
@.str.9 = [14 x i8] c"use multicast\00"
@.str.10 = [7 x i8] c"code%d\00"
define i8* @dhcp6_stcodestr(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 255
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %21
7: ; preds = %1
%8 = load i32, i32* %3
switch i32 %8, label %18 [
i32 0, label %9
i32 1, label %10
i32 6, label %11
i32 7, label %12
i32 2, label %13
i32 3, label %14
i32 8, label %15
i32 4, label %16
i32 5, label %17
]
9: ; preds = %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %21
10: ; preds = %7
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %21
11: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %21
12: ; preds = %7
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %21
13: ; preds = %7
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %21
14: ; preds = %7
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %21
15: ; preds = %7
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %21
16: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %21
17: ; preds = %7
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %21
18: ; preds = %7
%19 = load i32, i32* %3
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @dhcp6_stcodestr.genstr, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %19)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @dhcp6_stcodestr.genstr, i64 0, i64 0), i8** %2
br label %21
21: ; preds = %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %6
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@dhcp6_stcodestr.genstr = internal global [9 x i8] zeroinitializer
@.str = [13 x i8] c"INVALID code\00"
@.str.1 = [8 x i8] c"success\00"
@.str.2 = [15 x i8] c"unspec failure\00"
@.str.3 = [10 x i8] c"auth fail\00"
@.str.4 = [20 x i8] c"address unavailable\00"
@.str.5 = [13 x i8] c"no addresses\00"
@.str.6 = [11 x i8] c"no binding\00"
@.str.7 = [17 x i8] c"confirm no match\00"
@.str.8 = [12 x i8] c"not on-link\00"
@.str.9 = [14 x i8] c"use multicast\00"
@.str.10 = [7 x i8] c"code%d\00"
@reltable.dhcp6_stcodestr = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.9 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.dhcp6_stcodestr to i64)) to i32)]
define i8* @dhcp6_stcodestr(i32 %0) {
%2 = icmp sgt i32 %0, 255
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 9
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @dhcp6_stcodestr.genstr, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %0)
br label %11
7: ; preds = %3
%8 = sext i32 %0 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.dhcp6_stcodestr to i8*), i64 %9)
br label %11
11: ; preds = %7, %1, %5
%12 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @dhcp6_stcodestr.genstr, i64 0, i64 0), %5 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %1 ], [ %10, %7 ]
ret i8* %12
}