#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 */
char *strchr(char *, char);
int nextLine(char **s, char **l) {
  char *nextLine = NULL;
  if (*s == NULL || **s == '\0')
    return -1;
  *l = *s;
  nextLine = strchr(*s, '\n');
  if (nextLine) {
    *nextLine = '\0';
    *s = nextLine + 1;
  } else {
    nextLine = strchr(*s, '\0');
    *s = nextLine;
  }
  return 1;
}


x86 assembly (clang, -O0):
<nextLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1149 <nextLine+0x39>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1155 <nextLine+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <nextLine+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119e <nextLine+0x8e>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11bb <nextLine+0xab>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextLine>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     116d <nextLine+0x4d>
cmpb   $0x0,(%rcx)
je     116d <nextLine+0x4d>
mov    %rdi,%rbx
mov    %rcx,(%rsi)
mov    (%rdi),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     115a <nextLine+0x3a>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    1165 <nextLine+0x45>
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r14,%rax
mov    %rax,(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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