#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;

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


x86 assembly (clang, -O0):
<send_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe8d(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x2c(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xe61(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1205 <send_headers+0xc5>
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1222 <send_headers+0xe2>
mov    -0x20(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
jl     123d <send_headers+0xfd>
mov    -0x24(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x28(%rbp)
je     128d <send_headers+0x14d>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x28(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xc0(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xdbc(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xb0(%rbp),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,0x10(%rbp)
jle    12b3 <send_headers+0x173>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_headers>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %edi,%edx
mov    %r9d,0xc(%rsp)
lea    0xe84(%rip),%rdi
lea    0xe88(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
lea    0xe89(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1070 <gmtime@plt>
lea    0xe74(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe73(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     11f6 <send_headers+0xa6>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     120c <send_headers+0xbc>
lea    0xe52(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
js     1222 <send_headers+0xd2>
lea    0xe4f(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc0(%rsp),%ebp
cmp    $0xffffffff,%r15d
je     1265 <send_headers+0x115>
lea    0xc(%rsp),%rdi
call   1070 <gmtime@plt>
lea    0xdef(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe21(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    1281 <send_headers+0x131>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
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.0\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [14 x i8] c"in.www/200809\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_headers(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [128 x i8]
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = load i32, i32* %8
%18 = load i8*, i8** %9
%19 = call i32 (i8*, ...) @printf(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 %17, i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @time(i32* null)
store i32 %21, i32* %15
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%23 = call i32 @gmtime(i32* %15)
%24 = call i32 @strftime(i8* %22, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %10
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %7
%30 = load i8*, i8** %10
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %29, %7
%33 = load i8*, i8** %11
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %11
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %12
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %12
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %13
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%49 = call i32 @gmtime(i32* %13)
%50 = call i32 @strftime(i8* %48, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %47, %44
%54 = load i32, i32* %14
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %59
59: ; preds = %56, %53
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s %d %s\0D\0A\00"
@.str.1 = [9 x i8] c"HTTP/1.0\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [14 x i8] c"in.www/200809\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 = [19 x i8] c"Connection: close\0D\00"
@str.12 = [2 x i8] c"\0D\00"
define void @send_headers(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca [128 x i8]
store i32 %5, 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 (i8*, ...) @printf(i8* dereferenceable(1) 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 %0, i8* %1)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%19 = icmp eq i8* %2, null
br i1 %19, label %22, label %20
20: ; preds = %7
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %2)
br label %22
22: ; preds = %20, %7
%23 = icmp eq i8* %3, null
br i1 %23, label %26, label %24
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %3)
br label %26
26: ; preds = %24, %22
%27 = icmp sgt i32 %4, -1
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %4)
br label %30
30: ; preds = %28, %26
%31 = icmp eq i32 %5, -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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %12)
br label %36
36: ; preds = %32, %30
%37 = icmp sgt i32 %6, 0
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
br label %41
41: ; preds = %38, %36
ret void
}