#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*/ scheme;

/* Variables and functions */
int /*<<< orphan*/ strncasecmp(char *, char *, int);
int is_reference_database(char *p) {
  char *scheme[] = {"arXiv:", "pubmed:", "medline:", "isi:"};
  int schemelen[] = {6, 7, 8, 4};
  int i, nschemes = sizeof(scheme) / sizeof(scheme[0]);
  for (i = 0; i < nschemes; ++i) {
    if (!strncasecmp(p, scheme[i], schemelen[i]))
      return schemelen[i];
  }
  return -1;
}


x86 assembly (clang, -O0):
<is_reference_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2cdd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cda(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cd7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cd4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed1(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x4,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    11be <is_reference_database+0xae>
mov    -0x10(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11ab <is_reference_database+0x9b>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <is_reference_database+0xb5>
jmp    11b0 <is_reference_database+0xa0>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    116c <is_reference_database+0x5c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_reference_database>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
mov    $0x6,%ebp
mov    $0x6,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1185 <is_reference_database+0x75>
lea    0xed0(%rip),%rsi
mov    $0x7,%ebp
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1185 <is_reference_database+0x75>
lea    0xebb(%rip),%rsi
mov    $0x8,%ebp
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1185 <is_reference_database+0x75>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
neg    %eax
sbb    %ebp,%ebp
or     $0x4,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"arXiv:\00"
@.str.1 = [8 x i8] c"pubmed:\00"
@.str.2 = [9 x i8] c"medline:\00"
@.str.3 = [5 x i8] c"isi:\00"
@__const.is_reference_database.scheme = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@__const.is_reference_database.schemelen = [4 x i32] [i32 6, i32 7, i32 8, i32 4]
define i32 @is_reference_database(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4 x i8*]
%5 = alloca [4 x i32]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = bitcast [4 x i8*]* %4 to i8*
%9 = bitcast [4 x i32]* %5 to i8*
store i32 4, i32* %7
store i32 0, i32* %6
br label %10
10: ; preds = %32, %1
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @strncasecmp(i8* %15, i8* %19, i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %14
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
store i32 %30, i32* %2
br label %36
31: ; preds = %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %10
35: ; preds = %10
store i32 -1, i32* %2
br label %36
36: ; preds = %35, %26
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [7 x i8] c"arXiv:\00"
@.str.1 = [8 x i8] c"pubmed:\00"
@.str.2 = [9 x i8] c"medline:\00"
@.str.3 = [5 x i8] c"isi:\00"
define i32 @is_reference_database(i8* nocapture %0) {
%2 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%3 = icmp eq i32 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 4, i32 -1
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i32 [ 6, %1 ], [ 7, %4 ], [ 8, %7 ], [ %13, %10 ]
ret i32 %15
}