char *dhcp6optstr(type)
int type;
{
  static char genstr[sizeof("opt_65535") + 1];
  if (type > 65535)
    return "INVALID option";
  switch (type) {
  case 1:
    return "client ID";
  case 2:
    return "server ID";
  case 6:
    return "option request";
  case 7:
    return "preference";
  case 13:
    return "status code";
  case 14:
    return "rapid commit";
  case 23:
    return "DNS_SERVERS";
  case 24:
    return "DOMAIN_LIST";
  case 22:
    return "SIP_SERVERS";
  case 31:
    return "NTP_SERVERS";
  default:
    sprintf(genstr, "opt_%d", type);
    return (genstr);
  }
}


x86 assembly (clang, -O0):
<dhcp6optstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xffff,-0xc(%rbp)
jle    1138 <dhcp6optstr+0x28>
lea    0xf4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1e,%eax
ja     1201 <dhcp6optstr+0xf1>
mov    -0x18(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf23(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf17(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf16(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf0d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf0a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf06(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xf02(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
lea    0xefe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1224 <dhcp6optstr+0x114>
mov    -0xc(%rbp),%edx
lea    0x2e1e(%rip),%rdi
lea    0xef0(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2e09(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcp6optstr>:
push   %rbx
cmp    $0xffff,%edi
jle    1125 <dhcp6optstr+0x15>
lea    0xf5c(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x1e,%eax
ja     114f <dhcp6optstr+0x3f>
lea    0xf55(%rip),%rbx
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf48(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0x2ed3(%rip),%rbx
lea    0xfa5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1120 <dhcp6optstr+0x10>
lea    0xf2f(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf35(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf37(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf3a(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf56(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf35(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf38(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>
lea    0xf44(%rip),%rbx
jmp    1120 <dhcp6optstr+0x10>

LLVM IR (-O0):
@dhcp6optstr.genstr = internal global [11 x i8] zeroinitializer
@.str = [15 x i8] c"INVALID option\00"
@.str.1 = [10 x i8] c"client ID\00"
@.str.2 = [10 x i8] c"server ID\00"
@.str.3 = [15 x i8] c"option request\00"
@.str.4 = [11 x i8] c"preference\00"
@.str.5 = [12 x i8] c"status code\00"
@.str.6 = [13 x i8] c"rapid commit\00"
@.str.7 = [12 x i8] c"DNS_SERVERS\00"
@.str.8 = [12 x i8] c"DOMAIN_LIST\00"
@.str.9 = [12 x i8] c"SIP_SERVERS\00"
@.str.10 = [12 x i8] c"NTP_SERVERS\00"
@.str.11 = [7 x i8] c"opt_%d\00"
define i8* @dhcp6optstr(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 65535
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
7: ; preds = %1
%8 = load i32, i32* %3
switch i32 %8, label %19 [
i32 1, label %9
i32 2, label %10
i32 6, label %11
i32 7, label %12
i32 13, label %13
i32 14, label %14
i32 23, label %15
i32 24, label %16
i32 22, label %17
i32 31, label %18
]
9: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %22
10: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %22
11: ; preds = %7
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %22
12: ; preds = %7
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %22
13: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %22
14: ; preds = %7
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %22
15: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %22
16: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %22
17: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %22
18: ; preds = %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %22
19: ; preds = %7
%20 = load i32, i32* %3
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @dhcp6optstr.genstr, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %20)
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @dhcp6optstr.genstr, i64 0, i64 0), i8** %2
br label %22
22: ; preds = %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %6
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@dhcp6optstr.genstr = internal global [11 x i8] zeroinitializer
@.str = [15 x i8] c"INVALID option\00"
@.str.1 = [10 x i8] c"client ID\00"
@.str.2 = [10 x i8] c"server ID\00"
@.str.3 = [15 x i8] c"option request\00"
@.str.4 = [11 x i8] c"preference\00"
@.str.5 = [12 x i8] c"status code\00"
@.str.6 = [13 x i8] c"rapid commit\00"
@.str.7 = [12 x i8] c"DNS_SERVERS\00"
@.str.8 = [12 x i8] c"DOMAIN_LIST\00"
@.str.9 = [12 x i8] c"SIP_SERVERS\00"
@.str.10 = [12 x i8] c"NTP_SERVERS\00"
@.str.11 = [7 x i8] c"opt_%d\00"
define i8* @dhcp6optstr(i32 %0) {
%2 = icmp sgt i32 %0, 65535
br i1 %2, label %15, label %3
3: ; preds = %1
switch i32 %0, label %13 [
i32 1, label %15
i32 2, label %4
i32 6, label %5
i32 7, label %6
i32 13, label %7
i32 14, label %8
i32 23, label %9
i32 24, label %10
i32 22, label %11
i32 31, label %12
]
4: ; preds = %3
br label %15
5: ; preds = %3
br label %15
6: ; preds = %3
br label %15
7: ; preds = %3
br label %15
8: ; preds = %3
br label %15
9: ; preds = %3
br label %15
10: ; preds = %3
br label %15
11: ; preds = %3
br label %15
12: ; preds = %3
br label %15
13: ; preds = %3
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @dhcp6optstr.genstr, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %0)
br label %15
15: ; preds = %3, %1, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
%16 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @dhcp6optstr.genstr, i64 0, i64 0), %13 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), %10 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %3 ]
ret i8* %16
}