#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*/ file_manager_get_filetype(char const *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write_complete(int const, char *, int /*<<< orphan*/);
void clientsuccess(const int fd, const char *filename, const int length,
                   const int status) {
  char filetype[256], buf[8192];
  file_manager_get_filetype(filename, filetype);
  sprintf(buf, "HTTP/1.0 200 OK\r\n");
  sprintf(buf, "%sServer: Simple Web Server\r\n", buf);
  sprintf(buf, "%sContent-length: %d\r\n", buf, length);
  sprintf(buf, "%sContent-type: %s\r\n\r\n", buf, filetype);
  write_complete(fd, buf, strlen(buf));
}


x86 assembly (clang, -O0):
<clientsuccess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1040 <file_manager_get_filetype@plt>
lea    -0x2120(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x2120(%rbp),%rdi
lea    -0x2120(%rbp),%rdx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x2120(%rbp),%rdi
lea    -0x2120(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x2120(%rbp),%rdi
lea    -0x2120(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x212c(%rbp)
lea    -0x2120(%rbp),%rax
mov    %rax,-0x2128(%rbp)
lea    -0x2120(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x212c(%rbp),%edi
mov    -0x2128(%rbp),%rsi
mov    %eax,%edx
call   1050 <write_complete@plt>
add    $0x2130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clientsuccess>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2108,%rsp
mov    %edx,%ebp
mov    %edi,%r15d
mov    %rsp,%r14
mov    %rsi,%rdi
mov    %r14,%rsi
call   1040 <file_manager_get_filetype@plt>
movups 0xe99(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movw   $0xa,0x110(%rsp)
lea    0xe92(%rip),%rsi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write_complete@plt>
add    $0x2108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [30 x i8] c"%sServer: Simple Web Server\0D\0A\00"
@.str.2 = [23 x i8] c"%sContent-length: %d\0D\0A\00"
@.str.3 = [23 x i8] c"%sContent-type: %s\0D\0A\0D\0A\00"
define void @clientsuccess(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [8192 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%13 = call i32 @file_manager_get_filetype(i8* %11, i8* %12)
%14 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%20 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%21 = load i32, i32* %7
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32 %21)
%23 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25)
%27 = load i32, i32* %5
%28 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @write_complete(i32 %27, i8* %28, i32 %30)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.1 = [30 x i8] c"%sServer: Simple Web Server\0D\0A\00"
@.str.2 = [23 x i8] c"%sContent-length: %d\0D\0A\00"
@.str.3 = [23 x i8] c"%sContent-type: %s\0D\0A\0D\0A\00"
define void @clientsuccess(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = alloca [8192 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%9 = call i32 @file_manager_get_filetype(i8* %1, i8* %7)
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 %2)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %7)
%13 = call i32 @strlen(i8* %8)
%14 = call i32 @write_complete(i32 %0, i8* %8, i32 %13)
ret void
}