#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__ strncasecmp(char const *, char *, int);
const char *skip_url_prefix(const char *url, int *enclosedp,
                            const char **scheme) {
  const char *p;
  if (url == NULL) {
    return (NULL);
  }
  p = url;
  if (*p == '<') {
    *enclosedp = 1;
    ++p;
  } else {
    *enclosedp = 0;
  }
  if (strncasecmp(p, "URL:", (sizeof("URL:") - 1)) == 0) {
    p += (sizeof("URL:") - 1);
  }
  if (strncasecmp(p, "ldap://", (sizeof("ldap://") - 1)) == 0) {
    p += (sizeof("ldap://") - 1);
    *scheme = "ldap";
    return (p);
  }
  if (strncasecmp(p, "ldaps://", (sizeof("ldaps://") - 1)) == 0) {
    p += (sizeof("ldaps://") - 1);
    *scheme = "ldaps";
    return (p);
  }
  if (strncasecmp(p, "ldapi://", (sizeof("ldapi://") - 1)) == 0) {
    p += (sizeof("ldapi://") - 1);
    *scheme = "ldapi";
    return (p);
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<skip_url_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113c <skip_url_prefix+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    127e <skip_url_prefix+0x16e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    116f <skip_url_prefix+0x5f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1179 <skip_url_prefix+0x69>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11a4 <skip_url_prefix+0x94>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11ea <skip_url_prefix+0xda>
mov    -0x28(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
lea    0xe33(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    127e <skip_url_prefix+0x16e>
mov    -0x28(%rbp),%rdi
lea    0xe1d(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1230 <skip_url_prefix+0x120>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
lea    0xdfb(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    127e <skip_url_prefix+0x16e>
mov    -0x28(%rbp),%rdi
lea    0xde6(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1276 <skip_url_prefix+0x166>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
lea    0xdc4(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    127e <skip_url_prefix+0x16e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_url_prefix>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11ac <skip_url_prefix+0x9c>
mov    %rdx,%r14
mov    %rdi,%rbx
cmpb   $0x3c,(%rdi)
jne    1135 <skip_url_prefix+0x25>
movl   $0x1,(%rsi)
add    $0x1,%rbx
jmp    113b <skip_url_prefix+0x2b>
movl   $0x0,(%rsi)
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncasecmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rbx,%rcx,4),%rbx
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
test   %rax,%rax
je     11b0 <skip_url_prefix+0xa0>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
mov    $0x8,%r15d
test   %rax,%rax
je     11bf <skip_url_prefix+0xaf>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
test   %rax,%rax
je     11c8 <skip_url_prefix+0xb8>
xor    %ebx,%ebx
jmp    11d5 <skip_url_prefix+0xc5>
lea    0xe56(%rip),%rax
mov    $0x7,%r15d
jmp    11cf <skip_url_prefix+0xbf>
lea    0xe55(%rip),%rax
jmp    11cf <skip_url_prefix+0xbf>
lea    0xe5b(%rip),%rax
add    %r15,%rbx
mov    %rax,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"URL:\00"
@.str.1 = [8 x i8] c"ldap://\00"
@.str.2 = [5 x i8] c"ldap\00"
@.str.3 = [9 x i8] c"ldaps://\00"
@.str.4 = [6 x i8] c"ldaps\00"
@.str.5 = [9 x i8] c"ldapi://\00"
@.str.6 = [6 x i8] c"ldapi\00"
define i8* @skip_url_prefix(i8* %0, i32* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %3
store i8* null, i8** %4
br label %59
12: ; preds = %3
%13 = load i8*, i8** %5
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 60
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32*, i32** %6
store i32 1, i32* %19
%20 = load i8*, i8** %8
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %8
br label %24
22: ; preds = %12
%23 = load i32*, i32** %6
store i32 0, i32* %23
br label %24
24: ; preds = %22, %18
%25 = load i8*, i8** %8
%26 = call i64 @strncasecmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i64 4
store i8* %30, i8** %8
br label %31
31: ; preds = %28, %24
%32 = load i8*, i8** %8
%33 = call i64 @strncasecmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 7
store i8* %37, i8** %8
%38 = load i8**, i8*** %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %38
%39 = load i8*, i8** %8
store i8* %39, i8** %4
br label %59
40: ; preds = %31
%41 = load i8*, i8** %8
%42 = call i64 @strncasecmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 8
store i8* %46, i8** %8
%47 = load i8**, i8*** %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %47
%48 = load i8*, i8** %8
store i8* %48, i8** %4
br label %59
49: ; preds = %40
%50 = load i8*, i8** %8
%51 = call i64 @strncasecmp(i8* %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i8*, i8** %8
%55 = getelementptr inbounds i8, i8* %54, i64 8
store i8* %55, i8** %8
%56 = load i8**, i8*** %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %56
%57 = load i8*, i8** %8
store i8* %57, i8** %4
br label %59
58: ; preds = %49
store i8* null, i8** %4
br label %59
59: ; preds = %58, %53, %44, %35, %11
%60 = load i8*, i8** %4
ret i8* %60
}

LLVM IR (-O2):
@.str = [5 x i8] c"URL:\00"
@.str.1 = [8 x i8] c"ldap://\00"
@.str.2 = [5 x i8] c"ldap\00"
@.str.3 = [9 x i8] c"ldaps://\00"
@.str.4 = [6 x i8] c"ldaps\00"
@.str.5 = [9 x i8] c"ldapi://\00"
@.str.6 = [6 x i8] c"ldapi\00"
define i8* @skip_url_prefix(i8* %0, i32* nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %29, label %5
5: ; preds = %3
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 60
br i1 %7, label %8, label %10
8: ; preds = %5
store i32 1, i32* %1
%9 = getelementptr inbounds i8, i8* %0, i64 1
br label %11
10: ; preds = %5
store i32 0, i32* %1
br label %11
11: ; preds = %10, %8
%12 = phi i8* [ %9, %8 ], [ %0, %10 ]
%13 = tail call i64 @strncasecmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i64 4, i64 0
%16 = getelementptr i8, i8* %12, i64 %15
%17 = tail call i64 @strncasecmp(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %11
%20 = tail call i64 @strncasecmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = tail call i64 @strncasecmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22, %19, %11
%26 = phi i64 [ 7, %11 ], [ 8, %19 ], [ 8, %22 ]
%27 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %22 ]
%28 = getelementptr inbounds i8, i8* %16, i64 %26
store i8* %27, i8** %2
br label %29
29: ; preds = %25, %22, %3
%30 = phi i8* [ null, %3 ], [ null, %22 ], [ %28, %25 ]
ret i8* %30
}