#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 const *,
                                     struct evbuffer *);
void send_client_error_reply(struct evhttp_request *req, int code,
                             const char *reason, 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, code, reason, evb);
  evbuffer_free(evb);
}


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

x86 assembly (clang, -O2):
<send_client_error_reply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,(%rsp)
mov    %esi,%r13d
mov    %rdi,%rbp
xor    %eax,%eax
call   1060 <evbuffer_new@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1050 <evhttp_request_get_output_headers@plt>
lea    0xe69(%rip),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
call   1070 <evhttp_add_header@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <evbuffer_add@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    (%rsp),%rdx
mov    %r14,%rcx
call   1080 <evhttp_send_reply@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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"
define void @send_client_error_reply(%struct.evhttp_request* %0, i32 %1, i8* %2, i8* %3, i64 %4, i8* %5) {
%7 = alloca %struct.evhttp_request*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca %struct.evbuffer*
store %struct.evhttp_request* %0, %struct.evhttp_request** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
store i8* %5, i8** %12
%15 = load i8*, i8** %12
store i8* %15, i8** %13
%16 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %16, %struct.evbuffer** %14
%17 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%18 = call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %17)
%19 = load i8*, i8** %13
%20 = call i32 @evhttp_add_header(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load %struct.evbuffer*, %struct.evbuffer** %14
%22 = load i8*, i8** %10
%23 = load i64, i64* %11
%24 = call i32 @evbuffer_add(%struct.evbuffer* %21, i8* %22, i64 %23)
%25 = load %struct.evhttp_request*, %struct.evhttp_request** %7
%26 = load i32, i32* %8
%27 = load i8*, i8** %9
%28 = load %struct.evbuffer*, %struct.evbuffer** %14
%29 = call i32 @evhttp_send_reply(%struct.evhttp_request* %25, i32 %26, i8* %27, %struct.evbuffer* %28)
%30 = load %struct.evbuffer*, %struct.evbuffer** %14
%31 = call i32 @evbuffer_free(%struct.evbuffer* %30)
ret void
}

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