#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct evkeyvalq {
  struct evkeyval *tqh_first;
};
struct TYPE_2__ {
  struct evkeyval *tqe_next;
};
struct evkeyval {
  char *key;
  char *value;
  TYPE_1__ next;
};
struct evhttp_request {
  int dummy;
};

/* Variables and functions */
struct evkeyvalq *evhttp_request_get_input_headers(struct evhttp_request *);
int /*<<< orphan*/ printf(char *, char *, char *);
void print_headers(struct evhttp_request *req) {
  struct evkeyvalq *headers;
  struct evkeyval *header;
  headers = evhttp_request_get_input_headers(req);
  for (header = headers->tqh_first; header != NULL;
       header = header->next.tqe_next) {
    printf("%s: %s\n", header->key, header->value);
  }
}


x86 assembly (clang, -O0):
<print_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <evhttp_request_get_input_headers@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117b <print_headers+0x5b>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1144 <print_headers+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_headers>:
push   %r14
push   %rbx
push   %rax
call   1040 <evhttp_request_get_input_headers@plt>
mov    (%rax),%rbx
test   %rbx,%rbx
je     1158 <print_headers+0x38>
lea    0xec8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x10(%rbx),%rbx
test   %rbx,%rbx
jne    1140 <print_headers+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evkeyvalq = type { %struct.evkeyval* }
%struct.evkeyval = type { i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { %struct.evkeyval* }
@.str = [8 x i8] c"%s: %s\0A\00"
define void @print_headers(%struct.evhttp_request* %0) {
%2 = alloca %struct.evhttp_request*
%3 = alloca %struct.evkeyvalq*
%4 = alloca %struct.evkeyval*
store %struct.evhttp_request* %0, %struct.evhttp_request** %2
%5 = load %struct.evhttp_request*, %struct.evhttp_request** %2
%6 = call %struct.evkeyvalq* @evhttp_request_get_input_headers(%struct.evhttp_request* %5)
store %struct.evkeyvalq* %6, %struct.evkeyvalq** %3
%7 = load %struct.evkeyvalq*, %struct.evkeyvalq** %3
%8 = getelementptr inbounds %struct.evkeyvalq, %struct.evkeyvalq* %7, i32 0, i32 0
%9 = load %struct.evkeyval*, %struct.evkeyval** %8
store %struct.evkeyval* %9, %struct.evkeyval** %4
br label %10
10: ; preds = %21, %1
%11 = load %struct.evkeyval*, %struct.evkeyval** %4
%12 = icmp ne %struct.evkeyval* %11, null
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load %struct.evkeyval*, %struct.evkeyval** %4
%15 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = load %struct.evkeyval*, %struct.evkeyval** %4
%18 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %17, i32 0, i32 1
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %19)
br label %21
21: ; preds = %13
%22 = load %struct.evkeyval*, %struct.evkeyval** %4
%23 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %22, i32 0, i32 2
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
%25 = load %struct.evkeyval*, %struct.evkeyval** %24
store %struct.evkeyval* %25, %struct.evkeyval** %4
br label %10
26: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evkeyvalq = type { %struct.evkeyval* }
%struct.evkeyval = type { i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { %struct.evkeyval* }
@.str = [8 x i8] c"%s: %s\0A\00"
define void @print_headers(%struct.evhttp_request* %0) {
%2 = tail call %struct.evkeyvalq* @evhttp_request_get_input_headers(%struct.evhttp_request* %0)
%3 = getelementptr inbounds %struct.evkeyvalq, %struct.evkeyvalq* %2, i64 0, i32 0
%4 = load %struct.evkeyval*, %struct.evkeyval** %3
%5 = icmp eq %struct.evkeyval* %4, null
br i1 %5, label %16, label %6
6: ; preds = %1, %6
%7 = phi %struct.evkeyval* [ %14, %6 ], [ %4, %1 ]
%8 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %7, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11)
%13 = getelementptr inbounds %struct.evkeyval, %struct.evkeyval* %7, i64 0, i32 2, i32 0
%14 = load %struct.evkeyval*, %struct.evkeyval** %13
%15 = icmp eq %struct.evkeyval* %14, null
br i1 %15, label %16, label %6
16: ; preds = %6, %1
ret void
}