#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 */
struct nmodule {
  int dummy;
};

/* Variables and functions */
struct nmodule *find_module_by_name(char *);
struct nmodule *find_module_by_url(const char *url) {
  int i;
  char scheme[8];
  for (i = 0; *url && i < 8; i++) {
    scheme[i] = url[i];
    if (url[i] == ':') {
      scheme[i] = '\0';
      return find_module_by_name(scheme);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_module_by_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     1142 <find_module_by_url+0x32>
cmpl   $0x8,-0x14(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1152 <find_module_by_url+0x42>
jmp    11a8 <find_module_by_url+0x98>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1c(%rbp,%rax,1)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1195 <find_module_by_url+0x85>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x1c(%rbp,%rax,1)
lea    -0x1c(%rbp),%rdi
call   1030 <find_module_by_name@plt>
mov    %rax,-0x8(%rbp)
jmp    11b0 <find_module_by_url+0xa0>
jmp    119a <find_module_by_url+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <find_module_by_url+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_module_by_url>:
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11ab <find_module_by_url+0x9b>
mov    %al,(%rsp)
cmp    $0x3a,%al
jne    1126 <find_module_by_url+0x16>
xor    %eax,%eax
jmp    119d <find_module_by_url+0x8d>
mov    0x1(%rdi),%cl
mov    %cl,0x1(%rsp)
mov    $0x1,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x2(%rdi),%cl
mov    %cl,0x2(%rsp)
mov    $0x2,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x3(%rdi),%cl
mov    %cl,0x3(%rsp)
mov    $0x3,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x4(%rdi),%cl
mov    %cl,0x4(%rsp)
mov    $0x4,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x5(%rdi),%cl
mov    %cl,0x5(%rsp)
mov    $0x5,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x6(%rdi),%cl
mov    %cl,0x6(%rsp)
mov    $0x6,%eax
cmp    $0x3a,%cl
je     119d <find_module_by_url+0x8d>
mov    0x7(%rdi),%cl
mov    %cl,0x7(%rsp)
mov    $0x7,%eax
cmp    $0x3a,%cl
jne    11ab <find_module_by_url+0x9b>
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <find_module_by_name@plt>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.nmodule = type { i32 }
define %struct.nmodule* @find_module_by_url(i8* %0) {
%2 = alloca %struct.nmodule*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [8 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %39, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 8
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %42
16: ; preds = %14
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %23
store i8 %21, i8* %24
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 58
br i1 %31, label %32, label %38
32: ; preds = %16
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %34
store i8 0, i8* %35
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%37 = call %struct.nmodule* @find_module_by_name(i8* %36)
store %struct.nmodule* %37, %struct.nmodule** %2
br label %43
38: ; preds = %16
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %6
42: ; preds = %14
store %struct.nmodule* null, %struct.nmodule** %2
br label %43
43: ; preds = %42, %32
%44 = load %struct.nmodule*, %struct.nmodule** %2
ret %struct.nmodule* %44
}

LLVM IR (-O2):
%struct.nmodule = type { i32 }
define %struct.nmodule* @find_module_by_url(i8* nocapture %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %48, label %6
6: ; preds = %1
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
store i8 %4, i8* %7
%8 = icmp eq i8 %4, 58
br i1 %8, label %9, label %13
9: ; preds = %13, %18, %23, %28, %33, %38, %43, %6
%10 = phi i64 [ 0, %6 ], [ 1, %13 ], [ 2, %18 ], [ 3, %23 ], [ 4, %28 ], [ 5, %33 ], [ 6, %38 ], [ 7, %43 ]
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %10
store i8 0, i8* %11
%12 = call %struct.nmodule* @find_module_by_name(i8* %3)
br label %48
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = load i8, i8* %14
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
store i8 %15, i8* %16
%17 = icmp eq i8 %15, 58
br i1 %17, label %9, label %18
18: ; preds = %13
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = load i8, i8* %19
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
store i8 %20, i8* %21
%22 = icmp eq i8 %20, 58
br i1 %22, label %9, label %23
23: ; preds = %18
%24 = getelementptr inbounds i8, i8* %0, i64 3
%25 = load i8, i8* %24
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
store i8 %25, i8* %26
%27 = icmp eq i8 %25, 58
br i1 %27, label %9, label %28
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %0, i64 4
%30 = load i8, i8* %29
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
store i8 %30, i8* %31
%32 = icmp eq i8 %30, 58
br i1 %32, label %9, label %33
33: ; preds = %28
%34 = getelementptr inbounds i8, i8* %0, i64 5
%35 = load i8, i8* %34
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
store i8 %35, i8* %36
%37 = icmp eq i8 %35, 58
br i1 %37, label %9, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %0, i64 6
%40 = load i8, i8* %39
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
store i8 %40, i8* %41
%42 = icmp eq i8 %40, 58
br i1 %42, label %9, label %43
43: ; preds = %38
%44 = getelementptr inbounds i8, i8* %0, i64 7
%45 = load i8, i8* %44
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
store i8 %45, i8* %46
%47 = icmp eq i8 %45, 58
br i1 %47, label %9, label %48
48: ; preds = %43, %1, %9
%49 = phi %struct.nmodule* [ %12, %9 ], [ null, %1 ], [ null, %43 ]
ret %struct.nmodule* %49
}