#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 */
typedef int /*<<< orphan*/ headBuffer;
typedef int /*<<< orphan*/ date;

/* Variables and functions */
int /*<<< orphan*/ getFormattedTime(char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
void GETResponseHead(char *headBuffer, int contentLength) {
  memset(headBuffer, 0, sizeof(headBuffer));
  strcat(headBuffer, "HTTP/1.0 200 OK\r\n");
  char date[64];
  getFormattedTime(date, sizeof(date));
  strcat(headBuffer, date);
  strcat(headBuffer, "\r\n");
  strcat(headBuffer, "Content-Length: ");
  char contentLengthBuffer[32];
  sprintf(contentLengthBuffer, "%d", contentLength);
  strcat(headBuffer, contentLengthBuffer);
  strcat(headBuffer, "\r\n\r\n");
}


x86 assembly (clang, -O0):
<GETResponseHead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
call   1040 <getFormattedTime@plt>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x70(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe6b(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GETResponseHead>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x40,%esi
call   1040 <getFormattedTime@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcat@plt>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe78(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcat@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [17 x i8] c"Content-Length: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"\0D\0A\0D\0A\00"
define void @GETResponseHead(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = alloca [32 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @memset(i8* %7, i32 0, i32 8)
%9 = load i8*, i8** %3
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%12 = call i32 @getFormattedTime(i8* %11, i32 64)
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcat(i8* %13, i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* %4
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %3
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [17 x i8] c"Content-Length: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"\0D\0A\0D\0A\00"
define void @GETResponseHead(i8* %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = alloca [32 x i8]
%5 = tail call i32 @memset(i8* %0, i32 0, i32 8)
%6 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%8 = call i32 @getFormattedTime(i8* %7, i32 64)
%9 = call i32 @strcat(i8* %0, i8* %7)
%10 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%13 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%14 = call i32 @strcat(i8* %0, i8* %12)
%15 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret void
}