#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 */
typedef int /*<<< orphan*/ va_list;
struct evhttp_request {
  int dummy;
};
struct evbuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ HTTP_OK;
int /*<<< orphan*/ evbuffer_add_vprintf(struct evbuffer *, char const *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *,
                                     int /*<<< orphan*/, char *,
                                     struct evbuffer *);
void replyv(struct evhttp_request *req, const char *fmt, va_list ap) {
  struct evbuffer *buf;
  buf = evbuffer_new();
  evbuffer_add_vprintf(buf, fmt, ap);
  evhttp_send_reply(req, HTTP_OK, "OK", buf);
  evbuffer_free(buf);
}


x86 assembly (clang, -O0):
<replyv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1050 <evbuffer_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <evbuffer_add_vprintf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rcx
lea    0xe7a(%rip),%rdx
call   1060 <evhttp_send_reply@plt>
mov    -0x20(%rbp),%rdi
call   1030 <evbuffer_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replyv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <evbuffer_new@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <evbuffer_add_vprintf@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdx
mov    %r14,%rdi
mov    %rbp,%rcx
call   1060 <evhttp_send_reply@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <evbuffer_free@plt>

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@HTTP_OK = global i32 0
@.str = [3 x i8] c"OK\00"
define void @replyv(%struct.evhttp_request* %0, i8* %1, i32 %2) {
%4 = alloca %struct.evhttp_request*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.evbuffer*
store %struct.evhttp_request* %0, %struct.evhttp_request** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %8, %struct.evbuffer** %7
%9 = load %struct.evbuffer*, %struct.evbuffer** %7
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @evbuffer_add_vprintf(%struct.evbuffer* %9, i8* %10, i32 %11)
%13 = load %struct.evhttp_request*, %struct.evhttp_request** %4
%14 = load i32, i32* @HTTP_OK
%15 = load %struct.evbuffer*, %struct.evbuffer** %7
%16 = call i32 @evhttp_send_reply(%struct.evhttp_request* %13, i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.evbuffer* %15)
%17 = load %struct.evbuffer*, %struct.evbuffer** %7
%18 = call i32 @evbuffer_free(%struct.evbuffer* %17)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@HTTP_OK = global i32 0
@.str = [3 x i8] c"OK\00"
define void @replyv(%struct.evhttp_request* %0, i8* %1, i32 %2) {
%4 = tail call %struct.evbuffer* (...) @evbuffer_new()
%5 = tail call i32 @evbuffer_add_vprintf(%struct.evbuffer* %4, i8* %1, i32 %2)
%6 = load i32, i32* @HTTP_OK
%7 = tail call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.evbuffer* %4)
%8 = tail call i32 @evbuffer_free(%struct.evbuffer* %4)
ret void
}