#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__ memchr(char const *, char, size_t);
char *strchr(char const *, char);
size_t strlen(char const *);
scalar_t__ strncasecmp(char const *, char const *, size_t);
int hasQualifier(const char **identifier, const char *qualifier) {
  const char *delimiter = strchr(*identifier, ':');
  if (!delimiter)
    return 0;
  size_t count = delimiter - *identifier;
  if (memchr(*identifier, '/', count))
    return 0;
  if (qualifier) {
    if (count != strlen(qualifier))
      return 0;
    if (strncasecmp(*identifier, qualifier, count) != 0)
      return 0;
  }
  *identifier += count + 1;
  return 1;
}


x86 assembly (clang, -O0):
<hasQualifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117c <hasQualifier+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1239 <hasQualifier+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x2f,%esi
call   1050 <memchr@plt>
cmp    $0x0,%rax
je     11b9 <hasQualifier+0x79>
movl   $0x0,-0x4(%rbp)
jmp    1239 <hasQualifier+0xf9>
cmpq   $0x0,-0x18(%rbp)
je     1220 <hasQualifier+0xe0>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11f1 <hasQualifier+0xb1>
movl   $0x0,-0x4(%rbp)
jmp    1239 <hasQualifier+0xf9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <strncasecmp@plt>
cmp    $0x0,%rax
je     121b <hasQualifier+0xdb>
movl   $0x0,-0x4(%rbp)
jmp    1239 <hasQualifier+0xf9>
jmp    1220 <hasQualifier+0xe0>
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasQualifier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r13
mov    (%rdi),%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11c5 <hasQualifier+0x85>
mov    %rax,%rbp
sub    %rbx,%rbp
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    %rbp,%rdx
call   1050 <memchr@plt>
test   %rax,%rax
jne    11c5 <hasQualifier+0x85>
test   %r15,%r15
je     11af <hasQualifier+0x6f>
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbp
jne    11c5 <hasQualifier+0x85>
mov    0x0(%r13),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <strncasecmp@plt>
test   %rax,%rax
jne    11c5 <hasQualifier+0x85>
jmp    11b3 <hasQualifier+0x73>
mov    0x0(%r13),%r12
lea    (%r12,%rbp,1),%rax
add    $0x1,%rax
mov    %rax,0x0(%r13)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hasQualifier(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8** %0, i8*** %4
store i8* %1, i8** %5
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 0, i32* %3
br label %51
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = ptrtoint i8* %15 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
store i64 %20, i64* %7
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
%23 = load i64, i64* %7
%24 = call i64 @memchr(i8* %22, i8 signext 47, i64 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %14
store i32 0, i32* %3
br label %51
27: ; preds = %14
%28 = load i8*, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i64, i64* %7
%32 = load i8*, i8** %5
%33 = call i64 @strlen(i8* %32)
%34 = icmp ne i64 %31, %33
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %3
br label %51
36: ; preds = %30
%37 = load i8**, i8*** %4
%38 = load i8*, i8** %37
%39 = load i8*, i8** %5
%40 = load i64, i64* %7
%41 = call i64 @strncasecmp(i8* %38, i8* %39, i64 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %36
store i32 0, i32* %3
br label %51
44: ; preds = %36
br label %45
45: ; preds = %44, %27
%46 = load i64, i64* %7
%47 = add i64 %46, 1
%48 = load i8**, i8*** %4
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 %47
store i8* %50, i8** %48
store i32 1, i32* %3
br label %51
51: ; preds = %45, %43, %35, %26, %13
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
define i32 @hasQualifier(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %27, label %6
6: ; preds = %2
%7 = ptrtoint i8* %4 to i64
%8 = ptrtoint i8* %3 to i64
%9 = sub i64 %7, %8
%10 = tail call i64 @memchr(i8* %3, i8 signext 47, i64 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %6
%13 = icmp eq i8* %1, null
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = load i8*, i8** %0
br label %23
16: ; preds = %12
%17 = tail call i64 @strlen(i8* %1)
%18 = icmp eq i64 %9, %17
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i8*, i8** %0
%21 = tail call i64 @strncasecmp(i8* %20, i8* %1, i64 %9)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %14, %19
%24 = phi i8* [ %15, %14 ], [ %20, %19 ]
%25 = add i64 %9, 1
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8* %26, i8** %0
br label %27
27: ; preds = %23, %6, %16, %19, %2
%28 = phi i32 [ 0, %2 ], [ 1, %23 ], [ 0, %6 ], [ 0, %16 ], [ 0, %19 ]
ret i32 %28
}