#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 */
scalar_t__ eMalloc(size_t);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
char *nextStringLine(const char **const next) {
  char *result = NULL;
  size_t length;
  const char *end;
  do {
  } while (0);
  for (end = *next; *end != '\n' && *end != '\0'; ++end)
    ;
  length = end - *next;
  if (length > 0) {
    result = (char *)eMalloc((size_t)(length + 1) * sizeof(char));
    strncpy(result, *next, length);
    result[length] = '\0';
  }
  if (*end == '\n')
    ++end;
  else if (*end == '\r') {
    ++end;
    if (*end == '\n')
      ++end;
  }
  *next = end;
  return result;
}


x86 assembly (clang, -O0):
<nextStringLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
jmp    1139 <nextStringLine+0x19>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x21(%rbp)
je     1169 <nextStringLine+0x49>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1179 <nextStringLine+0x59>
jmp    118f <nextStringLine+0x6f>
jmp    117e <nextStringLine+0x5e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <nextStringLine+0x24>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    11e1 <nextStringLine+0xc1>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1040 <eMalloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1202 <nextStringLine+0xe2>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1244 <nextStringLine+0x124>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    123f <nextStringLine+0x11f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    123a <nextStringLine+0x11a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    123f <nextStringLine+0x11f>
jmp    1244 <nextStringLine+0x124>
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextStringLine>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%eax
test   %al,%al
je     1153 <nextStringLine+0x33>
cmp    $0xa,%al
je     1153 <nextStringLine+0x33>
add    $0x1,%rbx
jmp    1140 <nextStringLine+0x20>
lea    (%r12,%rbx,1),%r13
test   %rbx,%rbx
je     119d <nextStringLine+0x7d>
lea    0x1(%rbx),%rdi
call   1040 <eMalloc@plt>
mov    %rax,%r15
mov    (%r14),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbx,1)
mov    0x0(%r13),%al
cmp    $0xa,%al
je     11a4 <nextStringLine+0x84>
cmp    $0xd,%al
jne    11ac <nextStringLine+0x8c>
cmpb   $0xa,0x1(%r12,%rbx,1)
lea    0x1(%r12,%rbx,1),%rax
lea    0x2(%r12,%rbx,1),%r13
cmovne %rax,%r13
jmp    11ac <nextStringLine+0x8c>
xor    %r15d,%r15d
cmp    $0xa,%al
jne    1183 <nextStringLine+0x63>
lea    (%r12,%rbx,1),%r13
add    $0x1,%r13
mov    %r13,(%r14)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @nextStringLine(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8** %0, i8*** %2
store i8* null, i8** %3
br label %6
6: ; preds = %1
br label %7
7: ; preds = %6
%8 = load i8**, i8*** %2
%9 = load i8*, i8** %8
store i8* %9, i8** %5
br label %10
10: ; preds = %23, %7
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %15, %10
%21 = phi i1 [ false, %10 ], [ %19, %15 ]
br i1 %21, label %22, label %26
22: ; preds = %20
br label %23
23: ; preds = %22
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
br label %10
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = load i8**, i8*** %2
%29 = load i8*, i8** %28
%30 = ptrtoint i8* %27 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
store i64 %32, i64* %4
%33 = load i64, i64* %4
%34 = icmp ugt i64 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %26
%36 = load i64, i64* %4
%37 = add i64 %36, 1
%38 = mul i64 %37, 1
%39 = call i64 @eMalloc(i64 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %3
%41 = load i8*, i8** %3
%42 = load i8**, i8*** %2
%43 = load i8*, i8** %42
%44 = load i64, i64* %4
%45 = call i32 @strncpy(i8* %41, i8* %43, i64 %44)
%46 = load i8*, i8** %3
%47 = load i64, i64* %4
%48 = getelementptr inbounds i8, i8* %46, i64 %47
store i8 0, i8* %48
br label %49
49: ; preds = %35, %26
%50 = load i8*, i8** %5
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 10
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
br label %74
57: ; preds = %49
%58 = load i8*, i8** %5
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 13
br i1 %61, label %62, label %73
62: ; preds = %57
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %5
%65 = load i8*, i8** %5
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 10
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %5
br label %72
72: ; preds = %69, %62
br label %73
73: ; preds = %72, %57
br label %74
74: ; preds = %73, %54
%75 = load i8*, i8** %5
%76 = load i8**, i8*** %2
store i8* %75, i8** %76
%77 = load i8*, i8** %3
ret i8* %77
}

LLVM IR (-O2):
define i8* @nextStringLine(i8** nocapture %0) {
%2 = load i8*, i8** %0
br label %3
3: ; preds = %6, %1
%4 = phi i8* [ %2, %1 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 10, label %8
i8 0, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3, %3
%9 = ptrtoint i8* %4 to i64
%10 = ptrtoint i8* %2 to i64
%11 = sub i64 %9, %10
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %8
%14 = add i64 %11, 1
%15 = tail call i64 @eMalloc(i64 %14)
%16 = inttoptr i64 %15 to i8*
%17 = load i8*, i8** %0
%18 = tail call i32 @strncpy(i8* %16, i8* %17, i64 %11)
%19 = getelementptr inbounds i8, i8* %16, i64 %11
store i8 0, i8* %19
%20 = load i8, i8* %4
br label %21
21: ; preds = %13, %8
%22 = phi i8 [ %20, %13 ], [ %5, %8 ]
%23 = phi i8* [ %16, %13 ], [ null, %8 ]
switch i8 %22, label %32 [
i8 10, label %24
i8 13, label %26
]
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %4, i64 1
br label %32
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %4, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
%30 = getelementptr inbounds i8, i8* %4, i64 2
%31 = select i1 %29, i8* %30, i8* %27
br label %32
32: ; preds = %26, %21, %24
%33 = phi i8* [ %25, %24 ], [ %4, %21 ], [ %31, %26 ]
store i8* %33, i8** %0
ret i8* %23
}