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

/* Variables and functions */
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ evbuffer_add_printf(struct evbuffer *, char *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
char *evhttp_request_get_uri(struct evhttp_request *);
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *, int, char *,
                                     struct evbuffer *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void time_request_cb(struct evhttp_request *req, void *arg) {
  (void)arg;
  struct evbuffer *evb = evbuffer_new();
  printf("Received request for %s\n", evhttp_request_get_uri(req));
  time_t ts = time(NULL);
  evbuffer_add_printf(evb, "%s", ctime(&ts));
  evhttp_send_reply(req, 200, "OK", evb);
  evbuffer_free(evb);
}


x86 assembly (clang, -O0):
<time_request_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <evbuffer_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_request_get_uri@plt>
mov    %rax,%rsi
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe3c(%rip),%rsi
call   1060 <evbuffer_add_printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xc8,%esi
lea    0xe26(%rip),%rdx
call   10a0 <evhttp_send_reply@plt>
mov    -0x18(%rbp),%rdi
call   1050 <evbuffer_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_request_cb>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1090 <evbuffer_new@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <evhttp_request_get_uri@plt>
lea    0xe60(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1060 <evbuffer_add_printf@plt>
lea    0xe47(%rip),%rdx
mov    %r14,%rdi
mov    $0xc8,%esi
mov    %rbx,%rcx
call   10a0 <evhttp_send_reply@plt>
mov    %rbx,%rdi
call   1050 <evbuffer_free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [25 x i8] c"Received request for %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"OK\00"
define void @time_request_cb(%struct.evhttp_request* %0, i8* %1) {
%3 = alloca %struct.evhttp_request*
%4 = alloca i8*
%5 = alloca %struct.evbuffer*
%6 = alloca i32
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call %struct.evbuffer* (...) @evbuffer_new()
store %struct.evbuffer* %8, %struct.evbuffer** %5
%9 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%10 = call i8* @evhttp_request_get_uri(%struct.evhttp_request* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32 @time(i32* null)
store i32 %12, i32* %6
%13 = load %struct.evbuffer*, %struct.evbuffer** %5
%14 = call i32 @ctime(i32* %6)
%15 = call i32 @evbuffer_add_printf(%struct.evbuffer* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%17 = load %struct.evbuffer*, %struct.evbuffer** %5
%18 = call i32 @evhttp_send_reply(%struct.evhttp_request* %16, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.evbuffer* %17)
%19 = load %struct.evbuffer*, %struct.evbuffer** %5
%20 = call i32 @evbuffer_free(%struct.evbuffer* %19)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [25 x i8] c"Received request for %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"OK\00"
define void @time_request_cb(%struct.evhttp_request* %0, i8* nocapture readnone %1) {
%3 = alloca i32
%4 = tail call %struct.evbuffer* (...) @evbuffer_new()
%5 = tail call i8* @evhttp_request_get_uri(%struct.evhttp_request* %0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = bitcast i32* %3 to i8*
%8 = tail call i32 @time(i32* null)
store i32 %8, i32* %3
%9 = call i32 @ctime(i32* %3)
%10 = call i32 @evbuffer_add_printf(%struct.evbuffer* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.evbuffer* %4)
%12 = call i32 @evbuffer_free(%struct.evbuffer* %4)
ret void
}