#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_get_host(struct evhttp_uri *);
scalar_t__ evhttp_uri_get_port(struct evhttp_uri *);
int /*<<< orphan*/ evhttp_uri_join(struct evhttp_uri *, char *, int);
int /*<<< orphan*/ evutil_snprintf(char *, int, char *, int /*<<< orphan*/,
                                   scalar_t__);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *uri_hostport(struct evhttp_uri *uri, char buffer[4096]) {
  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);
  ;
  do {
    if (!(evhttp_uri_get_host(uri))) {
      fprintf(stderr, "[error] %s\n", "evhttp_uri_get_host(uri)");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  do {
    if (!(evhttp_uri_get_port(uri) > 0)) {
      fprintf(stderr, "[error] %s\n", "evhttp_uri_get_port(uri) > 0");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  evutil_snprintf(buffer, 4096, "%s:%d", evhttp_uri_get_host(uri),
                  evhttp_uri_get_port(uri));
  return buffer;
}


x86 assembly (clang, -O0):
<uri_hostport>:
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   1030 <evhttp_uri_join@plt>
cmp    $0x0,%eax
jne    11b5 <uri_hostport+0x55>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
lea    0xe6a(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11ba <uri_hostport+0x5a>
jmp    11bf <uri_hostport+0x5f>
mov    -0x8(%rbp),%rdi
call   1050 <evhttp_uri_get_host@plt>
cmp    $0x0,%eax
jne    11fb <uri_hostport+0x9b>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
lea    0xe4a(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1200 <uri_hostport+0xa0>
jmp    1205 <uri_hostport+0xa5>
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_uri_get_port@plt>
cmp    $0x0,%rax
jg     1242 <uri_hostport+0xe2>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
lea    0xe1c(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1247 <uri_hostport+0xe7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <evhttp_uri_get_host@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_uri_get_port@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    %rax,%r8
mov    $0x1000,%esi
lea    0xdee(%rip),%rdx
call   1060 <evutil_snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uri_hostport>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1000,%edx
call   1030 <evhttp_uri_join@plt>
test   %eax,%eax
je     11c4 <uri_hostport+0x64>
mov    %rbx,%rdi
call   1050 <evhttp_uri_get_host@plt>
test   %eax,%eax
je     11dd <uri_hostport+0x7d>
mov    %rbx,%rdi
call   1070 <evhttp_uri_get_port@plt>
test   %rax,%rax
jle    11f6 <uri_hostport+0x96>
mov    %rbx,%rdi
call   1050 <evhttp_uri_get_host@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <evhttp_uri_get_port@plt>
lea    0xebe(%rip),%rdx
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %ebp,%ecx
mov    %rax,%r8
call   1060 <evutil_snprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
lea    0xe31(%rip),%rdx
jmp    120d <uri_hostport+0xad>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
lea    0xe3e(%rip),%rdx
jmp    120d <uri_hostport+0xad>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
lea    0xe3e(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1080 <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 = [25 x i8] c"evhttp_uri_get_host(uri)\00"
@.str.3 = [29 x i8] c"evhttp_uri_get_port(uri) > 0\00"
@.str.4 = [6 x i8] c"%s:%d\00"
define i8* @uri_hostport(%struct.evhttp_uri* %0, i8* %1) {
%3 = alloca %struct.evhttp_uri*
%4 = alloca i8*
store %struct.evhttp_uri* %0, %struct.evhttp_uri** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %2
%6 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%7 = load i8*, i8** %4
%8 = call i32 @evhttp_uri_join(%struct.evhttp_uri* %6, i8* %7, i32 4096)
%9 = icmp ne i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, 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))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %5
br label %16
16: ; preds = %15
br label %17
17: ; preds = %16
%18 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%19 = call i32 @evhttp_uri_get_host(%struct.evhttp_uri* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %17
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
%29 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%30 = call i64 @evhttp_uri_get_port(%struct.evhttp_uri* %29)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %28
br label %38
38: ; preds = %37
%39 = load i8*, i8** %4
%40 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%41 = call i32 @evhttp_uri_get_host(%struct.evhttp_uri* %40)
%42 = load %struct.evhttp_uri*, %struct.evhttp_uri** %3
%43 = call i64 @evhttp_uri_get_port(%struct.evhttp_uri* %42)
%44 = call i32 @evutil_snprintf(i8* %39, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %41, i64 %43)
%45 = load i8*, i8** %4
ret i8* %45
}

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 = [25 x i8] c"evhttp_uri_get_host(uri)\00"
@.str.3 = [29 x i8] c"evhttp_uri_get_port(uri) > 0\00"
@.str.4 = [6 x i8] c"%s:%d\00"
define i8* @uri_hostport(%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 i32 @evhttp_uri_get_host(%struct.evhttp_uri* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %10
%19 = tail call i64 @evhttp_uri_get_port(%struct.evhttp_uri* %0)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %18
%27 = tail call i32 @evhttp_uri_get_host(%struct.evhttp_uri* %0)
%28 = tail call i64 @evhttp_uri_get_port(%struct.evhttp_uri* %0)
%29 = tail call i32 @evutil_snprintf(i8* %1, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %27, i64 %28)
ret i8* %1
}