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

/* Variables and functions */
int /*<<< orphan*/ HTTP_OK;
int /*<<< orphan*/ evbuffer_add_printf(struct evbuffer *, char *);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
int /*<<< orphan*/ evhttp_add_header(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *,
                                     int /*<<< orphan*/, char *,
                                     struct evbuffer *);
void generic_request_handler(struct evhttp_request *req, void *arg) {
  evhttp_add_header(req->output_headers, "Server", "yaoniming4000");
  evhttp_add_header(req->output_headers, "Content-Type",
                    "text/html; charset=utf-8");
  struct evbuffer *returnbuffer = evbuffer_new();
  evbuffer_add_printf(returnbuffer, "Hello World!");
  evhttp_send_reply(req, HTTP_OK, "Client", returnbuffer);
  evbuffer_free(returnbuffer);
  return;
}


x86 assembly (clang, -O0):
<generic_request_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
lea    0xe93(%rip),%rdx
call   1060 <evhttp_add_header@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
lea    0xe95(%rip),%rdx
call   1060 <evhttp_add_header@plt>
mov    $0x0,%al
call   1050 <evbuffer_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <evbuffer_add_printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0xe83(%rip),%rdx
call   1070 <evhttp_send_reply@plt>
mov    -0x18(%rbp),%rdi
call   1030 <evbuffer_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generic_request_handler>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%edi
lea    0xea0(%rip),%rsi
lea    0xea0(%rip),%rdx
call   1060 <evhttp_add_header@plt>
mov    (%r14),%edi
lea    0xe9f(%rip),%rsi
lea    0xea5(%rip),%rdx
call   1060 <evhttp_add_header@plt>
xor    %eax,%eax
call   1050 <evbuffer_new@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rsi
mov    %rax,%rdi
call   1040 <evbuffer_add_printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    0xe9d(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1070 <evhttp_send_reply@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <evbuffer_free@plt>

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [7 x i8] c"Server\00"
@.str.1 = [14 x i8] c"yaoniming4000\00"
@.str.2 = [13 x i8] c"Content-Type\00"
@.str.3 = [25 x i8] c"text/html; charset=utf-8\00"
@.str.4 = [13 x i8] c"Hello World!\00"
@HTTP_OK = global i32 0
@.str.5 = [7 x i8] c"Client\00"
define void @generic_request_handler(%struct.evhttp_request* %0, i8* %1) {
%3 = alloca %struct.evhttp_request*
%4 = alloca i8*
%5 = alloca %struct.evbuffer*
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
%6 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%7 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @evhttp_add_header(i32 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%10 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%11 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @evhttp_add_header(i32 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%14 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %14, %struct.evbuffer** %5
%15 = load %struct.evbuffer*, %struct.evbuffer** %5
%16 = call i32 @evbuffer_add_printf(%struct.evbuffer* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%17 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%18 = load i32, i32* @HTTP_OK
%19 = load %struct.evbuffer*, %struct.evbuffer** %5
%20 = call i32 @evhttp_send_reply(%struct.evhttp_request* %17, i32 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %19)
%21 = load %struct.evbuffer*, %struct.evbuffer** %5
%22 = call i32 @evbuffer_free(%struct.evbuffer* %21)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [7 x i8] c"Server\00"
@.str.1 = [14 x i8] c"yaoniming4000\00"
@.str.2 = [13 x i8] c"Content-Type\00"
@.str.3 = [25 x i8] c"text/html; charset=utf-8\00"
@.str.4 = [13 x i8] c"Hello World!\00"
@HTTP_OK = global i32 0
@.str.5 = [7 x i8] c"Client\00"
define void @generic_request_handler(%struct.evhttp_request* %0, i8* nocapture readnone %1) {
%3 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 @evhttp_add_header(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* %3
%7 = tail call i32 @evhttp_add_header(i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call %struct.evbuffer* (...) @evbuffer_new()
%9 = tail call i32 @evbuffer_add_printf(%struct.evbuffer* %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%10 = load i32, i32* @HTTP_OK
%11 = tail call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %8)
%12 = tail call i32 @evbuffer_free(%struct.evbuffer* %8)
ret void
}