#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*/ strncasecmp(char const *, char *, int);
unsigned addrtype(const char *addr) {
  if (!strncasecmp(addr, "MYADDR", 6) && (addr[6] == '\0' || addr[6] == '/'))
    return 1;
  if (!strncasecmp(addr, "MYADDR6", 7) && (addr[7] == '\0' || addr[7] == '/'))
    return 2;
  if (!strncasecmp(addr, "HISADDR", 7) && (addr[7] == '\0' || addr[7] == '/'))
    return 3;
  if (!strncasecmp(addr, "HISADDR6", 8) && (addr[8] == '\0' || addr[8] == '/'))
    return 4;
  if (!strncasecmp(addr, "DNS0", 4) && (addr[4] == '\0' || addr[4] == '/'))
    return 5;
  if (!strncasecmp(addr, "DNS1", 4) && (addr[4] == '\0' || addr[4] == '/'))
    return 6;
  return 0;
}


x86 assembly (clang, -O0):
<addrtype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1168 <addrtype+0x58>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x0,%eax
je     115c <addrtype+0x4c>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x2f,%eax
jne    1168 <addrtype+0x58>
movl   $0x1,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11b4 <addrtype+0xa4>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x0,%eax
je     11a8 <addrtype+0x98>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x2f,%eax
jne    11b4 <addrtype+0xa4>
movl   $0x2,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1200 <addrtype+0xf0>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x0,%eax
je     11f4 <addrtype+0xe4>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x2f,%eax
jne    1200 <addrtype+0xf0>
movl   $0x3,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
mov    -0x10(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    124c <addrtype+0x13c>
mov    -0x10(%rbp),%rax
movsbl 0x8(%rax),%eax
cmp    $0x0,%eax
je     1240 <addrtype+0x130>
mov    -0x10(%rbp),%rax
movsbl 0x8(%rax),%eax
cmp    $0x2f,%eax
jne    124c <addrtype+0x13c>
movl   $0x4,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
mov    -0x10(%rbp),%rdi
lea    0xdc9(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1298 <addrtype+0x188>
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x0,%eax
je     128c <addrtype+0x17c>
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x2f,%eax
jne    1298 <addrtype+0x188>
movl   $0x5,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
mov    -0x10(%rbp),%rdi
lea    0xd82(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    12e4 <addrtype+0x1d4>
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x0,%eax
je     12d8 <addrtype+0x1c8>
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x2f,%eax
jne    12e4 <addrtype+0x1d4>
movl   $0x6,-0x4(%rbp)
jmp    12eb <addrtype+0x1db>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addrtype>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11a7 <addrtype+0x97>
lea    0xed7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11bd <addrtype+0xad>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11d3 <addrtype+0xc3>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11e9 <addrtype+0xd9>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11ff <addrtype+0xef>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     1215 <addrtype+0x105>
pop    %rbx
ret
mov    0x6(%rbx),%cl
mov    $0x1,%eax
test   %cl,%cl
je     11a5 <addrtype+0x95>
cmp    $0x2f,%cl
je     11a5 <addrtype+0x95>
jmp    1129 <addrtype+0x19>
mov    0x7(%rbx),%cl
mov    $0x2,%eax
test   %cl,%cl
je     11a5 <addrtype+0x95>
cmp    $0x2f,%cl
je     11a5 <addrtype+0x95>
jmp    1141 <addrtype+0x31>
mov    0x7(%rbx),%cl
mov    $0x3,%eax
test   %cl,%cl
je     11a5 <addrtype+0x95>
cmp    $0x2f,%cl
je     11a5 <addrtype+0x95>
jmp    1159 <addrtype+0x49>
mov    0x8(%rbx),%cl
mov    $0x4,%eax
test   %cl,%cl
je     11a5 <addrtype+0x95>
cmp    $0x2f,%cl
je     11a5 <addrtype+0x95>
jmp    1171 <addrtype+0x61>
mov    0x4(%rbx),%cl
mov    $0x5,%eax
test   %cl,%cl
je     11a5 <addrtype+0x95>
cmp    $0x2f,%cl
je     11a5 <addrtype+0x95>
jmp    1189 <addrtype+0x79>
mov    0x4(%rbx),%cl
xor    %eax,%eax
cmp    $0x2f,%cl
mov    $0x6,%edx
cmove  %edx,%eax
test   %cl,%cl
cmove  %edx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"MYADDR\00"
@.str.1 = [8 x i8] c"MYADDR6\00"
@.str.2 = [8 x i8] c"HISADDR\00"
@.str.3 = [9 x i8] c"HISADDR6\00"
@.str.4 = [5 x i8] c"DNS0\00"
@.str.5 = [5 x i8] c"DNS1\00"
define i32 @addrtype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strncasecmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%6 = icmp ne i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 6
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 6
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %19, label %20
19: ; preds = %13, %7
store i32 1, i32* %2
br label %106
20: ; preds = %13, %1
%21 = load i8*, i8** %3
%22 = call i32 @strncasecmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%23 = icmp ne i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 7
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 7
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %37
36: ; preds = %30, %24
store i32 2, i32* %2
br label %106
37: ; preds = %30, %20
%38 = load i8*, i8** %3
%39 = call i32 @strncasecmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%40 = icmp ne i32 %39, 0
br i1 %40, label %54, label %41
41: ; preds = %37
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 7
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 7
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 47
br i1 %52, label %53, label %54
53: ; preds = %47, %41
store i32 3, i32* %2
br label %106
54: ; preds = %47, %37
%55 = load i8*, i8** %3
%56 = call i32 @strncasecmp(i8* %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%57 = icmp ne i32 %56, 0
br i1 %57, label %71, label %58
58: ; preds = %54
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 8
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %58
%65 = load i8*, i8** %3
%66 = getelementptr inbounds i8, i8* %65, i64 8
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 47
br i1 %69, label %70, label %71
70: ; preds = %64, %58
store i32 4, i32* %2
br label %106
71: ; preds = %64, %54
%72 = load i8*, i8** %3
%73 = call i32 @strncasecmp(i8* %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%74 = icmp ne i32 %73, 0
br i1 %74, label %88, label %75
75: ; preds = %71
%76 = load i8*, i8** %3
%77 = getelementptr inbounds i8, i8* %76, i64 4
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 0
br i1 %80, label %87, label %81
81: ; preds = %75
%82 = load i8*, i8** %3
%83 = getelementptr inbounds i8, i8* %82, i64 4
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 47
br i1 %86, label %87, label %88
87: ; preds = %81, %75
store i32 5, i32* %2
br label %106
88: ; preds = %81, %71
%89 = load i8*, i8** %3
%90 = call i32 @strncasecmp(i8* %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%91 = icmp ne i32 %90, 0
br i1 %91, label %105, label %92
92: ; preds = %88
%93 = load i8*, i8** %3
%94 = getelementptr inbounds i8, i8* %93, i64 4
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 0
br i1 %97, label %104, label %98
98: ; preds = %92
%99 = load i8*, i8** %3
%100 = getelementptr inbounds i8, i8* %99, i64 4
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp eq i32 %102, 47
br i1 %103, label %104, label %105
104: ; preds = %98, %92
store i32 6, i32* %2
br label %106
105: ; preds = %98, %88
store i32 0, i32* %2
br label %106
106: ; preds = %105, %104, %87, %70, %53, %36, %19
%107 = load i32, i32* %2
ret i32 %107
}

LLVM IR (-O2):
@.str = [7 x i8] c"MYADDR\00"
@.str.1 = [8 x i8] c"MYADDR6\00"
@.str.2 = [8 x i8] c"HISADDR\00"
@.str.3 = [9 x i8] c"HISADDR6\00"
@.str.4 = [5 x i8] c"DNS0\00"
@.str.5 = [5 x i8] c"DNS1\00"
define i32 @addrtype(i8* nocapture %0) {
%2 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 6
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %41
i8 47, label %41
]
7: ; preds = %4, %1
%8 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 7
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 0, label %41
i8 47, label %41
]
13: ; preds = %10, %7
%14 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %0, i64 7
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 0, label %41
i8 47, label %41
]
19: ; preds = %16, %13
%20 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %0, i64 8
%24 = load i8, i8* %23
switch i8 %24, label %25 [
i8 0, label %41
i8 47, label %41
]
25: ; preds = %22, %19
%26 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = getelementptr inbounds i8, i8* %0, i64 4
%30 = load i8, i8* %29
switch i8 %30, label %31 [
i8 0, label %41
i8 47, label %41
]
31: ; preds = %28, %25
%32 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = getelementptr inbounds i8, i8* %0, i64 4
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
%38 = icmp eq i8 %36, 47
%39 = or i1 %37, %38
%40 = select i1 %39, i32 6, i32 0
br label %41
41: ; preds = %31, %34, %28, %28, %22, %22, %16, %16, %10, %10, %4, %4
%42 = phi i32 [ 1, %4 ], [ 1, %4 ], [ 2, %10 ], [ 2, %10 ], [ 3, %16 ], [ 3, %16 ], [ 4, %22 ], [ 4, %22 ], [ 5, %28 ], [ 5, %28 ], [ %40, %34 ], [ 0, %31 ]
ret i32 %42
}