#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 */
char *strchr(char *, char);
scalar_t__ strcmp_suffix(char *, char *);
size_t strlen(char *);
scalar_t__ strncmp_suffix(char *, char *, int);
char *strstr(char *, char *);
int name_spec_is_quantum(char *spec) {
  char *nameEnd, *where;
  char before, after;
  if (spec == NULL)
    return 0;
  nameEnd = strchr(spec, '[');
  if (nameEnd == NULL)
    return (strcmp_suffix(spec, ".qdna") == 0);
  if (strncmp_suffix(spec, ".qdna", nameEnd - spec) == 0)
    return 1;
  where = strstr(nameEnd, "quantum");
  if (where != NULL) {
    before = where[-1];
    after = where[strlen("quantum")];
    if (((before == '[') || (before == ',')) &&
        ((after == ']') || (after == ',') || (after == '=')))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<name_spec_is_quantum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <name_spec_is_quantum+0x23>
movl   $0x0,-0x4(%rbp)
jmp    128a <name_spec_is_quantum+0x13a>
mov    -0x10(%rbp),%rdi
mov    $0x5b,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b4 <name_spec_is_quantum+0x64>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1050 <strcmp_suffix@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    128a <name_spec_is_quantum+0x13a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0xe34(%rip),%rsi
call   1060 <strncmp_suffix@plt>
cmp    $0x0,%rax
jne    11e7 <name_spec_is_quantum+0x97>
movl   $0x1,-0x4(%rbp)
jmp    128a <name_spec_is_quantum+0x13a>
mov    -0x18(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1283 <name_spec_is_quantum+0x133>
mov    -0x20(%rbp),%rax
mov    -0x1(%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xde7(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x22(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x5b,%eax
je     124b <name_spec_is_quantum+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x2c,%eax
jne    127e <name_spec_is_quantum+0x12e>
movsbl -0x22(%rbp),%eax
cmp    $0x5d,%eax
je     1272 <name_spec_is_quantum+0x122>
movsbl -0x22(%rbp),%eax
cmp    $0x2c,%eax
je     1272 <name_spec_is_quantum+0x122>
movsbl -0x22(%rbp),%eax
cmp    $0x3d,%eax
jne    127e <name_spec_is_quantum+0x12e>
movl   $0x1,-0x4(%rbp)
jmp    128a <name_spec_is_quantum+0x13a>
jmp    1283 <name_spec_is_quantum+0x133>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_spec_is_quantum>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     11db <name_spec_is_quantum+0x9b>
mov    %rdi,%rbx
mov    $0x5b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11c3 <name_spec_is_quantum+0x83>
mov    %rax,%r14
mov    %r14d,%edx
sub    %ebx,%edx
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strncmp_suffix@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11db <name_spec_is_quantum+0x9b>
lea    0xe7d(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11bf <name_spec_is_quantum+0x7f>
mov    -0x1(%rax),%cl
cmp    $0x5b,%cl
je     11a3 <name_spec_is_quantum+0x63>
cmp    $0x2c,%cl
jne    11bf <name_spec_is_quantum+0x7f>
mov    0x7(%rax),%al
add    $0xd4,%al
cmp    $0x31,%al
ja     11bf <name_spec_is_quantum+0x7f>
movzbl %al,%eax
movabs $0x2000000020001,%rcx
bt     %rax,%rcx
jb     11db <name_spec_is_quantum+0x9b>
xor    %ebp,%ebp
jmp    11db <name_spec_is_quantum+0x9b>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp_suffix@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c".qdna\00"
@.str.1 = [8 x i8] c"quantum\00"
define i32 @name_spec_is_quantum(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %67
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 91)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i64 @strcmp_suffix(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
store i32 %20, i32* %2
br label %67
21: ; preds = %11
%22 = load i8*, i8** %3
%23 = load i8*, i8** %4
%24 = load i8*, i8** %3
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @strncmp_suffix(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %21
store i32 1, i32* %2
br label %67
32: ; preds = %21
%33 = load i8*, i8** %4
%34 = call i8* @strstr(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %34, i8** %5
%35 = load i8*, i8** %5
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %66
37: ; preds = %32
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 -1
%40 = load i8, i8* %39
store i8 %40, i8* %6
%41 = load i8*, i8** %5
%42 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
store i8 %44, i8* %7
%45 = load i8, i8* %6
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 91
br i1 %47, label %52, label %48
48: ; preds = %37
%49 = load i8, i8* %6
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 44
br i1 %51, label %52, label %65
52: ; preds = %48, %37
%53 = load i8, i8* %7
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 93
br i1 %55, label %64, label %56
56: ; preds = %52
%57 = load i8, i8* %7
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 44
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i8, i8* %7
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 61
br i1 %63, label %64, label %65
64: ; preds = %60, %56, %52
store i32 1, i32* %2
br label %67
65: ; preds = %60, %48
br label %66
66: ; preds = %65, %32
store i32 0, i32* %2
br label %67
67: ; preds = %66, %64, %31, %16, %10
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
@.str = [6 x i8] c".qdna\00"
@.str.1 = [8 x i8] c"quantum\00"
define i32 @name_spec_is_quantum(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %27, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* %0, i8 signext 91)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i64 @strcmp_suffix(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
br label %27
10: ; preds = %3
%11 = ptrtoint i8* %4 to i64
%12 = ptrtoint i8* %0 to i64
%13 = sub i64 %11, %12
%14 = trunc i64 %13 to i32
%15 = tail call i64 @strncmp_suffix(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %10
%18 = tail call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %18, i64 -1
%22 = load i8, i8* %21
switch i8 %22, label %26 [
i8 91, label %23
i8 44, label %23
]
23: ; preds = %20, %20
%24 = getelementptr inbounds i8, i8* %18, i64 7
%25 = load i8, i8* %24
switch i8 %25, label %26 [
i8 93, label %27
i8 61, label %27
i8 44, label %27
]
26: ; preds = %23, %20, %17
br label %27
27: ; preds = %23, %23, %23, %10, %1, %26, %6
%28 = phi i32 [ %9, %6 ], [ 0, %26 ], [ 0, %1 ], [ 1, %10 ], [ 1, %23 ], [ 1, %23 ], [ 1, %23 ]
ret i32 %28
}