#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*/ getTime(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlcpy(char *, char *);
int /*<<< orphan*/ writeToClient(int, char *);
void sendOK(int clientsd, int fileLen) {
  char buf[128], length[20], time[80];
  sprintf(length, "%d", fileLen);
  getTime(time);
  strlcpy(buf, "HTTP/1.1 200 OK\n");
  strcat(buf, "Date: ");
  strcat(buf, time);
  strcat(buf, "\nContent-Type: text/html\n");
  strcat(buf, "Content-Length: ");
  strcat(buf, length);
  strcat(buf, "\n\n");
  writeToClient(clientsd, buf);
}


x86 assembly (clang, -O0):
<sendOK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe8e(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x100(%rbp),%rdi
call   1030 <getTime@plt>
lea    -0x90(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strlcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x4(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1050 <writeToClient@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendOK>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xf8,%rsp
mov    %esi,%edx
mov    %edi,%r15d
lea    0xe97(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <sprintf@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <getTime@plt>
lea    0xe7b(%rip),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlcpy@plt>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1050 <writeToClient@plt>
add    $0xf8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"HTTP/1.1 200 OK\0A\00"
@.str.2 = [7 x i8] c"Date: \00"
@.str.3 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.4 = [17 x i8] c"Content-Length: \00"
@.str.5 = [3 x i8] c"\0A\0A\00"
define void @sendOK(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = alloca [20 x i8]
%7 = alloca [80 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%12 = call i32 @getTime(i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlcpy(i8* %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* %3
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%31 = call i32 @writeToClient(i32 %29, i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"HTTP/1.1 200 OK\0A\00"
@.str.2 = [7 x i8] c"Date: \00"
@.str.3 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.4 = [17 x i8] c"Content-Length: \00"
@.str.5 = [3 x i8] c"\0A\0A\00"
define void @sendOK(i32 %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = alloca [20 x i8]
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%10 = call i32 @getTime(i8* %8)
%11 = call i32 @strlcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @strcat(i8* %6, i8* %8)
%14 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @strcat(i8* %6, i8* %7)
%17 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @writeToClient(i32 %0, i8* %6)
ret void
}