#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_request {
  int dummy;
};
struct evbuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ evbuffer_add(struct evbuffer *, char const *, size_t);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
int /*<<< orphan*/ evhttp_add_header(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ evhttp_request_get_output_headers(struct evhttp_request *);
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *, int, char *,
                                     struct evbuffer *);
void send_client_reply(struct evhttp_request *req, const char *p, size_t sz,
                       const char *content_type) {
  const char *ct = content_type;
  struct evbuffer *evb = evbuffer_new();
  evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", ct);
  evbuffer_add(evb, p, sz);
  evhttp_send_reply(req, 200, "OK", evb);
  evbuffer_free(evb);
}


x86 assembly (clang, -O0):
<send_client_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <evbuffer_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <evhttp_request_get_output_headers@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rdx
lea    0xe5f(%rip),%rsi
call   1070 <evhttp_add_header@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <evbuffer_add@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0xc8,%esi
lea    0xe42(%rip),%rdx
call   1080 <evhttp_send_reply@plt>
mov    -0x30(%rbp),%rdi
call   1030 <evbuffer_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_client_reply>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %eax,%eax
call   1060 <evbuffer_new@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1050 <evhttp_request_get_output_headers@plt>
lea    0xe72(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
call   1070 <evhttp_add_header@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <evbuffer_add@plt>
lea    0xe60(%rip),%rdx
mov    %r13,%rdi
mov    $0xc8,%esi
mov    %rbx,%rcx
call   1080 <evhttp_send_reply@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <evbuffer_free@plt>

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [13 x i8] c"Content-Type\00"
@.str.1 = [3 x i8] c"OK\00"
define void @send_client_reply(%struct.evhttp_request* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca %struct.evhttp_request*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.evbuffer*
store %struct.evhttp_request* %0, %struct.evhttp_request** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
store i8* %11, i8** %9
%12 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %12, %struct.evbuffer** %10
%13 = load %struct.evhttp_request*, %struct.evhttp_request** %5
%14 = call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %13)
%15 = load i8*, i8** %9
%16 = call i32 @evhttp_add_header(i32 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load %struct.evbuffer*, %struct.evbuffer** %10
%18 = load i8*, i8** %6
%19 = load i64, i64* %7
%20 = call i32 @evbuffer_add(%struct.evbuffer* %17, i8* %18, i64 %19)
%21 = load %struct.evhttp_request*, %struct.evhttp_request** %5
%22 = load %struct.evbuffer*, %struct.evbuffer** %10
%23 = call i32 @evhttp_send_reply(%struct.evhttp_request* %21, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.evbuffer* %22)
%24 = load %struct.evbuffer*, %struct.evbuffer** %10
%25 = call i32 @evbuffer_free(%struct.evbuffer* %24)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [13 x i8] c"Content-Type\00"
@.str.1 = [3 x i8] c"OK\00"
define void @send_client_reply(%struct.evhttp_request* %0, i8* %1, i64 %2, i8* %3) {
%5 = tail call %struct.evbuffer* (...) @evbuffer_new()
%6 = tail call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %0)
%7 = tail call i32 @evhttp_add_header(i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = tail call i32 @evbuffer_add(%struct.evbuffer* %5, i8* %1, i64 %2)
%9 = tail call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.evbuffer* %5)
%10 = tail call i32 @evbuffer_free(%struct.evbuffer* %5)
ret void
}