#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__ is_uri_char_scheme(char const);
int /*<<< orphan*/ isalpha(int /*<<< orphan*/);
int str_is_uri_scheme(const char *scheme) {
  if (!isalpha(*scheme++))
    return 0;
  while (is_uri_char_scheme(*scheme))
    ++scheme;
  return *scheme == '\0';
}


x86 assembly (clang, -O0):
<str_is_uri_scheme>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    1158 <str_is_uri_scheme+0x38>
movl   $0x0,-0x4(%rbp)
jmp    1199 <str_is_uri_scheme+0x79>
jmp    115d <str_is_uri_scheme+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_uri_char_scheme@plt>
cmp    $0x0,%rax
je     1184 <str_is_uri_scheme+0x64>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115d <str_is_uri_scheme+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_is_uri_scheme>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     115c <str_is_uri_scheme+0x3c>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1030 <is_uri_char_scheme@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <str_is_uri_scheme+0x20>
xor    %eax,%eax
cmpb   $0x0,-0x1(%rbx)
sete   %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @str_is_uri_scheme(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i32 1
store i8* %5, i8** %3
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = call i32 @isalpha(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %26
11: ; preds = %1
br label %12
12: ; preds = %17, %11
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = call i64 @is_uri_char_scheme(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %12
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
store i32 %25, i32* %2
br label %26
26: ; preds = %20, %10
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @str_is_uri_scheme(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = tail call i32 @isalpha(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1, %6
%7 = phi i8* [ %8, %6 ], [ %0, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = tail call i64 @is_uri_char_scheme(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = load i8, i8* %8
%14 = icmp eq i8 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %1, %12
%17 = phi i32 [ %15, %12 ], [ 0, %1 ]
ret i32 %17
}