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

/* Variables and functions */
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strlen(char *);
void apex_http_response_header(int fd, char *type, ssize_t size) {
  char header_buffer[1024] = {0};
  sprintf(header_buffer,
          "HTTP/1.1 200 OK\nServer: apex\n"
          "Content-type:%sContent-length: %d\n"
          "Cache-Control: no-cache\n"
          "Connection: keep-alive\n\n",
          type, size);
  send(fd, header_buffer, strlen(header_buffer), 0);
}


x86 assembly (clang, -O0):
<apex_http_response_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe83(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apex_http_response_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe91(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [112 x i8] c"HTTP/1.1 200 OK\0AServer: apex\0AContent-type:%sContent-length: %d\0ACache-Control: no-cache\0AConnection: keep-alive\0A\0A\00"
define void @apex_http_response_header(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [1024 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = bitcast [1024 x i8]* %7 to i8*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = load i32, i32* %4
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @send(i32 %13, i8* %14, i32 %16, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [112 x i8] c"HTTP/1.1 200 OK\0AServer: apex\0AContent-type:%sContent-length: %d\0ACache-Control: no-cache\0AConnection: keep-alive\0A\0A\00"
define void @apex_http_response_header(i32 %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
%7 = call i32 @strlen(i8* %5)
%8 = call i32 @send(i32 %0, i8* %5, i32 %7, i32 0)
ret void
}