#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*/ sprintf(char *, char *, char *);
char *ParseTextAreaLines(char *cTextArea) {
  static unsigned uEnd = 0;
  static unsigned uStart = 0;
  static char cRetVal[512];
  uStart = uEnd;
  while (cTextArea[uEnd++]) {
    if (cTextArea[uEnd] == '\n' || cTextArea[uEnd] == '\r' ||
        cTextArea[uEnd] == 0 || cTextArea[uEnd] == 10 ||
        cTextArea[uEnd] == 13) {
      if (cTextArea[uEnd] == 0)
        break;
      cTextArea[uEnd] = 0;
      sprintf(cRetVal, "%.511s", cTextArea + uStart);
      if (cRetVal[0] == '\n' || cRetVal[0] == 13) {
        uStart = uEnd = 0;
        return ("");
      }
      if (cTextArea[uEnd + 1] == 10)
        uEnd += 2;
      else
        uEnd++;
      return (cRetVal);
    }
  }
  if (uStart != uEnd) {
    sprintf(cRetVal, "%.511s", cTextArea + uStart);
    return (cRetVal);
  }
  uStart = uEnd = 0;
  return ("");
}


x86 assembly (clang, -O0):
<ParseTextAreaLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2f1e(%rip),%eax
mov    %eax,0x2f1c(%rip)
mov    -0x10(%rbp),%rax
mov    0x2f0e(%rip),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,0x2f03(%rip)
mov    %ecx,%ecx
cmpb   $0x0,(%rax,%rcx,1)
je     129e <ParseTextAreaLines+0x18e>
mov    -0x10(%rbp),%rax
mov    0x2eed(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11bc <ParseTextAreaLines+0xac>
mov    -0x10(%rbp),%rax
mov    0x2ed6(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
je     11bc <ParseTextAreaLines+0xac>
mov    -0x10(%rbp),%rax
mov    0x2ebf(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11bc <ParseTextAreaLines+0xac>
mov    -0x10(%rbp),%rax
mov    0x2ea8(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11bc <ParseTextAreaLines+0xac>
mov    -0x10(%rbp),%rax
mov    0x2e91(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    1299 <ParseTextAreaLines+0x189>
mov    -0x10(%rbp),%rax
mov    0x2e7a(%rip),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11d8 <ParseTextAreaLines+0xc8>
jmp    129e <ParseTextAreaLines+0x18e>
mov    -0x10(%rbp),%rax
mov    0x2e5e(%rip),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdx
mov    0x2e54(%rip),%eax
add    %rax,%rdx
lea    0x2e56(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1030 <sprintf@plt>
movsbl 0x2e43(%rip),%eax
cmp    $0xa,%eax
je     1226 <ParseTextAreaLines+0x116>
movsbl 0x2e33(%rip),%eax
cmp    $0xd,%eax
jne    124a <ParseTextAreaLines+0x13a>
movl   $0x0,0x2e10(%rip)
movl   $0x0,0x2e0a(%rip)
lea    0xdc5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ff <ParseTextAreaLines+0x1ef>
mov    -0x10(%rbp),%rax
mov    0x2dec(%rip),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    127a <ParseTextAreaLines+0x16a>
mov    0x2dd4(%rip),%eax
add    $0x2,%eax
mov    %eax,0x2dcb(%rip)
jmp    1289 <ParseTextAreaLines+0x179>
mov    0x2dc0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2db7(%rip)
lea    0x2dc0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ff <ParseTextAreaLines+0x1ef>
jmp    1128 <ParseTextAreaLines+0x18>
mov    0x2da0(%rip),%eax
cmp    0x2d96(%rip),%eax
je     12e0 <ParseTextAreaLines+0x1d0>
mov    -0x10(%rbp),%rdx
mov    0x2d8a(%rip),%eax
add    %rax,%rdx
lea    0x2d8c(%rip),%rdi
lea    0xd35(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2d79(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ff <ParseTextAreaLines+0x1ef>
movl   $0x0,0x2d56(%rip)
movl   $0x0,0x2d50(%rip)
lea    0xd0b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseTextAreaLines>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    0x2f22(%rip),%ecx
lea    (%rdi,%rcx,1),%rdx
mov    (%rdi,%rcx,1),%bl
mov    $0xffffffff,%eax
nopw   0x0(%rax,%rax,1)
test   %bl,%bl
je     119c <ParseTextAreaLines+0x8c>
lea    0x1(%rcx),%esi
mov    %esi,%edi
movzbl (%r15,%rdi,1),%ebx
test   %bl,%bl
je     119c <ParseTextAreaLines+0x8c>
cmp    $0xd,%bl
je     1151 <ParseTextAreaLines+0x41>
add    $0xffffffff,%eax
mov    %esi,%ecx
cmp    $0xa,%bl
jne    1130 <ParseTextAreaLines+0x20>
mov    %esi,0x2ee9(%rip)
movb   $0x0,(%r15,%rdi,1)
lea    0x2eed(%rip),%r14
lea    0xe96(%rip),%rsi
mov    %r14,%rdi
call   1030 <sprintf@plt>
mov    0x2ed8(%rip),%al
cmp    $0xd,%al
je     11c1 <ParseTextAreaLines+0xb1>
cmp    $0xa,%al
je     11c1 <ParseTextAreaLines+0xb1>
mov    0x2eba(%rip),%eax
lea    0x1(%rax),%ecx
add    $0x2,%eax
cmpb   $0xa,(%r15,%rcx,1)
cmovne %ecx,%eax
mov    %eax,0x2ea6(%rip)
jmp    11d2 <ParseTextAreaLines+0xc2>
add    $0x1,%ecx
mov    %ecx,0x2e9b(%rip)
test   %eax,%eax
je     11c1 <ParseTextAreaLines+0xb1>
lea    0x2ea0(%rip),%r14
lea    0xe49(%rip),%rsi
mov    %r14,%rdi
call   1030 <sprintf@plt>
jmp    11d2 <ParseTextAreaLines+0xc2>
movl   $0x0,0x2e75(%rip)
lea    0xe34(%rip),%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ParseTextAreaLines.uEnd = internal global i32 0
@ParseTextAreaLines.uStart = internal global i32 0
@ParseTextAreaLines.cRetVal = internal global [512 x i8] zeroinitializer
@.str = [7 x i8] c"%.511s\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @ParseTextAreaLines(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i32, i32* @ParseTextAreaLines.uEnd
store i32 %4, i32* @ParseTextAreaLines.uStart
br label %5
5: ; preds = %96, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* @ParseTextAreaLines.uEnd
%8 = add i32 %7, 1
store i32 %8, i32* @ParseTextAreaLines.uEnd
%9 = zext i32 %7 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %97
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* @ParseTextAreaLines.uEnd
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %53, label %21
21: ; preds = %13
%22 = load i8*, i8** %3
%23 = load i32, i32* @ParseTextAreaLines.uEnd
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 13
br i1 %28, label %53, label %29
29: ; preds = %21
%30 = load i8*, i8** %3
%31 = load i32, i32* @ParseTextAreaLines.uEnd
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %53, label %37
37: ; preds = %29
%38 = load i8*, i8** %3
%39 = load i32, i32* @ParseTextAreaLines.uEnd
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 10
br i1 %44, label %53, label %45
45: ; preds = %37
%46 = load i8*, i8** %3
%47 = load i32, i32* @ParseTextAreaLines.uEnd
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 13
br i1 %52, label %53, label %96
53: ; preds = %45, %37, %29, %21, %13
%54 = load i8*, i8** %3
%55 = load i32, i32* @ParseTextAreaLines.uEnd
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %53
br label %97
62: ; preds = %53
%63 = load i8*, i8** %3
%64 = load i32, i32* @ParseTextAreaLines.uEnd
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 0, i8* %66
%67 = load i8*, i8** %3
%68 = load i32, i32* @ParseTextAreaLines.uStart
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = call i32 @sprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %70)
%72 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0)
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 10
br i1 %74, label %79, label %75
75: ; preds = %62
%76 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0)
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 13
br i1 %78, label %79, label %80
79: ; preds = %75, %62
store i32 0, i32* @ParseTextAreaLines.uEnd
store i32 0, i32* @ParseTextAreaLines.uStart
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %108
80: ; preds = %75
%81 = load i8*, i8** %3
%82 = load i32, i32* @ParseTextAreaLines.uEnd
%83 = add i32 %82, 1
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 10
br i1 %88, label %89, label %92
89: ; preds = %80
%90 = load i32, i32* @ParseTextAreaLines.uEnd
%91 = add i32 %90, 2
store i32 %91, i32* @ParseTextAreaLines.uEnd
br label %95
92: ; preds = %80
%93 = load i32, i32* @ParseTextAreaLines.uEnd
%94 = add i32 %93, 1
store i32 %94, i32* @ParseTextAreaLines.uEnd
br label %95
95: ; preds = %92, %89
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8** %2
br label %108
96: ; preds = %45
br label %5
97: ; preds = %61, %5
%98 = load i32, i32* @ParseTextAreaLines.uStart
%99 = load i32, i32* @ParseTextAreaLines.uEnd
%100 = icmp ne i32 %98, %99
br i1 %100, label %101, label %107
101: ; preds = %97
%102 = load i8*, i8** %3
%103 = load i32, i32* @ParseTextAreaLines.uStart
%104 = zext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %102, i64 %104
%106 = call i32 @sprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %105)
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8** %2
br label %108
107: ; preds = %97
store i32 0, i32* @ParseTextAreaLines.uEnd
store i32 0, i32* @ParseTextAreaLines.uStart
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %108
108: ; preds = %107, %101, %95, %79
%109 = load i8*, i8** %2
ret i8* %109
}

LLVM IR (-O2):
@ParseTextAreaLines.uEnd = internal unnamed_addr global i32 0
@ParseTextAreaLines.cRetVal = internal global [512 x i8] zeroinitializer
@.str = [7 x i8] c"%.511s\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @ParseTextAreaLines(i8* %0) {
%2 = load i32, i32* @ParseTextAreaLines.uEnd
%3 = zext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
br label %6
6: ; preds = %11, %1
%7 = phi i8 [ %14, %11 ], [ %5, %1 ]
%8 = phi i32 [ %9, %11 ], [ %2, %1 ]
%9 = add i32 %8, 1
%10 = icmp eq i8 %7, 0
br i1 %10, label %30, label %11
11: ; preds = %6
%12 = zext i32 %9 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %6 [
i8 0, label %30
i8 10, label %15
i8 13, label %15
]
15: ; preds = %11, %11
%16 = zext i32 %9 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i32 %9, i32* @ParseTextAreaLines.uEnd
store i8 0, i8* %17
%18 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4)
%19 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0)
switch i8 %19, label %21 [
i8 13, label %20
i8 10, label %20
]
20: ; preds = %15, %15
store i32 0, i32* @ParseTextAreaLines.uEnd
br label %35
21: ; preds = %15
%22 = load i32, i32* @ParseTextAreaLines.uEnd
%23 = add i32 %22, 1
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
%28 = add i32 %22, 2
%29 = select i1 %27, i32 %28, i32 %23
store i32 %29, i32* @ParseTextAreaLines.uEnd
br label %35
30: ; preds = %11, %6
store i32 %9, i32* @ParseTextAreaLines.uEnd
%31 = icmp eq i32 %2, %9
br i1 %31, label %34, label %32
32: ; preds = %30
%33 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %35
34: ; preds = %30
store i32 0, i32* @ParseTextAreaLines.uEnd
br label %35
35: ; preds = %34, %32, %21, %20
%36 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), %32 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %34 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %20 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @ParseTextAreaLines.cRetVal, i64 0, i64 0), %21 ]
ret i8* %36
}