#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 */
char *strstr(char const *, char *);
void separate_http_message(const char *message, int mlen,
                           const char **start_line, int *slen,
                           const char **header_lines, int *hlen,
                           const char **body, int *blen) {
  *start_line = message;
  *header_lines = strstr(*start_line, "\r\n");
  *header_lines += 2;
  *slen = *header_lines - *start_line - 2;
  *body = strstr(*header_lines, "\r\n\r\n");
  *body += 4;
  *hlen = *body - *header_lines - 2;
  *blen = mlen - *slen - *hlen - 4;
}


x86 assembly (clang, -O0):
<separate_http_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
add    $0x2,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
mov    0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
sub    (%rax),%ecx
mov    -0x30(%rbp),%rax
sub    (%rax),%ecx
sub    $0x4,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<separate_http_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%ebx
mov    0x40(%rsp),%rbp
mov    %rdi,(%rdx)
lea    0xeca(%rip),%rsi
call   1030 <strstr@plt>
lea    0x2(%rax),%rdi
mov    %rdi,(%r12)
mov    0x0(%r13),%eax
mov    %edi,%ecx
sub    %eax,%ecx
add    $0xfffffffe,%ecx
mov    %ecx,(%r14)
lea    0xea6(%rip),%rsi
call   1030 <strstr@plt>
add    $0x4,%rax
mov    %rax,0x0(%rbp)
sub    (%r12),%eax
lea    -0x2(%rax),%ecx
mov    %ecx,(%r15)
add    (%r14),%eax
sub    %eax,%ebx
add    $0xfffffffe,%ebx
mov    0x48(%rsp),%rax
mov    %ebx,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
define void @separate_http_message(i8* %0, i32 %1, i8** %2, i32* %3, i8** %4, i32* %5, i8** %6, i32* %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i8**
%14 = alloca i32*
%15 = alloca i8**
%16 = alloca i32*
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8** %2, i8*** %11
store i32* %3, i32** %12
store i8** %4, i8*** %13
store i32* %5, i32** %14
store i8** %6, i8*** %15
store i32* %7, i32** %16
%17 = load i8*, i8** %9
%18 = load i8**, i8*** %11
store i8* %17, i8** %18
%19 = load i8**, i8*** %11
%20 = load i8*, i8** %19
%21 = call i8* @strstr(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = load i8**, i8*** %13
store i8* %21, i8** %22
%23 = load i8**, i8*** %13
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 2
store i8* %25, i8** %23
%26 = load i8**, i8*** %13
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %11
%29 = load i8*, i8** %28
%30 = ptrtoint i8* %27 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = sub nsw i64 %32, 2
%34 = trunc i64 %33 to i32
%35 = load i32*, i32** %12
store i32 %34, i32* %35
%36 = load i8**, i8*** %13
%37 = load i8*, i8** %36
%38 = call i8* @strstr(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%39 = load i8**, i8*** %15
store i8* %38, i8** %39
%40 = load i8**, i8*** %15
%41 = load i8*, i8** %40
%42 = getelementptr inbounds i8, i8* %41, i64 4
store i8* %42, i8** %40
%43 = load i8**, i8*** %15
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %13
%46 = load i8*, i8** %45
%47 = ptrtoint i8* %44 to i64
%48 = ptrtoint i8* %46 to i64
%49 = sub i64 %47, %48
%50 = sub nsw i64 %49, 2
%51 = trunc i64 %50 to i32
%52 = load i32*, i32** %14
store i32 %51, i32* %52
%53 = load i32, i32* %10
%54 = load i32*, i32** %12
%55 = load i32, i32* %54
%56 = sub nsw i32 %53, %55
%57 = load i32*, i32** %14
%58 = load i32, i32* %57
%59 = sub nsw i32 %56, %58
%60 = sub nsw i32 %59, 4
%61 = load i32*, i32** %16
store i32 %60, i32* %61
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
define void @separate_http_message(i8* %0, i32 %1, i8** nocapture %2, i32* nocapture %3, i8** nocapture %4, i32* nocapture writeonly %5, i8** nocapture writeonly %6, i32* nocapture writeonly %7) {
store i8* %0, i8** %2
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8, i8* %9, i64 2
store i8* %10, i8** %4
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = trunc i64 %14 to i32
%16 = add i32 %15, -2
store i32 %16, i32* %3
%17 = tail call i8* @strstr(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds i8, i8* %17, i64 4
store i8* %18, i8** %6
%19 = load i8*, i8** %4
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
%24 = add i32 %23, -2
store i32 %24, i32* %5
%25 = load i32, i32* %3
%26 = sub i32 2, %23
%27 = add i32 %1, -4
%28 = sub i32 %27, %25
%29 = add i32 %28, %26
store i32 %29, i32* %7
ret void
}