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

/* Variables and functions */
int /*<<< orphan*/ HTTP_OK;
int /*<<< orphan*/ evbuffer_add(struct evbuffer *, char *, int);
int /*<<< orphan*/ evbuffer_add_printf(struct evbuffer *, char *, char const *);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
int /*<<< orphan*/ evhttp_add_header(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ evhttp_clear_headers(struct evkeyvalq *);
char *evhttp_find_header(struct evkeyvalq *, char *);
int /*<<< orphan*/ evhttp_parse_query(int /*<<< orphan*/, struct evkeyvalq *);
int /*<<< orphan*/ evhttp_request_get_output_headers(struct evhttp_request *);
int /*<<< orphan*/ evhttp_request_get_uri(struct evhttp_request *);
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *,
                                     int /*<<< orphan*/, char *,
                                     struct evbuffer *);
void testing(struct evhttp_request *request, void *privParams) {
  struct evbuffer *buffer;
  struct evkeyvalq headers;
  const char *q;
  evhttp_parse_query(evhttp_request_get_uri(request), &headers);
  q = evhttp_find_header(&headers, "q");
  buffer = evbuffer_new();
  evbuffer_add(buffer, "coucou !", 8);
  evbuffer_add_printf(buffer, "%s", q);
  evhttp_add_header(evhttp_request_get_output_headers(request), "Content-Type",
                    "text/plain");
  evhttp_send_reply(request, HTTP_OK, "OK", buffer);
  evhttp_clear_headers(&headers);
  evbuffer_free(buffer);
  return;
}


x86 assembly (clang, -O0):
<testing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_request_get_uri@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1090 <evhttp_parse_query@plt>
lea    -0x20(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1030 <evhttp_find_header@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10b0 <evbuffer_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe04(%rip),%rsi
mov    $0x8,%edx
call   1080 <evbuffer_add@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdf4(%rip),%rsi
call   1050 <evbuffer_add_printf@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <evhttp_request_get_output_headers@plt>
mov    %eax,%edi
lea    0xde0(%rip),%rsi
lea    0xde6(%rip),%rdx
call   10c0 <evhttp_add_header@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0xdd4(%rip),%rdx
call   10d0 <evhttp_send_reply@plt>
lea    -0x20(%rbp),%rdi
call   1060 <evhttp_clear_headers@plt>
mov    -0x18(%rbp),%rdi
call   1040 <evbuffer_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testing>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1070 <evhttp_request_get_uri@plt>
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1090 <evhttp_parse_query@plt>
lea    0xe2c(%rip),%rsi
mov    %r14,%rdi
call   1030 <evhttp_find_header@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10b0 <evbuffer_new@plt>
mov    %rax,%rbx
lea    0xe12(%rip),%rsi
mov    %rax,%rdi
mov    $0x8,%edx
call   1080 <evbuffer_add@plt>
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1050 <evbuffer_add_printf@plt>
mov    %r15,%rdi
call   10a0 <evhttp_request_get_output_headers@plt>
lea    0xdf0(%rip),%rsi
lea    0xdf6(%rip),%rdx
mov    %eax,%edi
call   10c0 <evhttp_add_header@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
lea    0xdea(%rip),%rdx
mov    %r15,%rdi
mov    %rbx,%rcx
call   10d0 <evhttp_send_reply@plt>
mov    %r14,%rdi
call   1060 <evhttp_clear_headers@plt>
mov    %rbx,%rdi
call   1040 <evbuffer_free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
%struct.evkeyvalq = type { i32 }
@.str = [2 x i8] c"q\00"
@.str.1 = [9 x i8] c"coucou !\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [13 x i8] c"Content-Type\00"
@.str.4 = [11 x i8] c"text/plain\00"
@HTTP_OK = global i32 0
@.str.5 = [3 x i8] c"OK\00"
define void @testing(%struct.evhttp_request* %0, i8* %1) {
%3 = alloca %struct.evhttp_request*
%4 = alloca i8*
%5 = alloca %struct.evbuffer*
%6 = alloca %struct.evkeyvalq
%7 = alloca i8*
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
%8 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%9 = call i32 @evhttp_request_get_uri(%struct.evhttp_request* %8)
%10 = call i32 @evhttp_parse_query(i32 %9, %struct.evkeyvalq* %6)
%11 = call i8* @evhttp_find_header(%struct.evkeyvalq* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %7
%12 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %12, %struct.evbuffer** %5
%13 = load %struct.evbuffer*, %struct.evbuffer** %5
%14 = call i32 @evbuffer_add(%struct.evbuffer* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%15 = load %struct.evbuffer*, %struct.evbuffer** %5
%16 = load i8*, i8** %7
%17 = call i32 @evbuffer_add_printf(%struct.evbuffer* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%19 = call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %18)
%20 = call i32 @evhttp_add_header(i32 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%21 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%22 = load i32, i32* @HTTP_OK
%23 = load %struct.evbuffer*, %struct.evbuffer** %5
%24 = call i32 @evhttp_send_reply(%struct.evhttp_request* %21, i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %23)
%25 = call i32 @evhttp_clear_headers(%struct.evkeyvalq* %6)
%26 = load %struct.evbuffer*, %struct.evbuffer** %5
%27 = call i32 @evbuffer_free(%struct.evbuffer* %26)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evkeyvalq = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [2 x i8] c"q\00"
@.str.1 = [9 x i8] c"coucou !\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [13 x i8] c"Content-Type\00"
@.str.4 = [11 x i8] c"text/plain\00"
@HTTP_OK = global i32 0
@.str.5 = [3 x i8] c"OK\00"
define void @testing(%struct.evhttp_request* %0, i8* nocapture readnone %1) {
%3 = alloca %struct.evkeyvalq
%4 = bitcast %struct.evkeyvalq* %3 to i8*
%5 = tail call i32 @evhttp_request_get_uri(%struct.evhttp_request* %0)
%6 = call i32 @evhttp_parse_query(i32 %5, %struct.evkeyvalq* %3)
%7 = call i8* @evhttp_find_header(%struct.evkeyvalq* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call %struct.evbuffer* (...) @evbuffer_new()
%9 = call i32 @evbuffer_add(%struct.evbuffer* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%10 = call i32 @evbuffer_add_printf(%struct.evbuffer* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%11 = call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %0)
%12 = call i32 @evhttp_add_header(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32, i32* @HTTP_OK
%14 = call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %8)
%15 = call i32 @evhttp_clear_headers(%struct.evkeyvalq* %3)
%16 = call i32 @evbuffer_free(%struct.evbuffer* %8)
ret void
}