#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 *parseChars(char const *, int, int);
int /*<<< orphan*/ strlen(char *);
char *strstr(char const *, char *);
char *parseData(const char *request, int length) {
  char *delemiter = "\n\n";
  char *startPos = strstr(request, delemiter);
  if (startPos != NULL) {
    startPos += strlen(delemiter);
    int pos = startPos - request + 1;
    return parseChars(request, pos, length);
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<parseData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a9 <parseData+0x79>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <parseChars@plt>
mov    %rax,-0x8(%rbp)
jmp    11b1 <parseData+0x81>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseData>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xebf(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1172 <parseData+0x42>
mov    %rax,%rbp
lea    0xeab(%rip),%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
sub    %ebx,%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <parseChars@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
define i8* @parseData(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %6
%11 = call i8* @strstr(i8* %9, i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %31
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %7
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = load i8*, i8** %4
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = add nsw i64 %24, 1
%26 = trunc i64 %25 to i32
store i32 %26, i32* %8
%27 = load i8*, i8** %4
%28 = load i32, i32* %8
%29 = load i32, i32* %5
%30 = call i8* @parseChars(i8* %27, i32 %28, i32 %29)
store i8* %30, i8** %3
br label %32
31: ; preds = %2
store i8* null, i8** %3
br label %32
32: ; preds = %31, %14
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\0A\00"
define i8* @parseData(i8* %0, i32 %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %3, i64 %7
%9 = ptrtoint i8* %8 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = add i32 %12, 1
%14 = tail call i8* @parseChars(i8* %0, i32 %13, i32 %1)
br label %15
15: ; preds = %2, %5
%16 = phi i8* [ %14, %5 ], [ null, %2 ]
ret i8* %16
}