#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__ get_host(char const *);
scalar_t__ get_protocol(char const *);
size_t strlen(scalar_t__);
const char *get_uri(const char *url) {
  size_t proto_len = 0;
  if (get_protocol(url))
    proto_len = strlen(get_protocol(url));
  size_t host_len = strlen(get_host(url));
  url = url + proto_len + host_len;
  if (*url != '\0')
    return url;
  else
    return "/";
}


x86 assembly (clang, -O0):
<get_uri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_protocol@plt>
cmp    $0x0,%rax
je     116c <get_uri+0x3c>
mov    -0x10(%rbp),%rdi
call   1050 <get_protocol@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_host@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ae <get_uri+0x7e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <get_uri+0x89>
lea    0xe4b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_uri>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <get_protocol@plt>
test   %rax,%rax
je     1156 <get_uri+0x26>
mov    %r14,%rdi
call   1050 <get_protocol@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
jmp    1158 <get_uri+0x28>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1040 <get_host@plt>
mov    %rax,%rdi
call   1030 <strlen@plt>
add    %r14,%rbx
cmpb   $0x0,(%rax,%rbx,1)
lea    (%rbx,%rax,1),%rcx
lea    0xe86(%rip),%rax
cmovne %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @get_uri(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
%6 = load i8*, i8** %3
%7 = call i64 @get_protocol(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @get_protocol(i8* %10)
%12 = call i64 @strlen(i64 %11)
store i64 %12, i64* %4
br label %13
13: ; preds = %9, %1
%14 = load i8*, i8** %3
%15 = call i64 @get_host(i8* %14)
%16 = call i64 @strlen(i64 %15)
store i64 %16, i64* %5
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i64, i64* %5
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %13
%27 = load i8*, i8** %3
store i8* %27, i8** %2
br label %29
28: ; preds = %13
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %29
29: ; preds = %28, %26
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @get_uri(i8* %0) {
%2 = tail call i64 @get_protocol(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @get_protocol(i8* %0)
%6 = tail call i64 @strlen(i64 %5)
br label %7
7: ; preds = %4, %1
%8 = phi i64 [ %6, %4 ], [ 0, %1 ]
%9 = tail call i64 @get_host(i8* %0)
%10 = tail call i64 @strlen(i64 %9)
%11 = getelementptr inbounds i8, i8* %0, i64 %8
%12 = getelementptr inbounds i8, i8* %11, i64 %10
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %12
ret i8* %15
}