#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 */
typedef size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ secFree(char *);
char *secGetStringPart(char const *, size_t, size_t);
size_t strlen(char const *);
ssize_t getNextLineFromString(const char *ccp_string, char **cpp_current_line,
                              ssize_t i_offset) {
  ssize_t i = 0;
  if (*cpp_current_line != NULL)
    secFree(*cpp_current_line);
  for (i = i_offset; i < strlen(ccp_string) && ccp_string[i] != '\n'; ++i)
    ;
  *cpp_current_line = secGetStringPart(ccp_string, i_offset, i);
  return i + 1;
}


x86 assembly (clang, -O0):
<getNextLineFromString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1166 <getNextLineFromString+0x36>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <secFree@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x21(%rbp)
jae    11a9 <getNextLineFromString+0x79>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b9 <getNextLineFromString+0x89>
jmp    11cf <getNextLineFromString+0x9f>
jmp    11be <getNextLineFromString+0x8e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116e <getNextLineFromString+0x3e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <secGetStringPart@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextLineFromString>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rsi),%rdi
test   %rdi,%rdi
je     114e <getNextLineFromString+0x1e>
call   1050 <secFree@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r15,%rbx
cmp    %r15,%rax
jbe    1183 <getNextLineFromString+0x53>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0xa,(%r12,%rbx,1)
je     1183 <getNextLineFromString+0x53>
add    $0x1,%rbx
cmp    %rbx,%rax
jne    1170 <getNextLineFromString+0x40>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <secGetStringPart@plt>
mov    %rax,(%r14)
add    $0x1,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @getNextLineFromString(i8* %0, i8** nocapture %1, i64 %2) {
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @secFree(i8* %4)
br label %8
8: ; preds = %6, %3
%9 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%10 = icmp ugt i64 %9, %2
br i1 %10, label %11, label %19
11: ; preds = %8, %16
%12 = phi i64 [ %17, %16 ], [ %2, %8 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = add i64 %12, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %19, label %11
19: ; preds = %11, %16, %8
%20 = phi i64 [ %2, %8 ], [ %9, %16 ], [ %12, %11 ]
%21 = tail call i8* @secGetStringPart(i8* %0, i64 %2, i64 %20)
store i8* %21, i8** %1
%22 = add i64 %20, 1
ret i64 %22
}