#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 */
scalar_t__ custom_strncasecmp(unsigned char const *, unsigned char const *,
                              int);
int compare_tag_cd(const unsigned char *src, const unsigned char *tag,
                   int taglen) {
  const unsigned char *rpos = src;
  if (*rpos == '\0')
    return (1);
  if (custom_strncasecmp(rpos, tag, taglen) == 0) {
    switch (*(rpos + taglen)) {
    case ' ':
    case '>':
    case '/':
    case '\n':
      return (0);
    default:
      return (1);
    }
  }
  return (1);
}


x86 assembly (clang, -O0):
<compare_tag_cd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1147 <compare_tag_cd+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <compare_tag_cd+0xc0>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <custom_strncasecmp@plt>
cmp    $0x0,%rax
jne    11c9 <compare_tag_cd+0xb9>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
sub    $0xa,%eax
je     11b1 <compare_tag_cd+0xa1>
jmp    117e <compare_tag_cd+0x6e>
mov    -0x2c(%rbp),%eax
sub    $0x20,%eax
je     11b1 <compare_tag_cd+0xa1>
jmp    118f <compare_tag_cd+0x7f>
mov    -0x2c(%rbp),%eax
sub    $0x2f,%eax
je     11b1 <compare_tag_cd+0xa1>
jmp    11a0 <compare_tag_cd+0x90>
mov    -0x2c(%rbp),%eax
sub    $0x3e,%eax
jne    11bd <compare_tag_cd+0xad>
jmp    11b1 <compare_tag_cd+0xa1>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <compare_tag_cd+0xc0>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <compare_tag_cd+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_tag_cd>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%r14d
cmpb   $0x0,(%rdi)
je     1154 <compare_tag_cd+0x44>
mov    %edx,%ebp
mov    %rdi,%rbx
call   1030 <custom_strncasecmp@plt>
test   %rax,%rax
jne    1154 <compare_tag_cd+0x44>
movslq %ebp,%rax
movzbl (%rbx,%rax,1),%eax
cmp    $0x3e,%rax
ja     114e <compare_tag_cd+0x3e>
xor    %r14d,%r14d
movabs $0x4000800100000400,%rcx
bt     %rax,%rcx
jb     1154 <compare_tag_cd+0x44>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @compare_tag_cd(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
store i8* %9, i8** %8
%10 = load i8*, i8** %8
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 1, i32* %4
br label %31
15: ; preds = %3
%16 = load i8*, i8** %8
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i64 @custom_strncasecmp(i8* %16, i8* %17, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = load i8*, i8** %8
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
switch i32 %27, label %29 [
i32 32, label %28
i32 62, label %28
i32 47, label %28
i32 10, label %28
]
28: ; preds = %21, %21, %21, %21
store i32 0, i32* %4
br label %31
29: ; preds = %21
store i32 1, i32* %4
br label %31
30: ; preds = %15
store i32 1, i32* %4
br label %31
31: ; preds = %30, %29, %28, %14
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
define i32 @compare_tag_cd(i8* %0, i8* %1, i32 %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i64 @custom_strncasecmp(i8* %0, i8* %1, i32 %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 32, label %14
i8 62, label %14
i8 47, label %14
i8 10, label %14
]
13: ; preds = %9
br label %14
14: ; preds = %6, %9, %9, %9, %9, %3, %13
%15 = phi i32 [ 1, %13 ], [ 1, %3 ], [ 0, %9 ], [ 0, %9 ], [ 0, %9 ], [ 0, %9 ], [ 1, %6 ]
ret i32 %15
}