#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*/ sn_decode_has(char *, char *, int);
int sn_decode_crlf(char **p, char *end) {
  char *start = *p;
  if (!sn_decode_has(start, end, 2))
    return (-1);
  if (*start != '\r')
    return (-2);
  if (*(start + 1) != '\n')
    return (-2);
  *p += 2;
  return 0;
}


x86 assembly (clang, -O0):
<sn_decode_crlf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1030 <sn_decode_has@plt>
cmp    $0x0,%eax
jne    1152 <sn_decode_crlf+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a0 <sn_decode_crlf+0x90>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     116e <sn_decode_crlf+0x5e>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11a0 <sn_decode_crlf+0x90>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
je     118b <sn_decode_crlf+0x7b>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11a0 <sn_decode_crlf+0x90>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x2,%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sn_decode_crlf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <sn_decode_has@plt>
test   %eax,%eax
je     1143 <sn_decode_crlf+0x33>
mov    $0xfffffffe,%eax
cmpb   $0xd,(%rbx)
jne    1148 <sn_decode_crlf+0x38>
cmpb   $0xa,0x1(%rbx)
jne    1148 <sn_decode_crlf+0x38>
addq   $0x2,(%r14)
xor    %eax,%eax
jmp    1148 <sn_decode_crlf+0x38>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @sn_decode_crlf(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%7 = load i8**, i8*** %4
%8 = load i8*, i8** %7
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = call i32 @sn_decode_has(i8* %9, i8* %10, i32 2)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 -1, i32* %3
br label %31
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 13
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 -2, i32* %3
br label %31
20: ; preds = %14
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 -2, i32* %3
br label %31
27: ; preds = %20
%28 = load i8**, i8*** %4
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8* %30, i8** %28
store i32 0, i32* %3
br label %31
31: ; preds = %27, %26, %19, %13
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @sn_decode_crlf(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = tail call i32 @sn_decode_has(i8* %3, i8* %1, i32 2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 13
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %0
%15 = getelementptr inbounds i8, i8* %14, i64 2
store i8* %15, i8** %0
br label %16
16: ; preds = %9, %6, %2, %13
%17 = phi i32 [ 0, %13 ], [ -1, %2 ], [ -2, %6 ], [ -2, %9 ]
ret i32 %17
}