#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*/ printf(char *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send_msg(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void send_header(int send_to, char *content_type) {
  char *head = "HTTP/1.0 200 OK\r\n";
  int len = strlen(head);
  if (send(send_to, head, len, 0) == -1) {
    printf("send header error");
    return;
  }
  if (content_type) {
    char temp_1[30] = "Content-type: ";
    strcat(temp_1, content_type);
    strcat(temp_1, "\r\n");
    send_msg(send_to, temp_1);
  }
}


x86 assembly (clang, -O0):
<send_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    11a1 <send_header+0x51>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
jmp    120a <send_header+0xba>
cmpq   $0x0,-0x10(%rbp)
je     120a <send_header+0xba>
mov    0xe7d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xe6f(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1060 <send_msg@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_header>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe9c(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
je     11cb <send_header+0x7b>
test   %r14,%r14
je     11c2 <send_header+0x72>
movups 0xeb3(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <send_msg@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe40(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [18 x i8] c"send header error\00"
@__const.send_header.temp_1 = [30 x i8] c"Content-type: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @send_header(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [30 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %3
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @send(i32 %10, i8* %11, i32 %12, i32 0)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %30
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = bitcast [30 x i8]* %7 to i8*
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%23 = load i8*, i8** %4
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%29 = call i32 @send_msg(i32 %27, i8* %28)
br label %30
30: ; preds = %15, %20, %17
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [18 x i8] c"send header error\00"
@__const.send_header.temp_1 = [30 x i8] c"Content-type: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @send_header(i32 %0, i8* %1) {
%3 = alloca [30 x i8]
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @send(i32 %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = icmp eq i8* %1, null
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%13 = call i32 @strcat(i8* %12, i8* %1)
%14 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @send_msg(i32 %0, i8* %12)
br label %16
16: ; preds = %9, %11, %7
ret void
}