#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*/ EINVAL;
int /*<<< orphan*/ errno;
int token_to_line_feed(const char **src) {
  const char *tmp_src = NULL;
  if (src == NULL) {
    errno = EINVAL;
    return -1;
  }
  tmp_src = *src;
  while (!(*tmp_src == '\0' || *tmp_src == '\n')) {
    tmp_src++;
  }
  if (*tmp_src == '\n') {
    tmp_src++;
  }
  *src = tmp_src;
  return 0;
}


x86 assembly (clang, -O0):
<token_to_line_feed>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1139 <token_to_line_feed+0x39>
mov    0x2eb6(%rip),%rax
mov    (%rax),%ecx
mov    0x2eb5(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <token_to_line_feed+0xba>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1169 <token_to_line_feed+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    117b <token_to_line_feed+0x7b>
jmp    118c <token_to_line_feed+0x8c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1144 <token_to_line_feed+0x44>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a8 <token_to_line_feed+0xa8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_to_line_feed>:
test   %rdi,%rdi
je     1133 <token_to_line_feed+0x33>
mov    (%rdi),%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1122 <token_to_line_feed+0x22>
cmp    $0xa,%cl
je     1122 <token_to_line_feed+0x22>
add    $0x1,%rax
jmp    1110 <token_to_line_feed+0x10>
xor    %edx,%edx
cmp    $0xa,%cl
sete   %dl
add    %rdx,%rax
mov    %rax,(%rdi)
xor    %eax,%eax
ret
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    0x2e9d(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

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

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @token_to_line_feed(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @EINVAL
store i32 %4, i32* @errno
br label %16
5: ; preds = %1
%6 = load i8*, i8** %0
br label %7
7: ; preds = %10, %5
%8 = phi i8* [ %6, %5 ], [ %11, %10 ]
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 10, label %12
i8 0, label %12
]
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
12: ; preds = %7, %7
%13 = icmp eq i8 %9, 10
%14 = zext i1 %13 to i64
%15 = getelementptr i8, i8* %8, i64 %14
store i8* %15, i8** %0
br label %16
16: ; preds = %12, %3
%17 = phi i32 [ -1, %3 ], [ 0, %12 ]
ret i32 %17
}