#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 */
struct ncprange {
  int dummy;
};

/* Variables and functions */
char const *ncprange_ntoa(struct ncprange *);
const char *addrstr(struct ncprange *addr, unsigned type) {
  switch (type) {
  case 1:
    return "MYADDR";
  case 3:
    return "HISADDR";
  case 5:
    return "DNS0";
  case 6:
    return "DNS1";
  }
  return ncprange_ntoa(addr);
}


x86 assembly (clang, -O0):
<addrstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1188 <addrstr+0x78>
mov    -0x20(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <addrstr+0x85>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <addrstr+0x85>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <addrstr+0x85>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <addrstr+0x85>
mov    -0x10(%rbp),%rdi
call   1030 <ncprange_ntoa@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addrstr>:
add    $0xffffffff,%esi
cmp    $0x6,%esi
jae    1122 <addrstr+0x12>
mov    $0x35,%eax
bt     %esi,%eax
jb     1127 <addrstr+0x17>
jmp    1030 <ncprange_ntoa@plt>
movslq %esi,%rax
lea    0xeeb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
%struct.ncprange = type { i32 }
@.str = [7 x i8] c"MYADDR\00"
@.str.1 = [8 x i8] c"HISADDR\00"
@.str.2 = [5 x i8] c"DNS0\00"
@.str.3 = [5 x i8] c"DNS1\00"
define i8* @addrstr(%struct.ncprange* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.ncprange*
%5 = alloca i32
store %struct.ncprange* %0, %struct.ncprange** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %11 [
i32 1, label %7
i32 3, label %8
i32 5, label %9
i32 6, label %10
]
7: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
br label %14
8: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %14
9: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %14
10: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %14
11: ; preds = %2
%12 = load %struct.ncprange*, %struct.ncprange** %4
%13 = call i8* @ncprange_ntoa(%struct.ncprange* %12)
store i8* %13, i8** %3
br label %14
14: ; preds = %11, %10, %9, %8, %7
%15 = load i8*, i8** %3
ret i8* %15
}

LLVM IR (-O2):
%struct.ncprange = type { i32 }
@.str = [7 x i8] c"MYADDR\00"
@.str.1 = [8 x i8] c"HISADDR\00"
@.str.2 = [5 x i8] c"DNS0\00"
@.str.3 = [5 x i8] c"DNS1\00"
@reltable.addrstr = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.addrstr to i64)) to i32)]
define i8* @addrstr(%struct.ncprange* %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 6
br i1 %4, label %7, label %5
5: ; preds = %7, %2
%6 = tail call i8* @ncprange_ntoa(%struct.ncprange* %0)
br label %16
7: ; preds = %2
%8 = trunc i32 %3 to i8
%9 = lshr i8 53, %8
%10 = and i8 %9, 1
%11 = icmp eq i8 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %7
%13 = sext i32 %3 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.addrstr to i8*), i64 %14)
br label %16
16: ; preds = %12, %5
%17 = phi i8* [ %6, %5 ], [ %15, %12 ]
ret i8* %17
}