#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*/ get_cgi_size(char *);
char *myitoa(int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ send_date(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
void create_cgi_res(int client, char *path) {
  char res[1024] = {0};
  send_date(client);
  strcat(res, "Server: Light Web Server for cgi V1.1.5\r\n");
  strcat(res, "Content-Length:");
  strcat(res, myitoa(get_cgi_size(path)));
  strcat(res, "\r\n");
  strcat(res, "Pragma: no-cache\r\n");
  send(client, res, strlen(res), 0);
}


x86 assembly (clang, -O0):
<create_cgi_res>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
call   1060 <send_date@plt>
lea    -0x410(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <get_cgi_size@plt>
mov    %eax,%edi
call   1070 <myitoa@plt>
mov    -0x428(%rbp),%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x41c(%rbp),%edi
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_cgi_res>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14d,%edi
call   1060 <send_date@plt>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbp,%rdi
call   1090 <get_cgi_size@plt>
mov    %eax,%edi
call   1070 <myitoa@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Server: Light Web Server for cgi V1.1.5\0D\0A\00"
@.str.1 = [16 x i8] c"Content-Length:\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [19 x i8] c"Pragma: no-cache\0D\0A\00"
define void @create_cgi_res(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = bitcast [1024 x i8]* %5 to i8*
%7 = load i32, i32* %3
%8 = call i32 @send_date(i32 %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %4
%15 = call i32 @get_cgi_size(i8* %14)
%16 = call i8* @myitoa(i32 %15)
%17 = call i32 @strcat(i8* %13, i8* %16)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @send(i32 %22, i8* %23, i32 %25, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Server: Light Web Server for cgi V1.1.5\0D\0A\00"
@.str.1 = [16 x i8] c"Content-Length:\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [19 x i8] c"Pragma: no-cache\0D\0A\00"
define void @create_cgi_res(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @send_date(i32 %0)
%6 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @get_cgi_size(i8* %1)
%9 = call i8* @myitoa(i32 %8)
%10 = call i32 @strcat(i8* %4, i8* %9)
%11 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @strlen(i8* %4)
%14 = call i32 @send(i32 %0, i8* %4, i32 %13, i32 0)
ret void
}