#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 scalar_t__ time_t;
typedef scalar_t__ off_t;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ gmtime(scalar_t__ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ time(scalar_t__ *);
void send_headers(int status, char *title, char *extra_header, char *mime_type,
                  off_t length, time_t mod) {
  time_t now;
  char timebuf[100];
  (void)printf("%s %d %s\015\012", "HTTP/1.0", status, title);
  (void)printf("Server: %s\015\012", "micro_httpd");
  now = time((time_t *)0);
  (void)strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT",
                 gmtime(&now));
  (void)printf("Date: %s\015\012", timebuf);
  if (extra_header != (char *)0)
    (void)printf("%s\015\012", extra_header);
  if (mime_type != (char *)0)
    (void)printf("Content-Type: %s\015\012", mime_type);
  if (length >= 0)
    (void)printf("Content-Length: %lld\015\012", (int64_t)length);
  if (mod != (time_t)-1) {
    (void)strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT",
                   gmtime(&mod));
    (void)printf("Last-Modified: %s\015\012", timebuf);
  }
  (void)printf("Connection: close\015\012");
  (void)printf("\015\012");
}


x86 assembly (clang, -O0):
<send_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe90(%rip),%rdi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x38(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x38(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x64,%esi
lea    0xe61(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1203 <send_headers+0xc3>
mov    -0x18(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1220 <send_headers+0xe0>
mov    -0x20(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
jl     123f <send_headers+0xff>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0xffffffffffffffff,-0x30(%rbp)
je     1290 <send_headers+0x150>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <gmtime@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%ecx
mov    $0x64,%esi
lea    0xdb7(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xa0(%rbp),%rsi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_headers>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %r9,%r15
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rcx
mov    %edi,%edx
mov    %r9,0x8(%rsp)
lea    0xe83(%rip),%rdi
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
lea    0xe88(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1070 <gmtime@plt>
lea    0xe73(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13,%r13
je     11f5 <send_headers+0xa5>
lea    0xea0(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     120b <send_headers+0xbb>
lea    0xe51(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
js     1221 <send_headers+0xd1>
lea    0xe4e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffffffffffffff,%r15
je     125d <send_headers+0x10d>
lea    0x8(%rsp),%rdi
call   1070 <gmtime@plt>
lea    0xdf5(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe29(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe31(%rip),%rdi
call   1030 <puts@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 = [12 x i8] c"micro_httpd\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 = [23 x i8] c"Content-Length: %lld\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, i64 %4, i64 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca [100 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
store i64 %5, i64* %12
%15 = load i32, i32* %7
%16 = load i8*, i8** %8
%17 = 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 %15, i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%19 = call i64 @time(i64* null)
store i64 %19, i64* %13
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%21 = call i32 @gmtime(i64* %13)
%22 = call i32 @strftime(i8* %20, i32 100, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %9
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %6
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %6
%31 = load i8*, i8** %10
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i8*, i8** %10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33, %30
%37 = load i64, i64* %11
%38 = icmp sge i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i64, i64* %11
%41 = trunc i64 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %39, %36
%44 = load i64, i64* %12
%45 = icmp ne i64 %44, -1
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%48 = call i32 @gmtime(i64* %12)
%49 = call i32 @strftime(i8* %47, i32 100, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %46, %43
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(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.0\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [12 x i8] c"micro_httpd\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 = [23 x i8] c"Content-Length: %lld\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, i64 %4, i64 %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca [100 x i8]
store i64 %5, i64* %7
%10 = bitcast i64* %8 to i8*
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%12 = 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)
%13 = 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 ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i64 @time(i64* null)
store i64 %14, i64* %8
%15 = call i32 @gmtime(i64* %8)
%16 = call i32 @strftime(i8* %11, i32 100, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%18 = icmp eq i8* %2, null
br i1 %18, label %21, label %19
19: ; preds = %6
%20 = 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 %21
21: ; preds = %19, %6
%22 = icmp eq i8* %3, null
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = 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 %25
25: ; preds = %23, %21
%26 = icmp sgt i64 %4, -1
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = trunc i64 %4 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %25
%31 = icmp eq i64 %5, -1
br i1 %31, label %36, label %32
32: ; preds = %30
%33 = call i32 @gmtime(i64* %7)
%34 = call i32 @strftime(i8* %11, i32 100, 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* %11)
br label %36
36: ; preds = %32, %30
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
ret void
}