#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 *, char *);
char *separate_CRLF(char *string) {
  char *p = strpbrk(string, "\r\n");
  if (!p)
    return NULL;
  char c = *p;
  *p = '\0';
  p++;
  if ((c == '\n' && *p == '\r') || (c == '\r' && *p == '\n'))
    p++;
  return p;
}


x86 assembly (clang, -O0):
<separate_CRLF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1148 <separate_CRLF+0x38>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <separate_CRLF+0xa2>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1181 <separate_CRLF+0x71>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     119e <separate_CRLF+0x8e>
movsbl -0x19(%rbp),%eax
cmp    $0xd,%eax
jne    11aa <separate_CRLF+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11aa <separate_CRLF+0x9a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<separate_CRLF>:
push   %rax
lea    0xee8(%rip),%rsi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     113c <separate_CRLF+0x2c>
mov    (%rax),%dl
movb   $0x0,(%rax)
lea    0x1(%rax),%rcx
cmp    $0xd,%dl
je     1140 <separate_CRLF+0x30>
cmp    $0xa,%dl
jne    114c <separate_CRLF+0x3c>
cmpb   $0xd,(%rcx)
je     1145 <separate_CRLF+0x35>
jmp    114c <separate_CRLF+0x3c>
xor    %ecx,%ecx
jmp    114c <separate_CRLF+0x3c>
cmpb   $0xa,(%rcx)
jne    114c <separate_CRLF+0x3c>
add    $0x2,%rax
mov    %rax,%rcx
mov    %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
define i8* @separate_CRLF(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
%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** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* null, i8** %2
br label %39
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
store i8 %13, i8* %5
%14 = load i8*, i8** %4
store i8 0, i8* %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %25
20: ; preds = %11
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 13
br i1 %24, label %34, label %25
25: ; preds = %20, %11
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 13
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %37
34: ; preds = %29, %20
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %37
37: ; preds = %34, %29, %25
%38 = load i8*, i8** %4
store i8* %38, i8** %2
br label %39
39: ; preds = %37, %10
%40 = load i8*, i8** %2
ret i8* %40
}

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