#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 bl_entry {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
struct bl_entry *get_bl_entry(char *);
char *memchr(char *, char, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
struct bl_entry *get_bl_entry_by_url(char *url, int url_size) {
  char *hostname_end = memchr(url + 7, '/', url_size - 7);
  assert(hostname_end != NULL);
  char hostname[hostname_end - url - 7 + 1];
  memcpy(hostname, url + 7, hostname_end - url - 7);
  hostname[hostname_end - url - 7] = '\0';
  return get_bl_entry(hostname);
}


x86 assembly (clang, -O0):
<get_bl_entry_by_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x7,%rdi
mov    -0xc(%rbp),%edx
add    $0xfffffff9,%edx
mov    $0x2f,%esi
call   1040 <memchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
mov    %rcx,%rax
add    $0xfffffffffffffffa,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x9,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
add    $0x7,%rsi
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sub    $0x7,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sub    $0x7,%rax
movb   $0x0,(%rdi,%rax,1)
call   1030 <get_bl_entry@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bl_entry_by_url>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
lea    0x7(%rdi),%r14
lea    -0x7(%rsi),%edx
mov    %r14,%rdi
mov    $0x2f,%esi
call   1040 <memchr@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
sub    %r15,%r12
lea    -0x7(%r12),%rdx
lea    0x9(%r12),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <memcpy@plt>
movb   $0x0,-0x7(%r12,%rbx,1)
mov    %rbx,%rdi
call   1030 <get_bl_entry@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bl_entry = type { i32 }
define %struct.bl_entry* @get_bl_entry_by_url(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 7
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 7
%12 = call i8* @memchr(i8* %9, i8 signext 47, i32 %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %5
%18 = load i8*, i8** %3
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = sub nsw i64 %21, 7
%23 = add nsw i64 %22, 1
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %6
%25 = alloca i8, i64 %23
store i64 %23, i64* %7
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 7
%28 = load i8*, i8** %5
%29 = load i8*, i8** %3
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = sub nsw i64 %32, 7
%34 = trunc i64 %33 to i32
%35 = call i32 @memcpy(i8* %25, i8* %27, i32 %34)
%36 = load i8*, i8** %5
%37 = load i8*, i8** %3
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %37 to i64
%40 = sub i64 %38, %39
%41 = sub nsw i64 %40, 7
%42 = getelementptr inbounds i8, i8* %25, i64 %41
store i8 0, i8* %42
%43 = call %struct.bl_entry* @get_bl_entry(i8* %25)
%44 = load i8*, i8** %6
ret %struct.bl_entry* %43
}

LLVM IR (-O2):
%struct.bl_entry = type { i32 }
define %struct.bl_entry* @get_bl_entry_by_url(i8* %0, i32 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 7
%4 = add nsw i32 %1, -7
%5 = tail call i8* @memchr(i8* %3, i8 signext 47, i32 %4)
%6 = icmp ne i8* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = ptrtoint i8* %5 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = add nsw i64 %11, -7
%13 = add nsw i64 %11, -6
%14 = alloca i8, i64 %13
%15 = trunc i64 %12 to i32
%16 = call i32 @memcpy(i8* %14, i8* %3, i32 %15)
%17 = getelementptr inbounds i8, i8* %14, i64 %12
store i8 0, i8* %17
%18 = call %struct.bl_entry* @get_bl_entry(i8* %14)
ret %struct.bl_entry* %18
}