#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*/ qtype_strings;
typedef int /*<<< orphan*/ qtype_codes;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int parse_query(char *input, char *qname, int qnlen, int *qtype) {
  static char *qtype_strings[] = {
      "A",     "NS",  "MD",   "MF",    "CNAME", "SOA", "MB",  "MG",   "MR",
      "NULL",  "WKS", "PTR",  "HINFO", "MINFO", "MX",  "TXT", "AAAA", "SRV",
      "NAPTR", "A6",  "AXFR", "MAILB", "MAILA", "*",   "ANY"};
  static int qtype_codes[] = {1,  2,  3,   4,   5,   6,   7,  8,  9,
                              10, 11, 12,  13,  14,  15,  16, 28, 33,
                              35, 38, 252, 253, 254, 255, 255};
  int num_types, index;
  int found = 0;
  char incopy[512 + 1];
  char *domain_str, *type_str;
  num_types = sizeof(qtype_strings) / sizeof(qtype_strings[0]);
  if (num_types > (sizeof(qtype_codes) / sizeof(int)))
    num_types = sizeof(qtype_codes) / sizeof(int);
  strcpy(incopy, input);
  domain_str = strtok(incopy, " \t\n");
  type_str = strtok(NULL, " \t\n");
  if ((domain_str == NULL) || (type_str == NULL)) {
    fprintf(stderr, "Invalid query input format: %s\n", input);
    return (-1);
  }
  if (strlen(domain_str) > qnlen) {
    fprintf(stderr, "Query domain too long: %s\n", domain_str);
    return (-1);
  }
  for (index = 0; (index < num_types) && (found == 0); index++) {
    if (strcasecmp(type_str, qtype_strings[index]) == 0) {
      *qtype = qtype_codes[index];
      found = 1;
    }
  }
  if (found == 0) {
    fprintf(stderr, "Query type not understood: %s\n", type_str);
    return (-1);
  }
  strcpy(qname, domain_str);
  return (0);
}


x86 assembly (clang, -O0):
<parse_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x19,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    $0x19,%rax
jbe    118d <parse_query+0x3d>
movl   $0x19,-0x2c(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x240(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x248(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9f(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x250(%rbp)
cmpq   $0x0,-0x248(%rbp)
je     11ea <parse_query+0x9a>
cmpq   $0x0,-0x250(%rbp)
jne    120f <parse_query+0xbf>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <parse_query+0x1d3>
mov    -0x248(%rbp),%rdi
call   1050 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jle    124c <parse_query+0xfc>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    -0x248(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <parse_query+0x1d3>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x2c(%rbp),%ecx
mov    %al,-0x251(%rbp)
jge    1274 <parse_query+0x124>
cmpl   $0x0,-0x34(%rbp)
sete   %al
mov    %al,-0x251(%rbp)
mov    -0x251(%rbp),%al
test   $0x1,%al
jne    1287 <parse_query+0x137>
jmp    12da <parse_query+0x18a>
mov    -0x250(%rbp),%rdi
movslq -0x30(%rbp),%rcx
lea    0x2db7(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12c7 <parse_query+0x177>
movslq -0x30(%rbp),%rcx
lea    0x2e69(%rip),%rax
mov    (%rax,%rcx,4),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x34(%rbp)
jmp    12cc <parse_query+0x17c>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1253 <parse_query+0x103>
cmpl   $0x0,-0x34(%rbp)
jne    130c <parse_query+0x1bc>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
mov    -0x250(%rbp),%rdx
lea    0xda5(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <parse_query+0x1d3>
mov    -0x18(%rbp),%rdi
mov    -0x248(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_query>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rcx,0x8(%rsp)
mov    %edx,%r13d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0xfaf(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strtok@plt>
mov    %rax,%r12
xor    %edi,%edi
mov    %r14,%rsi
call   1070 <strtok@plt>
test   %r12,%r12
je     11cd <parse_query+0x7d>
mov    %rax,%r14
test   %rax,%rax
je     11cd <parse_query+0x7d>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    %r13d,%eax
jle    11e2 <parse_query+0x92>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xf91(%rip),%rsi
mov    %r12,%rdx
jmp    122b <parse_query+0xdb>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xf5c(%rip),%rsi
mov    %rbp,%rdx
jmp    122b <parse_query+0xdb>
xor    %ebp,%ebp
lea    0xe15(%rip),%r13
xor    %ebx,%ebx
nopl   (%rax)
movslq 0x0(%rbp,%r13,1),%rsi
add    %r13,%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1247 <parse_query+0xf7>
je     1218 <parse_query+0xc8>
lea    0x1(%rbx),%rax
add    $0x4,%rbp
cmp    $0x18,%rbx
mov    %rax,%rbx
jb     11f0 <parse_query+0xa0>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xf4c(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe22(%rip),%rax
mov    0x0(%rbp,%rax,1),%eax
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
jmp    1235 <parse_query+0xe5>

LLVM IR (-O0):
@parse_query.qtype_strings = internal global [25 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.24, i32 0, i32 0)]
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"NS\00"
@.str.2 = [3 x i8] c"MD\00"
@.str.3 = [3 x i8] c"MF\00"
@.str.4 = [6 x i8] c"CNAME\00"
@.str.5 = [4 x i8] c"SOA\00"
@.str.6 = [3 x i8] c"MB\00"
@.str.7 = [3 x i8] c"MG\00"
@.str.8 = [3 x i8] c"MR\00"
@.str.9 = [5 x i8] c"NULL\00"
@.str.10 = [4 x i8] c"WKS\00"
@.str.11 = [4 x i8] c"PTR\00"
@.str.12 = [6 x i8] c"HINFO\00"
@.str.13 = [6 x i8] c"MINFO\00"
@.str.14 = [3 x i8] c"MX\00"
@.str.15 = [4 x i8] c"TXT\00"
@.str.16 = [5 x i8] c"AAAA\00"
@.str.17 = [4 x i8] c"SRV\00"
@.str.18 = [6 x i8] c"NAPTR\00"
@.str.19 = [3 x i8] c"A6\00"
@.str.20 = [5 x i8] c"AXFR\00"
@.str.21 = [6 x i8] c"MAILB\00"
@.str.22 = [6 x i8] c"MAILA\00"
@.str.23 = [2 x i8] c"*\00"
@.str.24 = [4 x i8] c"ANY\00"
@parse_query.qtype_codes = internal global [25 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 28, i32 33, i32 35, i32 38, i32 252, i32 253, i32 254, i32 255, i32 255]
@.str.25 = [4 x i8] c" \09\0A\00"
@stderr = global i32 0
@.str.26 = [32 x i8] c"Invalid query input format: %s\0A\00"
@.str.27 = [27 x i8] c"Query domain too long: %s\0A\00"
@.str.28 = [31 x i8] c"Query type not understood: %s\0A\00"
define i32 @parse_query(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [513 x i8]
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 0, i32* %12
store i32 25, i32* %10
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = icmp ugt i64 %17, 25
br i1 %18, label %19, label %20
19: ; preds = %4
store i32 25, i32* %10
br label %20
20: ; preds = %19, %4
%21 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = getelementptr inbounds [513 x i8], [513 x i8]* %13, i64 0, i64 0
%25 = call i8* @strtok(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
store i8* %25, i8** %14
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
store i8* %26, i8** %15
%27 = load i8*, i8** %14
%28 = icmp eq i8* %27, null
br i1 %28, label %32, label %29
29: ; preds = %20
%30 = load i8*, i8** %15
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %36
32: ; preds = %29, %20
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %6
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i8* %34)
store i32 -1, i32* %5
br label %84
36: ; preds = %29
%37 = load i8*, i8** %14
%38 = call i32 @strlen(i8* %37)
%39 = load i32, i32* %8
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %14
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.27, i64 0, i64 0), i8* %43)
store i32 -1, i32* %5
br label %84
45: ; preds = %36
store i32 0, i32* %11
br label %46
46: ; preds = %70, %45
%47 = load i32, i32* %11
%48 = load i32, i32* %10
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i32, i32* %12
%52 = icmp eq i32 %51, 0
br label %53
53: ; preds = %50, %46
%54 = phi i1 [ false, %46 ], [ %52, %50 ]
br i1 %54, label %55, label %73
55: ; preds = %53
%56 = load i8*, i8** %15
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [25 x i8*], [25 x i8*]* @parse_query.qtype_strings, i64 0, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strcasecmp(i8* %56, i8* %60)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %55
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [25 x i32], [25 x i32]* @parse_query.qtype_codes, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = load i32*, i32** %9
store i32 %67, i32* %68
store i32 1, i32* %12
br label %69
69: ; preds = %63, %55
br label %70
70: ; preds = %69
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %46
73: ; preds = %53
%74 = load i32, i32* %12
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = load i8*, i8** %15
%79 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.28, i64 0, i64 0), i8* %78)
store i32 -1, i32* %5
br label %84
80: ; preds = %73
%81 = load i8*, i8** %7
%82 = load i8*, i8** %14
%83 = call i32 @strcpy(i8* %81, i8* %82)
store i32 0, i32* %5
br label %84
84: ; preds = %80, %76, %41, %32
%85 = load i32, i32* %5
ret i32 %85
}

LLVM IR (-O2):
@reltable.parse_query = internal unnamed_addr constant [25 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.13 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.14 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.15 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.16 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.18 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.19 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.20 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.21 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.22 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.23 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.24 to i64), i64 ptrtoint ([25 x i32]* @reltable.parse_query to i64)) to i32)]
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"NS\00"
@.str.2 = [3 x i8] c"MD\00"
@.str.3 = [3 x i8] c"MF\00"
@.str.4 = [6 x i8] c"CNAME\00"
@.str.5 = [4 x i8] c"SOA\00"
@.str.6 = [3 x i8] c"MB\00"
@.str.7 = [3 x i8] c"MG\00"
@.str.8 = [3 x i8] c"MR\00"
@.str.9 = [5 x i8] c"NULL\00"
@.str.10 = [4 x i8] c"WKS\00"
@.str.11 = [4 x i8] c"PTR\00"
@.str.12 = [6 x i8] c"HINFO\00"
@.str.13 = [6 x i8] c"MINFO\00"
@.str.14 = [3 x i8] c"MX\00"
@.str.15 = [4 x i8] c"TXT\00"
@.str.16 = [5 x i8] c"AAAA\00"
@.str.17 = [4 x i8] c"SRV\00"
@.str.18 = [6 x i8] c"NAPTR\00"
@.str.19 = [3 x i8] c"A6\00"
@.str.20 = [5 x i8] c"AXFR\00"
@.str.21 = [6 x i8] c"MAILB\00"
@.str.22 = [6 x i8] c"MAILA\00"
@.str.23 = [2 x i8] c"*\00"
@.str.24 = [4 x i8] c"ANY\00"
@parse_query.qtype_codes = internal unnamed_addr constant [25 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 28, i32 33, i32 35, i32 38, i32 252, i32 253, i32 254, i32 255, i32 255]
@.str.25 = [4 x i8] c" \09\0A\00"
@stderr = global i32 0
@.str.26 = [32 x i8] c"Invalid query input format: %s\0A\00"
@.str.27 = [27 x i8] c"Query domain too long: %s\0A\00"
@.str.28 = [31 x i8] c"Query type not understood: %s\0A\00"
define i32 @parse_query(i8* %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca [513 x i8]
%6 = getelementptr inbounds [513 x i8], [513 x i8]* %5, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* %0)
%8 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%10 = icmp eq i8* %8, null
%11 = icmp eq i8* %9, null
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i8* %0)
br label %39
16: ; preds = %4
%17 = call i32 @strlen(i8* %8)
%18 = icmp sgt i32 %17, %2
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.27, i64 0, i64 0), i8* %8)
br label %39
22: ; preds = %16, %28
%23 = phi i64 [ %29, %28 ], [ 0, %16 ]
%24 = shl i64 %23, 2
%25 = call i8* @llvm.load.relative.i64(i8* bitcast ([25 x i32]* @reltable.parse_query to i8*), i64 %24)
%26 = call i64 @strcasecmp(i8* %9, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %22
%29 = add nuw nsw i64 %23, 1
%30 = icmp ugt i64 %23, 23
%31 = or i1 %27, %30
br i1 %31, label %32, label %22
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.28, i64 0, i64 0), i8* %9)
br label %39
35: ; preds = %22
%36 = getelementptr inbounds [25 x i32], [25 x i32]* @parse_query.qtype_codes, i64 0, i64 %23
%37 = load i32, i32* %36
store i32 %37, i32* %3
%38 = call i32 @strcpy(i8* %1, i8* %8)
br label %39
39: ; preds = %35, %32, %19, %13
%40 = phi i32 [ -1, %13 ], [ -1, %19 ], [ -1, %32 ], [ 0, %35 ]
ret i32 %40
}