#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 tm {
  int tm_year;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
  int /*<<< orphan*/ tm_mon;
};
typedef int /*<<< orphan*/ strbuf;
typedef scalar_t__ client_ip;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printLog(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *);
char *strstr(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void log_request(FILE *logfile, unsigned long int client_ip, char *headers,
                 int headers_len) {
  int i;
  time_t t;
  struct tm *lt;
  char hyphen[2];
  char buffer[1024];
  char strbuf[32];
  char *ref, *u_a;
  printLog(logfile, "--------\n");
  return;
  memcpy(buffer, headers, headers_len + 1);
  hyphen[0] = '-';
  hyphen[1] = '\0';
  memset(strbuf, 0, sizeof(strbuf));
  sprintf(strbuf, "Referer: ");
  ref = strstr(buffer, strbuf);
  ref = ((ref == NULL) ? hyphen : ref + 9);
  sprintf(strbuf, "User-Agent: ");
  u_a = strstr(buffer, strbuf);
  u_a = ((u_a == NULL) ? hyphen : u_a + 12);
  for (i = 0; i < headers_len; i++) {
    if (buffer[i] < 32) {
      if (buffer[i] == '\r' && buffer[i + 1] == '\n')
        buffer[i] = '\0';
      else
        buffer[i] = ' ';
    }
  }
  t = time(NULL);
  lt = localtime(&t);
  lt->tm_year += 1900;
  lt->tm_mon++;
  printLog(logfile, "[%04d-%02d-%02d %02d:%02d:%02d]\0", lt->tm_year,
           lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);
  printLog(logfile, " %d-%d.%d.%d %c%s%c %c%s%c %c%s%c\r\n\0",
           (int)(client_ip)&0xFF, (int)(client_ip >> 8) & 0xFF,
           (int)(client_ip >> 16) & 0xFF, (int)(client_ip >> 24) & 0xFF, '"',
           buffer, '"', '"', ref, '"', '"', u_a, '"');
}


x86 assembly (clang, -O0):
<log_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecb(%rip),%rsi
mov    $0x0,%al
call   1030 <printLog@plt>
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_request>:
lea    0xee9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printLog@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [10 x i8] c"--------\0A\00"
define void @log_request(i32* %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.tm*
%12 = alloca [2 x i8]
%13 = alloca [1024 x i8]
%14 = alloca [32 x i8]
%15 = alloca i8*
%16 = alloca i8*
store i32* %0, i32** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%17 = load i32*, i32** %5
%18 = call i32 (i32*, i8*, ...) @printLog(i32* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [10 x i8] c"--------\0A\00"
define void @log_request(i32* %0, i64 %1, i8* nocapture readnone %2, i32 %3) {
%5 = tail call i32 (i32*, i8*, ...) @printLog(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret void
}