#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_end_headers(int);
int /*<<< orphan*/ http_send_data(int, char *, int);
int /*<<< orphan*/ http_send_header(int, char *, char *);
int /*<<< orphan*/ http_start_response(int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void send_data(int fd, int status_code, char content_type[], char data[],
               int data_sz) {
  char buf[20];
  sprintf(buf, "%d", data_sz);
  http_start_response(fd, status_code);
  http_send_header(fd, "Content-type", content_type);
  http_send_header(fd, "Content-Length", buf);
  http_end_headers(fd);
  http_send_data(fd, data, data_sz);
}


x86 assembly (clang, -O0):
<send_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe88(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <http_start_response@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xe6d(%rip),%rsi
call   1050 <http_send_header@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1050 <http_send_header@plt>
mov    -0x4(%rbp),%edi
call   1040 <http_end_headers@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <http_send_data@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r12d
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xe8e(%rip),%rsi
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r8d,%edx
call   1070 <sprintf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <http_start_response@plt>
lea    0xe73(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
call   1050 <http_send_header@plt>
lea    0xe6f(%rip),%rsi
mov    %ebp,%edi
mov    %r13,%rdx
call   1050 <http_send_header@plt>
mov    %ebp,%edi
call   1040 <http_end_headers@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <http_send_data@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Content-type\00"
@.str.2 = [15 x i8] c"Content-Length\00"
define void @send_data(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [20 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%13 = load i32, i32* %10
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 @http_start_response(i32 %15, i32 %16)
%18 = load i32, i32* %6
%19 = load i8*, i8** %8
%20 = call i32 @http_send_header(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %6
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%23 = call i32 @http_send_header(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %6
%25 = call i32 @http_end_headers(i32 %24)
%26 = load i32, i32* %6
%27 = load i8*, i8** %9
%28 = load i32, i32* %10
%29 = call i32 @http_send_data(i32 %26, i8* %27, i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Content-type\00"
@.str.2 = [15 x i8] c"Content-Length\00"
define void @send_data(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%9 = tail call i32 @http_start_response(i32 %0, i32 %1)
%10 = tail call i32 @http_send_header(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = call i32 @http_send_header(i32 %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%12 = call i32 @http_end_headers(i32 %0)
%13 = call i32 @http_send_data(i32 %0, i8* %3, i32 %4)
ret void
}