#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*/ perror(char *);
scalar_t__ send(int, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *);
scalar_t__ strlen(char *);
void setup(int connection_socket, int http_reponse_code) {
  char buf[255];
  sprintf(buf, "HTTP/1.1 200 Success\r\nConnection: keep-alive\r\n");
  if (send(connection_socket, buf, strlen(buf), 0) < strlen(buf)) {
    perror("Error while setting up http stream");
  }
}


x86 assembly (clang, -O0):
<setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x124(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x124(%rbp),%edi
mov    -0x120(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x118(%rbp),%rax
cmp    %rcx,%rax
jge    11d0 <setup+0x90>
lea    0xe64(%rip),%rdi
call   1050 <perror@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebx
movups 0xedc(%rip),%xmm0
movups %xmm0,0x1f(%rsp)
movups 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xea5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jl     1194 <setup+0x64>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe94(%rip),%rdi
call   1050 <perror@plt>
jmp    1189 <setup+0x59>

LLVM IR (-O0):
@.str = [47 x i8] c"HTTP/1.1 200 Success\0D\0AConnection: keep-alive\0D\0A\00"
@.str.1 = [35 x i8] c"Error while setting up http stream\00"
define void @setup(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [255 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
%12 = call i64 @send(i32 %8, i8* %9, i64 %11, i32 0)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = icmp slt i64 %12, %14
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"HTTP/1.1 200 Success\0D\0AConnection: keep-alive\0D\0A\00"
@.str.1 = [35 x i8] c"Error while setting up http stream\00"
define void @setup(i32 %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = call i64 @strlen(i8* %4)
%6 = call i64 @send(i32 %0, i8* %4, i64 %5, i32 0)
%7 = call i64 @strlen(i8* %4)
%8 = icmp slt i64 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
ret void
}