#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *);
void bad_request(int client) {
  char buf[1024];
  sprintf(buf, "HTTP/1.0 400 BAD REQUEST\r\n");
  send(client, buf, sizeof(buf), 0);
  sprintf(buf, "Content-type: text/html\r\n");
  send(client, buf, sizeof(buf), 0);
  sprintf(buf, "\r\n");
  send(client, buf, sizeof(buf), 0);
  sprintf(buf, "<P>Your browser sent a bad request, ");
  send(client, buf, sizeof(buf), 0);
  sprintf(buf, "such as a POST without a Content-Length.\r\n");
  send(client, buf, sizeof(buf), 0);
}


x86 assembly (clang, -O0):
<bad_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xec4(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xef4(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad_request>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
movups 0xee8(%rip),%xmm0
movups %xmm0,0xb(%rsp)
movups 0xed1(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
movups 0xecf(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xece(%rip),%xmm0
movups %xmm0,0xa(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
movw   $0xa0d,(%rsp)
movb   $0x0,0x2(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
movabs $0x202c7473657571,%rax
mov    %rax,0x1d(%rsp)
movups 0xe96(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe9b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
movups 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe97(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"HTTP/1.0 400 BAD REQUEST\0D\0A\00"
@.str.1 = [26 x i8] c"Content-type: text/html\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [37 x i8] c"<P>Your browser sent a bad request, \00"
@.str.4 = [43 x i8] c"such as a POST without a Content-Length.\0D\0A\00"
define void @bad_request(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = call i32 @send(i32 %6, i8* %7, i32 1024, i32 0)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32 @send(i32 %11, i8* %12, i32 1024, i32 0)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%18 = call i32 @send(i32 %16, i8* %17, i32 1024, i32 0)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%23 = call i32 @send(i32 %21, i8* %22, i32 1024, i32 0)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%28 = call i32 @send(i32 %26, i8* %27, i32 1024, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"HTTP/1.0 400 BAD REQUEST\0D\0A\00"
@.str.1 = [26 x i8] c"Content-type: text/html\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [37 x i8] c"<P>Your browser sent a bad request, \00"
@.str.4 = [43 x i8] c"such as a POST without a Content-Length.\0D\0A\00"
define void @bad_request(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @send(i32 %0, i8* %3, i32 1024, i32 0)
%5 = call i32 @send(i32 %0, i8* %3, i32 1024, i32 0)
%6 = call i32 @send(i32 %0, i8* %3, i32 1024, i32 0)
%7 = call i32 @send(i32 %0, i8* %3, i32 1024, i32 0)
%8 = call i32 @send(i32 %0, i8* %3, i32 1024, i32 0)
ret void
}