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

/* Variables and functions */
int /*<<< orphan*/ HTTP_OK;
int /*<<< orphan*/ evbuffer_add_printf(struct evbuffer *, char *,
                                       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 generic_request_handler(struct evhttp_request *req, void *arg) {
  struct evbuffer *returnbuffer = evbuffer_new();
  evbuffer_add_printf(returnbuffer, "%s", req->uri);
  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    $0x0,%al
call   1050 <evbuffer_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe94(%rip),%rsi
call   1040 <evbuffer_add_printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0xe7a(%rip),%rdx
call   1060 <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
xor    %eax,%eax
call   1050 <evbuffer_new@plt>
mov    %rax,%rbx
mov    (%r14),%edx
lea    0xea5(%rip),%rsi
mov    %rax,%rdi
call   1040 <evbuffer_add_printf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <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 = [3 x i8] c"%s\00"
@HTTP_OK = global i32 0
@.str.1 = [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 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %6, %struct.evbuffer** %5
%7 = load %struct.evbuffer*, %struct.evbuffer** %5
%8 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%9 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @evbuffer_add_printf(%struct.evbuffer* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%13 = load i32, i32* @HTTP_OK
%14 = load %struct.evbuffer*, %struct.evbuffer** %5
%15 = call i32 @evhttp_send_reply(%struct.evhttp_request* %12, i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %struct.evbuffer* %14)
%16 = load %struct.evbuffer*, %struct.evbuffer** %5
%17 = call i32 @evbuffer_free(%struct.evbuffer* %16)
ret void
}

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