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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ evhttp_uri_join(struct evhttp_uri *, char *, int);
struct evhttp_uri *evhttp_uri_parse(char *);
int /*<<< orphan*/ evhttp_uri_set_host(struct evhttp_uri *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ evhttp_uri_set_port(struct evhttp_uri *, int);
int /*<<< orphan*/ evhttp_uri_set_scheme(struct evhttp_uri *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ evhttp_uri_set_userinfo(struct evhttp_uri *,
                                           int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *uri_path(struct evhttp_uri *uri, char buffer[4096]) {
  struct evhttp_uri *path;
  do {
    if (!(evhttp_uri_join(uri, buffer, 4096))) {
      fprintf(stderr, "[error] %s\n", "evhttp_uri_join(uri, buffer, URL_MAX)");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  path = evhttp_uri_parse(buffer);
  evhttp_uri_set_scheme(path, NULL);
  evhttp_uri_set_userinfo(path, 0);
  evhttp_uri_set_host(path, NULL);
  evhttp_uri_set_port(path, -1);
  do {
    if (!(evhttp_uri_join(path, buffer, 4096))) {
      fprintf(stderr, "[error] %s\n", "evhttp_uri_join(path, buffer, URL_MAX)");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  return buffer;
}


x86 assembly (clang, -O0):
<uri_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <evhttp_uri_join@plt>
cmp    $0x0,%eax
jne    11d5 <uri_path+0x55>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
lea    0xe4a(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11da <uri_path+0x5a>
mov    -0x10(%rbp),%rdi
call   1070 <evhttp_uri_parse@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <evhttp_uri_set_scheme@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1060 <evhttp_uri_set_userinfo@plt>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <evhttp_uri_set_host@plt>
mov    -0x18(%rbp),%rdi
mov    $0xffffffff,%esi
call   1030 <evhttp_uri_set_port@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <evhttp_uri_join@plt>
cmp    $0x0,%eax
jne    125f <uri_path+0xdf>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xdbb(%rip),%rsi
lea    0xde6(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1264 <uri_path+0xe4>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uri_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0x1000,%edx
call   1040 <evhttp_uri_join@plt>
test   %eax,%eax
je     11ea <uri_path+0x6a>
mov    %r14,%rdi
call   1070 <evhttp_uri_parse@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   10a0 <evhttp_uri_set_scheme@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <evhttp_uri_set_userinfo@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <evhttp_uri_set_host@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1030 <evhttp_uri_set_port@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1000,%edx
call   1040 <evhttp_uri_join@plt>
test   %eax,%eax
je     1203 <uri_path+0x83>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
lea    0xe0b(%rip),%rdx
jmp    121a <uri_path+0x9a>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
lea    0xe18(%rip),%rdx
call   1050 <fprintf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.evhttp_uri = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"[error] %s\0A\00"
@.str.1 = [38 x i8] c"evhttp_uri_join(uri, buffer, URL_MAX)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [39 x i8] c"evhttp_uri_join(path, buffer, URL_MAX)\00"
define i8* @uri_path(%struct.evhttp_uri* %0, i8* %1) {
%3 = alloca %struct.evhttp_uri*
%4 = alloca i8*
%5 = alloca %struct.evhttp_uri*
store %struct.evhttp_uri* %0, %struct.evhttp_uri** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %2
%7 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%8 = load i8*, i8** %4
%9 = call i32 @evhttp_uri_join(%struct.evhttp_uri* %7, i8* %8, i32 4096)
%10 = icmp ne i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %6
br label %17
17: ; preds = %16
%18 = load i8*, i8** %4
%19 = call %struct.evhttp_uri* @evhttp_uri_parse(i8* %18)
store %struct.evhttp_uri* %19, %struct.evhttp_uri** %5
%20 = load %struct.evhttp_uri*, %struct.evhttp_uri** %5
%21 = call i32 @evhttp_uri_set_scheme(%struct.evhttp_uri* %20, i32* null)
%22 = load %struct.evhttp_uri*, %struct.evhttp_uri** %5
%23 = call i32 @evhttp_uri_set_userinfo(%struct.evhttp_uri* %22, i32 0)
%24 = load %struct.evhttp_uri*, %struct.evhttp_uri** %5
%25 = call i32 @evhttp_uri_set_host(%struct.evhttp_uri* %24, i32* null)
%26 = load %struct.evhttp_uri*, %struct.evhttp_uri** %5
%27 = call i32 @evhttp_uri_set_port(%struct.evhttp_uri* %26, i32 -1)
br label %28
28: ; preds = %17
%29 = load %struct.evhttp_uri*, %struct.evhttp_uri** %5
%30 = load i8*, i8** %4
%31 = call i32 @evhttp_uri_join(%struct.evhttp_uri* %29, i8* %30, i32 4096)
%32 = icmp ne i32 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28
br label %39
39: ; preds = %38
%40 = load i8*, i8** %4
ret i8* %40
}

LLVM IR (-O2):
%struct.evhttp_uri = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"[error] %s\0A\00"
@.str.1 = [38 x i8] c"evhttp_uri_join(uri, buffer, URL_MAX)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [39 x i8] c"evhttp_uri_join(path, buffer, URL_MAX)\00"
define i8* @uri_path(%struct.evhttp_uri* %0, i8* returned %1) {
%3 = tail call i32 @evhttp_uri_join(%struct.evhttp_uri* %0, i8* %1, i32 4096)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = tail call %struct.evhttp_uri* @evhttp_uri_parse(i8* %1)
%12 = tail call i32 @evhttp_uri_set_scheme(%struct.evhttp_uri* %11, i32* null)
%13 = tail call i32 @evhttp_uri_set_userinfo(%struct.evhttp_uri* %11, i32 0)
%14 = tail call i32 @evhttp_uri_set_host(%struct.evhttp_uri* %11, i32* null)
%15 = tail call i32 @evhttp_uri_set_port(%struct.evhttp_uri* %11, i32 -1)
%16 = tail call i32 @evhttp_uri_join(%struct.evhttp_uri* %11, i8* %1, i32 4096)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %10
ret i8* %1
}