#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 */

/* Variables and functions */
char *getMime(char const *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void headers(int client, const char *filename) {
  char buf[1024];
  (void)filename;
  strcpy(buf, "HTTP/1.0 200 OK\r\n");
  send(client, buf, strlen(buf), 0);
  strcpy(buf, "Server: jdbhttpd/0.1.0\r\n");
  send(client, buf, strlen(buf), 0);
  sprintf(buf, "Content-Type: %s\r\n", getMime(filename));
  send(client, buf, strlen(buf), 0);
  strcpy(buf, "\r\n");
  send(client, buf, strlen(buf), 0);
}


x86 assembly (clang, -O0):
<headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x454(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x454(%rbp),%edi
mov    -0x450(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x444(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x444(%rbp),%edi
mov    -0x440(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <getMime@plt>
mov    -0x438(%rbp),%rdi
mov    %rax,%rdx
lea    0xe09(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xdba(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x41c(%rbp),%edi
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<headers>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe99(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %r14,%rdi
call   1070 <getMime@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [25 x i8] c"Server: jdbhttpd/0.1.0\0D\0A\00"
@.str.2 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @headers(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = call i32 @send(i32 %9, i8* %10, i32 %12, i32 0)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @send(i32 %16, i8* %17, i32 %19, i32 0)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i8* @getMime(i8* %22)
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %3
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @send(i32 %25, i8* %26, i32 %28, i32 0)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* %3
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = call i32 @send(i32 %32, i8* %33, i32 %35, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [25 x i8] c"Server: jdbhttpd/0.1.0\0D\0A\00"
@.str.2 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @headers(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strlen(i8* %4)
%7 = call i32 @send(i32 %0, i8* %4, i32 %6, i32 0)
%8 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strlen(i8* %4)
%10 = call i32 @send(i32 %0, i8* %4, i32 %9, i32 0)
%11 = call i8* @getMime(i8* %1)
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 @strlen(i8* %4)
%14 = call i32 @send(i32 %0, i8* %4, i32 %13, i32 0)
%15 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @strlen(i8* %4)
%17 = call i32 @send(i32 %0, i8* %4, i32 %16, i32 0)
ret void
}