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

/* Variables and functions */
int find_host_path(struct url_dat *, char *, int, char *, int);
int split_url(char *, unsigned long, char **, int *, int /*<<< orphan*/ *,
              char **, int *, int /*<<< orphan*/ *);
int find_url(struct url_dat *ud, char *url, unsigned long len) {
  char *host, *path;
  int host_len, path_len;
  int ret;
  int found;
  ret = split_url(url, len, &host, &host_len, NULL, &path, &path_len, NULL);
  if (ret < 0)
    return 0;
  found = find_host_path(ud, host, host_len, path, path_len);
  return found;
}


x86 assembly (clang, -O0):
<find_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x34(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x30(%rbp),%r9
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
call   1030 <split_url@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    117c <find_url+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    119d <find_url+0x7d>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8d
call   1040 <find_host_path@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_url>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    %rsp,%r10
xor    %ebx,%ebx
lea    0x10(%rsp),%rax
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r9
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
xor    %r8d,%r8d
push   $0x0
push   %r10
call   1030 <split_url@plt>
add    $0x10,%rsp
test   %eax,%eax
js     1177 <find_url+0x57>
mov    0x10(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%rcx
mov    (%rsp),%r8d
mov    %r14,%rdi
call   1040 <find_host_path@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.url_dat = type { i32 }
define i32 @find_url(%struct.url_dat* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca %struct.url_dat*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.url_dat* %0, %struct.url_dat** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = call i32 @split_url(i8* %14, i64 %15, i8** %8, i32* %10, i32* null, i8** %9, i32* %11, i32* null)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 0, i32* %4
br label %28
20: ; preds = %3
%21 = load %struct.url_dat*, %struct.url_dat** %5
%22 = load i8*, i8** %8
%23 = load i32, i32* %10
%24 = load i8*, i8** %9
%25 = load i32, i32* %11
%26 = call i32 @find_host_path(%struct.url_dat* %21, i8* %22, i32 %23, i8* %24, i32 %25)
store i32 %26, i32* %13
%27 = load i32, i32* %13
store i32 %27, i32* %4
br label %28
28: ; preds = %20, %19
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.url_dat = type { i32 }
define i32 @find_url(%struct.url_dat* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = call i32 @split_url(i8* %1, i64 %2, i8** %4, i32* %6, i32* null, i8** %5, i32* %7, i32* null)
%13 = icmp slt i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = call i32 @find_host_path(%struct.url_dat* %0, i8* %15, i32 %16, i8* %17, i32 %18)
br label %20
20: ; preds = %3, %14
%21 = phi i32 [ %19, %14 ], [ 0, %3 ]
ret i32 %21
}