#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*/ strncmp(char const *, char *, int);
int document_headers_done(char *full_page) {
  const char *body;
  for (body = full_page; *body; body++) {
    if (!strncmp(body, "\n\n", 2) || !strncmp(body, "\n\r\n", 3))
      break;
  }
  if (!*body)
    return 0;
  full_page[body - full_page] = 0;
  return 1;
}


x86 assembly (clang, -O0):
<document_headers_done>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1188 <document_headers_done+0x78>
mov    -0x18(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     116d <document_headers_done+0x5d>
mov    -0x18(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1172 <document_headers_done+0x62>
jmp    1188 <document_headers_done+0x78>
jmp    1177 <document_headers_done+0x67>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <document_headers_done+0x14>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11a1 <document_headers_done+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11bb <document_headers_done+0xab>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<document_headers_done>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
cmpb   $0x0,(%rdi)
je     1172 <document_headers_done+0x62>
mov    %rdi,%rbx
lea    0xed7(%rip),%r15
lea    0xed3(%rip),%rbp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1164 <document_headers_done+0x54>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1164 <document_headers_done+0x54>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1130 <document_headers_done+0x20>
jmp    1172 <document_headers_done+0x62>
cmpb   $0x0,(%rbx)
je     1172 <document_headers_done+0x62>
movb   $0x0,(%rbx)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [4 x i8] c"\0A\0D\0A\00"
define i32 @document_headers_done(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1, %11
%5 = phi i8* [ %12, %11 ], [ %0, %1 ]
%6 = tail call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = tail call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %5, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %23, label %4
15: ; preds = %4, %8
%16 = load i8, i8* %5
%17 = icmp eq i8 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = ptrtoint i8* %5 to i64
%20 = ptrtoint i8* %0 to i64
%21 = sub i64 %19, %20
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %11, %1, %15, %18
%24 = phi i32 [ 1, %18 ], [ 0, %15 ], [ 0, %1 ], [ 0, %11 ]
ret i32 %24
}