#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 asprintf(char **, char *);
int /*<<< orphan*/ send_free(int, char **, int);
void bad_request(int client) {
  char *buffer = NULL;
  int bytes = asprintf(&buffer, "HTTP/1.0 400 BAD REQUEST\r\n");
  send_free(client, &buffer, bytes);
  ;
  bytes = asprintf(&buffer, "Content-type: text/html\r\n");
  send_free(client, &buffer, bytes);
  ;
  bytes = asprintf(&buffer, "\r\n");
  send_free(client, &buffer, bytes);
  ;
  bytes = asprintf(&buffer, "<P>Your browser sent a bad request, ");
  send_free(client, &buffer, bytes);
  ;
  bytes = asprintf(&buffer, "such as a POST without a Content-Length.\r\n");
  send_free(client, &buffer, bytes);
  ;
}


x86 assembly (clang, -O0):
<bad_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <asprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1030 <send_free@plt>
lea    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1040 <asprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1030 <send_free@plt>
lea    -0x10(%rbp),%rdi
lea    0xf00(%rip),%rsi
call   1040 <asprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1030 <send_free@plt>
lea    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1040 <asprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1030 <send_free@plt>
lea    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1040 <asprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1030 <send_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad_request>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movq   $0x0,(%rsp)
lea    0xecb(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <asprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_free@plt>
lea    0xec8(%rip),%rsi
mov    %r14,%rdi
call   1040 <asprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_free@plt>
lea    0xf14(%rip),%rsi
mov    %r14,%rdi
call   1040 <asprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_free@plt>
lea    0xeac(%rip),%rsi
mov    %r14,%rdi
call   1040 <asprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_free@plt>
lea    0xeb6(%rip),%rsi
mov    %r14,%rdi
call   1040 <asprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_free@plt>
add    $0x8,%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 i8*
%4 = alloca i32
store i32 %0, i32* %2
store i8* null, i8** %3
%5 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %4
%6 = load i32, i32* %2
%7 = load i32, i32* %4
%8 = call i32 @send_free(i32 %6, i8** %3, i32 %7)
%9 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 %9, i32* %4
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = call i32 @send_free(i32 %10, i8** %3, i32 %11)
%13 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = call i32 @send_free(i32 %14, i8** %3, i32 %15)
%17 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
store i32 %17, i32* %4
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = call i32 @send_free(i32 %18, i8** %3, i32 %19)
%21 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
store i32 %21, i32* %4
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = call i32 @send_free(i32 %22, i8** %3, i32 %23)
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 i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @send_free(i32 %0, i8** %2, i32 %4)
%6 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @send_free(i32 %0, i8** %2, i32 %6)
%8 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @send_free(i32 %0, i8** %2, i32 %8)
%10 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @send_free(i32 %0, i8** %2, i32 %10)
%12 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @send_free(i32 %0, i8** %2, i32 %12)
ret void
}