#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 */
typedef int /*<<< orphan*/ uint16_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ ns_c_2;
int /*<<< orphan*/ ns_c_any;
int /*<<< orphan*/ ns_c_chaos;
int /*<<< orphan*/ ns_c_hs;
int /*<<< orphan*/ ns_c_in;
int /*<<< orphan*/ ns_c_none;
int /*<<< orphan*/ strcasecmp(char const *, char *);
int32_t dns_class_number(const char *c, uint16_t *n) {
  if (c == NULL)
    return -1;
  if (!strcasecmp(c, "IN")) {
    *n = ns_c_in;
    return 0;
  }
  if (!strcasecmp(c, "CS")) {
    *n = ns_c_2;
    return 0;
  }
  if (!strcasecmp(c, "CH")) {
    *n = ns_c_chaos;
    return 0;
  }
  if (!strcasecmp(c, "HS")) {
    *n = ns_c_hs;
    return 0;
  }
  if (!strcasecmp(c, "NONE")) {
    *n = ns_c_none;
    return 0;
  }
  if (!strcasecmp(c, "ANY")) {
    *n = ns_c_any;
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<dns_class_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1137 <dns_class_number+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    116b <dns_class_number+0x5b>
mov    0x2e69(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    119f <dns_class_number+0x8f>
mov    0x2e4d(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11d3 <dns_class_number+0xc3>
mov    0x2e31(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1207 <dns_class_number+0xf7>
mov    0x2ddd(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    123b <dns_class_number+0x12b>
mov    0x2da1(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    126f <dns_class_number+0x15f>
mov    0x2d8d(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1276 <dns_class_number+0x166>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_class_number>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     11d2 <dns_class_number+0xc2>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xed1(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11a0 <dns_class_number+0x90>
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11a9 <dns_class_number+0x99>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b2 <dns_class_number+0xa2>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11bb <dns_class_number+0xab>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11c4 <dns_class_number+0xb4>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
jne    11d2 <dns_class_number+0xc2>
mov    0x2e4a(%rip),%rax
jmp    11cb <dns_class_number+0xbb>
mov    0x2e19(%rip),%rax
jmp    11cb <dns_class_number+0xbb>
mov    0x2e28(%rip),%rax
jmp    11cb <dns_class_number+0xbb>
mov    0x2e37(%rip),%rax
jmp    11cb <dns_class_number+0xbb>
mov    0x2e0e(%rip),%rax
jmp    11cb <dns_class_number+0xbb>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"IN\00"
@ns_c_in = global i32 0
@.str.1 = [3 x i8] c"CS\00"
@ns_c_2 = global i32 0
@.str.2 = [3 x i8] c"CH\00"
@ns_c_chaos = global i32 0
@.str.3 = [3 x i8] c"HS\00"
@ns_c_hs = global i32 0
@.str.4 = [5 x i8] c"NONE\00"
@ns_c_none = global i32 0
@.str.5 = [4 x i8] c"ANY\00"
@ns_c_any = global i32 0
define i32 @dns_class_number(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %52
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strcasecmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i32, i32* @ns_c_in
%15 = load i32*, i32** %5
store i32 %14, i32* %15
store i32 0, i32* %3
br label %52
16: ; preds = %9
%17 = load i8*, i8** %4
%18 = call i32 @strcasecmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* @ns_c_2
%22 = load i32*, i32** %5
store i32 %21, i32* %22
store i32 0, i32* %3
br label %52
23: ; preds = %16
%24 = load i8*, i8** %4
%25 = call i32 @strcasecmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i32, i32* @ns_c_chaos
%29 = load i32*, i32** %5
store i32 %28, i32* %29
store i32 0, i32* %3
br label %52
30: ; preds = %23
%31 = load i8*, i8** %4
%32 = call i32 @strcasecmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @ns_c_hs
%36 = load i32*, i32** %5
store i32 %35, i32* %36
store i32 0, i32* %3
br label %52
37: ; preds = %30
%38 = load i8*, i8** %4
%39 = call i32 @strcasecmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = load i32, i32* @ns_c_none
%43 = load i32*, i32** %5
store i32 %42, i32* %43
store i32 0, i32* %3
br label %52
44: ; preds = %37
%45 = load i8*, i8** %4
%46 = call i32 @strcasecmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = load i32, i32* @ns_c_any
%50 = load i32*, i32** %5
store i32 %49, i32* %50
store i32 0, i32* %3
br label %52
51: ; preds = %44
store i32 -1, i32* %3
br label %52
52: ; preds = %51, %48, %41, %34, %27, %20, %13, %8
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"IN\00"
@ns_c_in = global i32 0
@.str.1 = [3 x i8] c"CS\00"
@ns_c_2 = global i32 0
@.str.2 = [3 x i8] c"CH\00"
@ns_c_chaos = global i32 0
@.str.3 = [3 x i8] c"HS\00"
@ns_c_hs = global i32 0
@.str.4 = [5 x i8] c"NONE\00"
@ns_c_none = global i32 0
@.str.5 = [4 x i8] c"ANY\00"
@ns_c_any = global i32 0
define i32 @dns_class_number(i8* %0, i32* nocapture writeonly %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %4
%8 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19, %16, %13, %10, %7, %4
%23 = phi i32* [ @ns_c_in, %4 ], [ @ns_c_2, %7 ], [ @ns_c_chaos, %10 ], [ @ns_c_hs, %13 ], [ @ns_c_none, %16 ], [ @ns_c_any, %19 ]
%24 = load i32, i32* %23
store i32 %24, i32* %1
br label %25
25: ; preds = %22, %19, %2
%26 = phi i32 [ -1, %2 ], [ -1, %19 ], [ 0, %22 ]
ret i32 %26
}