#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_uri_remote_scheme(char *p) {
  char *scheme[] = {"http:", "https:", "ftp:", "git:", "gopher:"};
  int schemelen[] = {5, 6, 4, 4, 7};
  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_uri_remote_scheme>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xebd(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeb4(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x50(%rbp)
movl   $0x5,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    11f2 <is_uri_remote_scheme+0xd2>
mov    -0x10(%rbp),%rdi
movslq -0x64(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11df <is_uri_remote_scheme+0xbf>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <is_uri_remote_scheme+0xd9>
jmp    11e4 <is_uri_remote_scheme+0xc4>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11a0 <is_uri_remote_scheme+0x80>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_uri_remote_scheme>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
mov    $0x5,%ebp
mov    $0x5,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11a2 <is_uri_remote_scheme+0x92>
lea    0xecf(%rip),%rsi
mov    $0x6,%ebp
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11a2 <is_uri_remote_scheme+0x92>
lea    0xeb9(%rip),%rsi
mov    $0x4,%ebp
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11a2 <is_uri_remote_scheme+0x92>
lea    0xea1(%rip),%rsi
mov    $0x4,%ebp
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     11a2 <is_uri_remote_scheme+0x92>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
neg    %eax
sbb    %ebp,%ebp
or     $0x7,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"http:\00"
@.str.1 = [7 x i8] c"https:\00"
@.str.2 = [5 x i8] c"ftp:\00"
@.str.3 = [5 x i8] c"git:\00"
@.str.4 = [8 x i8] c"gopher:\00"
define i32 @is_uri_remote_scheme(i8* nocapture %0) {
%2 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i32 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, 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
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 7)
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 7, i32 -1
br label %17
17: ; preds = %13, %10, %7, %4, %1
%18 = phi i32 [ 5, %1 ], [ 6, %4 ], [ 4, %7 ], [ 4, %10 ], [ %16, %13 ]
ret i32 %18
}