#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*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
void post_response(int connectfd, char *data) {
  char buf[255];
  send(connectfd, "HTTP/1.1 200\n", 13, 0);
  sprintf(buf, "Content-Length: %i\n", strlen(data));
  send(connectfd, buf, strlen(buf), 0);
  send(connectfd, "Content-Type: text/plain\n", 25, 0);
  send(connectfd, "Connection: Close\n\n", 19, 0);
  send(connectfd, data, strlen(data), 0);
}


x86 assembly (clang, -O0):
<post_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    0xeb4(%rip),%rsi
mov    $0xd,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%edx
lea    0xe8f(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x4(%rbp),%edi
lea    0xe5b(%rip),%rsi
mov    $0x19,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x4(%rbp),%edi
lea    0xe5f(%rip),%rsi
mov    $0x13,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x11c(%rbp),%edi
mov    -0x118(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<post_response>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xeb9(%rip),%rsi
mov    $0xd,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xeac(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    0xe96(%rip),%rsi
mov    %ebp,%edi
mov    $0x19,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    0xe9b(%rip),%rsi
mov    %ebp,%edi
mov    $0x13,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"HTTP/1.1 200\0A\00"
@.str.1 = [20 x i8] c"Content-Length: %i\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/plain\0A\00"
@.str.3 = [20 x i8] c"Connection: Close\0A\0A\00"
define void @post_response(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [255 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = call i32 @send(i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 13, i32 0)
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @send(i32 %12, i8* %13, i32 %15, i32 0)
%17 = load i32, i32* %3
%18 = call i32 @send(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 0)
%19 = load i32, i32* %3
%20 = call i32 @send(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 19, i32 0)
%21 = load i32, i32* %3
%22 = load i8*, i8** %4
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @send(i32 %21, i8* %22, i32 %24, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"HTTP/1.1 200\0A\00"
@.str.1 = [20 x i8] c"Content-Length: %i\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/plain\0A\00"
@.str.3 = [20 x i8] c"Connection: Close\0A\0A\00"
define void @post_response(i32 %0, i8* %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @send(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 13, i32 0)
%6 = tail call i32 @strlen(i8* %1)
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @send(i32 %0, i8* %4, i32 %8, i32 0)
%10 = call i32 @send(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 0)
%11 = call i32 @send(i32 %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 19, i32 0)
%12 = call i32 @strlen(i8* %1)
%13 = call i32 @send(i32 %0, i8* %1, i32 %12, i32 0)
ret void
}