const char *copacin_nextline(const char *p) {
  while (*p && *p != '\n' && *p != '\r')
    p++;
  while (*p == '\n' || *p == '\r')
    p++;
  return p;
}


x86 assembly (clang, -O0):
<copacin_nextline>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     1142 <copacin_nextline+0x42>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x9(%rbp)
je     1142 <copacin_nextline+0x42>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1152 <copacin_nextline+0x52>
jmp    1163 <copacin_nextline+0x63>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <copacin_nextline+0x8>
jmp    1168 <copacin_nextline+0x68>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0xa(%rbp)
je     118d <copacin_nextline+0x8d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    119d <copacin_nextline+0x9d>
jmp    11ae <copacin_nextline+0xae>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1168 <copacin_nextline+0x68>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<copacin_nextline>:
mov    %rdi,%rax
mov    $0x2401,%edx
jmp    1114 <copacin_nextline+0x14>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0xd,%rcx
ja     1110 <copacin_nextline+0x10>
bt     %rcx,%rdx
jae    1110 <copacin_nextline+0x10>
jmp    1138 <copacin_nextline+0x38>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0xd,%cl
je     1130 <copacin_nextline+0x30>
cmp    $0xa,%cl
je     1130 <copacin_nextline+0x30>
ret

LLVM IR (-O0):
define i8* @copacin_nextline(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %20, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 13
br label %18
18: ; preds = %13, %8, %3
%19 = phi i1 [ false, %8 ], [ false, %3 ], [ %17, %13 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
br label %3
23: ; preds = %18
br label %24
24: ; preds = %36, %23
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 13
br label %34
34: ; preds = %29, %24
%35 = phi i1 [ true, %24 ], [ %33, %29 ]
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %2
br label %24
39: ; preds = %34
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
define i8* @copacin_nextline(i8* %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i8* [ %0, %1 ], [ %7, %6 ]
%4 = load i8, i8* %3
switch i8 %4, label %6 [
i8 0, label %5
i8 10, label %5
i8 13, label %5
]
5: ; preds = %2, %2, %2
br label %8
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
8: ; preds = %5, %11
%9 = phi i8 [ %13, %11 ], [ %4, %5 ]
%10 = phi i8* [ %12, %11 ], [ %3, %5 ]
switch i8 %9, label %14 [
i8 10, label %11
i8 13, label %11
]
11: ; preds = %8, %8
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = load i8, i8* %12
br label %8
14: ; preds = %8
ret i8* %10
}