#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*/ timebuf;
typedef int time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gmtime(int *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int time(int /*<<< orphan*/ *);
void send_header(FILE *f, int status, char *title, char *extra, char *mime,
                 int length, time_t date) {
  time_t now;
  char timebuf[128];
  fprintf(f, "%s %d %s\r\n", "HTTP/1.1", status, title);
  fprintf(f, "Server: %s\r\n", "http_server 0.1");
  now = time(NULL);
  strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
  fprintf(f, "Date: %s\r\n", timebuf);
  if (extra)
    fprintf(f, "%s\r\n", extra);
  if (mime)
    fprintf(f, "Content-Type: %s\r\n", mime);
  if (length >= 0)
    fprintf(f, "Content-Length: %d\r\n", length);
  if (date != -1) {
    strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT",
             gmtime(&date));
    fprintf(f, "Last-Modified: %s\r\n", timebuf);
  }
  fprintf(f, "Connection: close\r\n");
  fprintf(f, "\r\n");
}


x86 assembly (clang, -O0):
<send_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe89(%rip),%rsi
lea    0xe8d(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    0xe8a(%rip),%rdx
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x30(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xe5b(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1215 <send_header+0xd5>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1236 <send_header+0xf6>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x2c(%rbp)
jl     1255 <send_header+0x115>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0xffffffff,0x10(%rbp)
je     12a9 <send_header+0x169>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    0x10(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xc0(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xda6(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r8
mov    %esi,%ecx
mov    %rdi,%rbx
mov    0xd0(%rsp),%r13d
lea    0xe7f(%rip),%rsi
lea    0xe83(%rip),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe7e(%rip),%rsi
lea    0xe84(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
lea    0xe6e(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1050 <strftime@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r12,%r12
je     1204 <send_header+0xb4>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15,%r15
je     121d <send_header+0xcd>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r14d,%r14d
js     1236 <send_header+0xe6>
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    $0xffffffff,%r13d
je     1278 <send_header+0x128>
lea    0xd0(%rsp),%rdi
call   1060 <gmtime@plt>
lea    0xde1(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1050 <strftime@plt>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe13(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xde3(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s %d %s\0D\0A\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [16 x i8] c"http_server 0.1\00"
@.str.4 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
@.str.5 = [11 x i8] c"Date: %s\0D\0A\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
@.str.7 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.8 = [21 x i8] c"Content-Length: %d\0D\0A\00"
@.str.9 = [20 x i8] c"Last-Modified: %s\0D\0A\00"
@.str.10 = [20 x i8] c"Connection: close\0D\0A\00"
@.str.11 = [3 x i8] c"\0D\0A\00"
define void @send_header(i32* %0, i32 %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [128 x i8]
store i32* %0, i32** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = load i32*, i32** %8
%18 = load i32, i32* %9
%19 = load i8*, i8** %10
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %19)
%21 = load i32*, i32** %8
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @time(i32* null)
store i32 %23, i32* %15
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%25 = call i32 @gmtime(i32* %15)
%26 = call i32 @strftime(i8* %24, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32*, i32** %8
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %11
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %36
32: ; preds = %7
%33 = load i32*, i32** %8
%34 = load i8*, i8** %11
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %32, %7
%37 = load i8*, i8** %12
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32*, i32** %8
%41 = load i8*, i8** %12
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %39, %36
%44 = load i32, i32* %13
%45 = icmp sge i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32*, i32** %8
%48 = load i32, i32* %13
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %46, %43
%51 = load i32, i32* %14
%52 = icmp ne i32 %51, -1
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%55 = call i32 @gmtime(i32* %14)
%56 = call i32 @strftime(i8* %54, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = load i32*, i32** %8
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %53, %50
%61 = load i32*, i32** %8
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%63 = load i32*, i32** %8
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s %d %s\0D\0A\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [16 x i8] c"http_server 0.1\00"
@.str.4 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
@.str.5 = [11 x i8] c"Date: %s\0D\0A\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
@.str.7 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.8 = [21 x i8] c"Content-Length: %d\0D\0A\00"
@.str.9 = [20 x i8] c"Last-Modified: %s\0D\0A\00"
@.str.10 = [20 x i8] c"Connection: close\0D\0A\00"
@.str.11 = [3 x i8] c"\0D\0A\00"
define void @send_header(i32* nocapture %0, i32 %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca [128 x i8]
store i32 %6, i32* %8
%11 = bitcast i32* %9 to i8*
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2)
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @time(i32* null)
store i32 %15, i32* %9
%16 = call i32 @gmtime(i32* %9)
%17 = call i32 @strftime(i8* %12, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%19 = icmp eq i8* %3, null
br i1 %19, label %22, label %20
20: ; preds = %7
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %3)
br label %22
22: ; preds = %20, %7
%23 = icmp eq i8* %4, null
br i1 %23, label %26, label %24
24: ; preds = %22
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %26
26: ; preds = %24, %22
%27 = icmp sgt i32 %5, -1
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %5)
br label %30
30: ; preds = %28, %26
%31 = icmp eq i32 %6, -1
br i1 %31, label %36, label %32
32: ; preds = %30
%33 = call i32 @gmtime(i32* %8)
%34 = call i32 @strftime(i8* %12, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %12)
br label %36
36: ; preds = %32, %30
%37 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i64 19, i64 1, i32* %0)
%38 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}