#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 *strpbrk(char const *, char *);
const char *php_http_locate_eol(const char *line, int *eol_len) {
  const char *eol = strpbrk(line, "\r\n");
  if (eol_len) {
    *eol_len = eol ? ((eol[0] == '\r' && eol[1] == '\n') ? 2 : 1) : 0;
  }
  return eol;
}


x86 assembly (clang, -O0):
<php_http_locate_eol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <php_http_locate_eol+0x8e>
cmpq   $0x0,-0x18(%rbp)
je     118b <php_http_locate_eol+0x7b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x19(%rbp)
jne    1170 <php_http_locate_eol+0x60>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%dl
mov    $0x1,%eax
mov    $0x2,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    1195 <php_http_locate_eol+0x85>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1195 <php_http_locate_eol+0x85>
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<php_http_locate_eol>:
push   %rbx
mov    %rsi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strpbrk@plt>
test   %rbx,%rbx
je     1146 <php_http_locate_eol+0x36>
test   %rax,%rax
je     1142 <php_http_locate_eol+0x32>
mov    $0x1,%ecx
cmpb   $0xd,(%rax)
jne    1144 <php_http_locate_eol+0x34>
xor    %ecx,%ecx
cmpb   $0xa,0x1(%rax)
sete   %cl
add    $0x1,%ecx
jmp    1144 <php_http_locate_eol+0x34>
xor    %ecx,%ecx
mov    %ecx,(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define i8* @php_http_locate_eol(i8* %0, i32* writeonly %1) {
%3 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %1, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = icmp eq i8* %3, null
br i1 %6, label %15, label %7
7: ; preds = %5
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 13
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %3, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 10
%14 = select i1 %13, i32 2, i32 1
br label %15
15: ; preds = %7, %10, %5
%16 = phi i32 [ 0, %5 ], [ 1, %7 ], [ %14, %10 ]
store i32 %16, i32* %1
br label %17
17: ; preds = %15, %2
ret i8* %3
}