#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 *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *w_malloc(size_t);
void http_response_send_statusline(char *version, char *code, char *message,
                                   int connfd) {
  size_t length =
      strlen(version) + 1 + strlen(code) + 1 + strlen(message) + 2 + 1;
  char *statusline = w_malloc(length);
  strcpy(statusline, version);
  strcat(statusline, " ");
  strcat(statusline, code);
  strcat(statusline, " ");
  strcat(statusline, message);
  strcat(statusline, "\r\n");
  send(connfd, statusline, length, 0);
}


x86 assembly (clang, -O0):
<http_response_send_statusline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <w_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_response_send_statusline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %r12d,%ebx
add    %ebx,%eax
add    $0x5,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   1060 <w_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xe57(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xe26(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <send@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @http_response_send_statusline(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 1
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 1
%18 = load i8*, i8** %7
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = add nsw i32 %20, 2
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
store i64 %23, i64* %9
%24 = load i64, i64* %9
%25 = call i8* @w_malloc(i64 %24)
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = load i8*, i8** %5
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load i8*, i8** %10
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = load i8*, i8** %10
%32 = load i8*, i8** %6
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = load i8*, i8** %10
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%36 = load i8*, i8** %10
%37 = load i8*, i8** %7
%38 = call i32 @strcat(i8* %36, i8* %37)
%39 = load i8*, i8** %10
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %8
%42 = load i8*, i8** %10
%43 = load i64, i64* %9
%44 = call i32 @send(i32 %41, i8* %42, i64 %43, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @http_response_send_statusline(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i32 @strlen(i8* %2)
%8 = add i32 %5, 5
%9 = add i32 %8, %6
%10 = add i32 %9, %7
%11 = sext i32 %10 to i64
%12 = tail call i8* @w_malloc(i64 %11)
%13 = tail call i32 @strcpy(i8* %12, i8* %0)
%14 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %12, i8* %1)
%16 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @strcat(i8* %12, i8* %2)
%18 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @send(i32 %3, i8* %12, i64 %11, i32 0)
ret void
}