#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 */
int /*<<< orphan*/ http_response_end_header(int);
int /*<<< orphan*/ send(int, char *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *w_malloc(size_t);
void http_response_send_header(char *key, char *value, int connfd) {
  size_t length = strlen(key) + 2 + strlen(value) + 1;
  char *header = w_malloc(length);
  strcpy(header, key);
  strcat(header, ": ");
  strcat(header, value);
  send(connfd, header, length, 0);
  http_response_end_header(connfd);
}


x86 assembly (clang, -O0):
<http_response_send_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <w_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x14(%rbp),%edi
call   1060 <http_response_end_header@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_response_send_header>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
add    $0x3,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   1070 <w_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %r14d,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <http_response_end_header@plt>

LLVM IR (-O0):
@.str = [3 x i8] c": \00"
define void @http_response_send_header(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 2
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
store i64 %16, i64* %7
%17 = load i64, i64* %7
%18 = call i8* @w_malloc(i64 %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i8*, i8** %8
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %8
%25 = load i8*, i8** %5
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i32, i32* %6
%28 = load i8*, i8** %8
%29 = load i64, i64* %7
%30 = call i32 @send(i32 %27, i8* %28, i64 %29, i32 0)
%31 = load i32, i32* %6
%32 = call i32 @http_response_end_header(i32 %31)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c": \00"
define void @http_response_send_header(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 3
%7 = add i32 %6, %5
%8 = sext i32 %7 to i64
%9 = tail call i8* @w_malloc(i64 %8)
%10 = tail call i32 @strcpy(i8* %9, i8* %0)
%11 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %9, i8* %1)
%13 = tail call i32 @send(i32 %2, i8* %9, i64 %8, i32 0)
%14 = tail call i32 @http_response_end_header(i32 %2)
ret void
}