#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_printf(struct evbuffer *, int /*<<< orphan*/);
int /*<<< orphan*/ evbuffer_free(struct evbuffer *);
struct evbuffer *evbuffer_new();
int /*<<< orphan*/ evhttp_add_header(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ evhttp_request_get_output_headers(struct evhttp_request *);
int /*<<< orphan*/ evhttp_send_reply(struct evhttp_request *, int, char *,
                                     struct evbuffer *);
int /*<<< orphan*/ gettext(char *);
scalar_t__ lsddb_indexHtmlGen(struct evbuffer *);
void srvIndexCB(struct evhttp_request *req, void *arg) {
  struct evbuffer *repBuf = evbuffer_new();
  if (lsddb_indexHtmlGen(repBuf) < 0)
    evbuffer_add_printf(repBuf, gettext("Error while generating index\n"));
  evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type",
                    "text/html");
  evhttp_add_header(evhttp_request_get_output_headers(req), "Pragma",
                    "no-cache");
  evhttp_send_reply(req, 200, "OK", repBuf);
  evbuffer_free(repBuf);
}


x86 assembly (clang, -O0):
<srvIndexCB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <evbuffer_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <lsddb_indexHtmlGen@plt>
cmp    $0x0,%rax
jge    11cd <srvIndexCB+0x4d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe43(%rip),%rdi
call   1030 <gettext@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <evbuffer_add_printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_request_get_output_headers@plt>
mov    %eax,%edi
lea    0xe3f(%rip),%rsi
lea    0xe45(%rip),%rdx
call   1090 <evhttp_add_header@plt>
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_request_get_output_headers@plt>
mov    %eax,%edi
lea    0xe38(%rip),%rsi
lea    0xe38(%rip),%rdx
call   1090 <evhttp_add_header@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xc8,%esi
lea    0xe28(%rip),%rdx
call   10a0 <evhttp_send_reply@plt>
mov    -0x18(%rbp),%rdi
call   1040 <evbuffer_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srvIndexCB>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1080 <evbuffer_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <lsddb_indexHtmlGen@plt>
test   %rax,%rax
jns    11b4 <srvIndexCB+0x34>
lea    0xe5b(%rip),%rdi
call   1030 <gettext@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <evbuffer_add_printf@plt>
mov    %r14,%rdi
call   1070 <evhttp_request_get_output_headers@plt>
lea    0xe5b(%rip),%rsi
lea    0xe61(%rip),%rdx
mov    %eax,%edi
call   1090 <evhttp_add_header@plt>
mov    %r14,%rdi
call   1070 <evhttp_request_get_output_headers@plt>
lea    0xe55(%rip),%rsi
lea    0xe55(%rip),%rdx
mov    %eax,%edi
call   1090 <evhttp_add_header@plt>
lea    0xe50(%rip),%rdx
mov    %r14,%rdi
mov    $0xc8,%esi
mov    %rbx,%rcx
call   10a0 <evhttp_send_reply@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <evbuffer_free@plt>

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [30 x i8] c"Error while generating index\0A\00"
@.str.1 = [13 x i8] c"Content-Type\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [7 x i8] c"Pragma\00"
@.str.4 = [9 x i8] c"no-cache\00"
@.str.5 = [3 x i8] c"OK\00"
define void @srvIndexCB(%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 = call i64 @lsddb_indexHtmlGen(%struct.evbuffer* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load %struct.evbuffer*, %struct.evbuffer** %5
%12 = call i32 @gettext(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @evbuffer_add_printf(%struct.evbuffer* %11, i32 %12)
br label %14
14: ; preds = %10, %2
%15 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%16 = call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %15)
%17 = call i32 @evhttp_add_header(i32 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%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 ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%21 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%22 = load %struct.evbuffer*, %struct.evbuffer** %5
%23 = call i32 @evhttp_send_reply(%struct.evhttp_request* %21, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %22)
%24 = load %struct.evbuffer*, %struct.evbuffer** %5
%25 = call i32 @evbuffer_free(%struct.evbuffer* %24)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [30 x i8] c"Error while generating index\0A\00"
@.str.1 = [13 x i8] c"Content-Type\00"
@.str.2 = [10 x i8] c"text/html\00"
@.str.3 = [7 x i8] c"Pragma\00"
@.str.4 = [9 x i8] c"no-cache\00"
@.str.5 = [3 x i8] c"OK\00"
define void @srvIndexCB(%struct.evhttp_request* %0, i8* nocapture readnone %1) {
%3 = tail call %struct.evbuffer* (...) @evbuffer_new()
%4 = tail call i64 @lsddb_indexHtmlGen(%struct.evbuffer* %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @gettext(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @evbuffer_add_printf(%struct.evbuffer* %3, i32 %7)
br label %9
9: ; preds = %6, %2
%10 = tail call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %0)
%11 = tail call i32 @evhttp_add_header(i32 %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @evhttp_request_get_output_headers(%struct.evhttp_request* %0)
%13 = tail call i32 @evhttp_add_header(i32 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @evhttp_send_reply(%struct.evhttp_request* %0, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.evbuffer* %3)
%15 = tail call i32 @evbuffer_free(%struct.evbuffer* %3)
ret void
}