#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*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ write_socket(int, char *, int);
void ok(int client_sockfd) {
  char buffer[8096];
  char body[8096];
  sprintf(buffer, "HTTP/1.1 201 OK\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Server: httpServer/0.1.1\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Allow: POST\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Content-Type: text/html\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(body, "<HTML><HEAD><TITLE>POST OK</TITLE></HEAD>\r\n");
  sprintf(body + strlen(body), "<BODY><P>POST OK.</P></BODY></HTML>\r\n");
  sprintf(buffer, "Content-Length: %ld\r\n", strlen(body));
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  write_socket(client_sockfd, body, strlen(body));
}


x86 assembly (clang, -O0):
<ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3fd0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x1fb0(%rbp),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3fcc(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3fc8(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3fcc(%rbp),%edi
mov    -0x3fc8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3fbc(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3fb8(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3fbc(%rbp),%edi
mov    -0x3fb8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3fac(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3fa8(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3fac(%rbp),%edi
mov    -0x3fa8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f9c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f98(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f9c(%rbp),%edi
mov    -0x3f98(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x3f50(%rbp),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f90(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f90(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f88(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f88(%rbp),%rdi
mov    %eax,%edx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f7c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f78(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f7c(%rbp),%edi
mov    -0x3f78(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xcfd(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f6c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f68(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f6c(%rbp),%edi
mov    -0x3f68(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f5c(%rbp)
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f58(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f5c(%rbp),%edi
mov    -0x3f58(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3fd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ok>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f40,%rsp
mov    %edi,%ebx
movups 0xebb(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0xa,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xea4(%rip),%xmm0
movups %xmm0,0xb(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movabs $0x50203a776f6c6c41,%rax
3a 20 50
mov    %rax,(%rsp)
movabs $0xa0d54534f5020,%rax
mov    %rax,0x6(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe71(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe70(%rip),%xmm0
movups %xmm0,0xa(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe60(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xe61(%rip),%xmm0
movaps %xmm0,0x1fb0(%rsp)
movups 0xe5e(%rip),%xmm0
movups %xmm0,0x1fbc(%rsp)
lea    0x1fa0(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movups 0xe4d(%rip),%xmm0
movups %xmm0,0x1fa0(%rsp,%rax,1)
movups 0xe4e(%rip),%xmm0
movups %xmm0,0x1fb0(%rsp,%rax,1)
movabs $0xa0d3e4c4d5448,%rcx
mov    %rcx,0x1fbe(%rsp,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0xe3b(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movw   $0xa0d,(%rsp)
movb   $0x0,0x2(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3f40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.1 201 OK\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [14 x i8] c"Allow: POST\0D\0A\00"
@.str.3 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.4 = [44 x i8] c"<HTML><HEAD><TITLE>POST OK</TITLE></HEAD>\0D\0A\00"
@.str.5 = [38 x i8] c"<BODY><P>POST OK.</P></BODY></HTML>\0D\0A\00"
@.str.6 = [22 x i8] c"Content-Length: %ld\0D\0A\00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define void @ok(i32 %0) {
%2 = alloca i32
%3 = alloca [8096 x i8]
%4 = alloca [8096 x i8]
store i32 %0, i32* %2
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @write_socket(i32 %7, i8* %8, i32 %10)
%12 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @write_socket(i32 %14, i8* %15, i32 %17)
%19 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @write_socket(i32 %21, i8* %22, i32 %24)
%26 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @write_socket(i32 %28, i8* %29, i32 %31)
%33 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%35 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%36 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%41 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %2
%46 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%47 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%48 = call i32 @strlen(i8* %47)
%49 = call i32 @write_socket(i32 %45, i8* %46, i32 %48)
%50 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%51 = call i32 (i8*, i8*, ...) @sprintf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%52 = load i32, i32* %2
%53 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%54 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%55 = call i32 @strlen(i8* %54)
%56 = call i32 @write_socket(i32 %52, i8* %53, i32 %55)
%57 = load i32, i32* %2
%58 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%59 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @write_socket(i32 %57, i8* %58, i32 %60)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.1 201 OK\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [14 x i8] c"Allow: POST\0D\0A\00"
@.str.3 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.4 = [44 x i8] c"<HTML><HEAD><TITLE>POST OK</TITLE></HEAD>\0D\0A\00"
@.str.5 = [38 x i8] c"<BODY><P>POST OK.</P></BODY></HTML>\0D\0A\00"
@.str.6 = [22 x i8] c"Content-Length: %ld\0D\0A\00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define void @ok(i32 %0) {
%2 = alloca [8096 x i8]
%3 = alloca [8096 x i8]
%4 = getelementptr inbounds [8096 x i8], [8096 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 @strlen(i8* %4)
%7 = call i32 @write_socket(i32 %0, i8* %4, i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @write_socket(i32 %0, i8* %4, i32 %8)
%10 = call i32 @strlen(i8* %4)
%11 = call i32 @write_socket(i32 %0, i8* %4, i32 %10)
%12 = call i32 @strlen(i8* %4)
%13 = call i32 @write_socket(i32 %0, i8* %4, i32 %12)
%14 = call i32 @strlen(i8* %5)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 %15
%17 = call i32 @strlen(i8* %5)
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%19 = call i32 @strlen(i8* %4)
%20 = call i32 @write_socket(i32 %0, i8* %4, i32 %19)
%21 = call i32 @strlen(i8* %4)
%22 = call i32 @write_socket(i32 %0, i8* %4, i32 %21)
%23 = call i32 @strlen(i8* %5)
%24 = call i32 @write_socket(i32 %0, i8* %5, i32 %23)
ret void
}