#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*/ strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int /*<<< orphan*/);
char *strstr(char const *, char *);
char *startOfDataForHTTPRequest(const char *httpData) {
  const char *ok200 = "HTTP/1.0 200 OK";
  if (strncmp(httpData, ok200, strlen(ok200)) == 0) {
    char *newlineLoc = strstr(httpData, "\r\n\r\n");
    if (newlineLoc) {
      return newlineLoc + 4;
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<startOfDataForHTTPRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ae <startOfDataForHTTPRequest+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a9 <startOfDataForHTTPRequest+0x79>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <startOfDataForHTTPRequest+0x86>
jmp    11ae <startOfDataForHTTPRequest+0x7e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startOfDataForHTTPRequest>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     115c <startOfDataForHTTPRequest+0x2c>
xor    %eax,%eax
jmp    1174 <startOfDataForHTTPRequest+0x44>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1158 <startOfDataForHTTPRequest+0x28>
add    $0x4,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"HTTP/1.0 200 OK\00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
define i8* @startOfDataForHTTPRequest(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = call i64 @strncmp(i8* %6, i8* %7, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 4
store i8* %19, i8** %2
br label %22
20: ; preds = %12
br label %21
21: ; preds = %20, %1
store i8* null, i8** %2
br label %22
22: ; preds = %21, %17
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [16 x i8] c"HTTP/1.0 200 OK\00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
define i8* @startOfDataForHTTPRequest(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
%8 = getelementptr inbounds i8, i8* %6, i64 4
br i1 %7, label %9, label %10
9: ; preds = %5, %1
br label %10
10: ; preds = %5, %9
%11 = phi i8* [ null, %9 ], [ %8, %5 ]
ret i8* %11
}