#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 _ad_method_char_lookup(char const *, unsigned int);
int /*<<< orphan*/ ad_utils_strcmp_ic(char const *, char const *);
unsigned int strlen(char const *);
int ad_method_is_valid(register const char *input) {
  const char *const method_list[] = {
      NULL,      NULL,  NULL,   "GET",   "HEAD", "TRACE",  "DELETE",
      "OPTIONS", "PUT", "POST", "PATCH", NULL,   "CONNECT"};
  if (input) {
    register unsigned int input_len = strlen(input);
    if (input_len <= 7 && input_len >= 3) {
      register int key = _ad_method_char_lookup(input, input_len);
      if (key <= 12 && key >= 0) {
        register const char *method = method_list[key];
        if (!ad_utils_strcmp_ic(method, input))
          return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<ad_method_is_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c56(%rip),%rsi
mov    $0x68,%edx
call   1040 <memcpy@plt>
cmpq   $0x0,-0x10(%rbp)
je     120e <ad_method_is_valid+0xce>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x7,-0x84(%rbp)
ja     1209 <ad_method_is_valid+0xc9>
cmpl   $0x3,-0x84(%rbp)
jb     1209 <ad_method_is_valid+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1050 <_ad_method_char_lookup@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0xc,-0x88(%rbp)
jg     1204 <ad_method_is_valid+0xc4>
cmpl   $0x0,-0x88(%rbp)
jl     1204 <ad_method_is_valid+0xc4>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <ad_utils_strcmp_ic@plt>
cmp    $0x0,%eax
jne    11ff <ad_method_is_valid+0xbf>
movl   $0x1,-0x4(%rbp)
jmp    1215 <ad_method_is_valid+0xd5>
jmp    1204 <ad_method_is_valid+0xc4>
jmp    1209 <ad_method_is_valid+0xc9>
jmp    120e <ad_method_is_valid+0xce>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ad_method_is_valid>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1177 <ad_method_is_valid+0x47>
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    -0x3(%rax),%ecx
cmp    $0x4,%ecx
ja     1177 <ad_method_is_valid+0x47>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <_ad_method_char_lookup@plt>
cmp    $0xc,%eax
ja     1177 <ad_method_is_valid+0x47>
mov    %eax,%eax
lea    0x2c4e(%rip),%rcx
mov    (%rcx,%rax,8),%rdi
mov    %rbx,%rsi
call   1050 <ad_utils_strcmp_ic@plt>
test   %eax,%eax
jne    1177 <ad_method_is_valid+0x47>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"GET\00"
@.str.1 = [5 x i8] c"HEAD\00"
@.str.2 = [6 x i8] c"TRACE\00"
@.str.3 = [7 x i8] c"DELETE\00"
@.str.4 = [8 x i8] c"OPTIONS\00"
@.str.5 = [4 x i8] c"PUT\00"
@.str.6 = [5 x i8] c"POST\00"
@.str.7 = [6 x i8] c"PATCH\00"
@.str.8 = [8 x i8] c"CONNECT\00"
@__const.ad_method_is_valid.method_list = [13 x i8*] [i8* null, i8* null, i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 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 ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0)]
define i32 @ad_method_is_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [13 x i8*]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = bitcast [13 x i8*]* %4 to i8*
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %41
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp ule i32 %14, 7
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = load i32, i32* %5
%18 = icmp uge i32 %17, 3
br i1 %18, label %19, label %40
19: ; preds = %16
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = call i32 @_ad_method_char_lookup(i8* %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp sle i32 %23, 12
br i1 %24, label %25, label %39
25: ; preds = %19
%26 = load i32, i32* %6
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [13 x i8*], [13 x i8*]* %4, i64 0, i64 %30
%32 = load i8*, i8** %31
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = load i8*, i8** %3
%35 = call i32 @ad_utils_strcmp_ic(i8* %33, i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %28
store i32 1, i32* %2
br label %42
38: ; preds = %28
br label %39
39: ; preds = %38, %25, %19
br label %40
40: ; preds = %39, %16, %11
br label %41
41: ; preds = %40, %1
store i32 0, i32* %2
br label %42
42: ; preds = %41, %37
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [4 x i8] c"GET\00"
@.str.1 = [5 x i8] c"HEAD\00"
@.str.2 = [6 x i8] c"TRACE\00"
@.str.3 = [7 x i8] c"DELETE\00"
@.str.4 = [8 x i8] c"OPTIONS\00"
@.str.5 = [4 x i8] c"PUT\00"
@.str.6 = [5 x i8] c"POST\00"
@.str.7 = [6 x i8] c"PATCH\00"
@.str.8 = [8 x i8] c"CONNECT\00"
@__const.ad_method_is_valid.method_list = [13 x i8*] [i8* null, i8* null, i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 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 ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0)]
define i32 @ad_method_is_valid(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = add i32 %4, -3
%6 = icmp ult i32 %5, 5
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = tail call i32 @_ad_method_char_lookup(i8* %0, i32 %4)
%9 = icmp ult i32 %8, 13
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = zext i32 %8 to i64
%12 = getelementptr inbounds [13 x i8*], [13 x i8*]* @__const.ad_method_is_valid.method_list, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32 @ad_utils_strcmp_ic(i8* %13, i8* %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %7, %10
br label %17
17: ; preds = %3, %1, %16, %10
%18 = phi i32 [ 1, %10 ], [ 0, %16 ], [ 0, %1 ], [ 0, %3 ]
ret i32 %18
}