#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*/ ft_strlen(char *);
char *ft_strnew(int /*<<< orphan*/);
char *get_line(char *, char **);
int text_copy(int const, char **);
int get_next_line(int const fd, char **line) {
  int ret;
  static char *offset;
  if (!line)
    return (-1);
  if (!offset)
    offset = ft_strnew(0);
  if ((ret = text_copy(fd, &offset)) == -1)
    return (-1);
  offset = get_line(offset, line);
  if ((!ret && !ft_strlen(offset) && !ft_strlen(*line)))
    return (0);
  else
    return (1);
}


x86 assembly (clang, -O0):
<get_next_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <get_next_line+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <get_next_line+0xc7>
cmpq   $0x0,0x2eda(%rip)
jne    1182 <get_next_line+0x42>
xor    %edi,%edi
call   1060 <ft_strnew@plt>
mov    %rax,0x2ec6(%rip)
mov    -0x8(%rbp),%edi
lea    0x2ebc(%rip),%rsi
call   1050 <text_copy@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11a9 <get_next_line+0x69>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <get_next_line+0xc7>
mov    0x2e98(%rip),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <get_line@plt>
mov    %rax,0x2e88(%rip)
cmpl   $0x0,-0x14(%rbp)
jne    1200 <get_next_line+0xc0>
mov    0x2e77(%rip),%rdi
call   1040 <ft_strlen@plt>
cmp    $0x0,%eax
jne    1200 <get_next_line+0xc0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ft_strlen@plt>
cmp    $0x0,%eax
jne    1200 <get_next_line+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    1207 <get_next_line+0xc7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_line>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
test   %rsi,%rsi
je     11b7 <get_next_line+0x77>
mov    %rsi,%r14
mov    %edi,%ebx
cmpq   $0x0,0x2eed(%rip)
jne    116b <get_next_line+0x2b>
xor    %edi,%edi
call   1060 <ft_strnew@plt>
mov    %rax,0x2edd(%rip)
lea    0x2ed6(%rip),%rsi
mov    %ebx,%edi
call   1050 <text_copy@plt>
cmp    $0xffffffff,%eax
je     11b7 <get_next_line+0x77>
mov    %eax,%ebx
mov    0x2ec1(%rip),%rdi
mov    %r14,%rsi
call   1030 <get_line@plt>
mov    %rax,0x2eb2(%rip)
test   %ebx,%ebx
jne    11b2 <get_next_line+0x72>
mov    %rax,%rdi
call   1040 <ft_strlen@plt>
test   %eax,%eax
jne    11b2 <get_next_line+0x72>
mov    (%r14),%rdi
call   1040 <ft_strlen@plt>
test   %eax,%eax
je     11be <get_next_line+0x7e>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    11b7 <get_next_line+0x77>

LLVM IR (-O0):
@get_next_line.offset = internal global i8* null
define i32 @get_next_line(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = icmp ne i8** %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 -1, i32* %3
br label %37
10: ; preds = %2
%11 = load i8*, i8** @get_next_line.offset
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i8* @ft_strnew(i32 0)
store i8* %14, i8** @get_next_line.offset
br label %15
15: ; preds = %13, %10
%16 = load i32, i32* %4
%17 = call i32 @text_copy(i32 %16, i8** @get_next_line.offset)
store i32 %17, i32* %6
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* %3
br label %37
20: ; preds = %15
%21 = load i8*, i8** @get_next_line.offset
%22 = load i8**, i8*** %5
%23 = call i8* @get_line(i8* %21, i8** %22)
store i8* %23, i8** @get_next_line.offset
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %36, label %26
26: ; preds = %20
%27 = load i8*, i8** @get_next_line.offset
%28 = call i32 @ft_strlen(i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 @ft_strlen(i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %30
store i32 0, i32* %3
br label %37
36: ; preds = %30, %26, %20
store i32 1, i32* %3
br label %37
37: ; preds = %36, %35, %19, %9
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@get_next_line.offset = internal global i8* null
define i32 @get_next_line(i32 %0, i8** %1) {
%3 = icmp eq i8** %1, null
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = load i8*, i8** @get_next_line.offset
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i8* @ft_strnew(i32 0)
store i8* %8, i8** @get_next_line.offset
br label %9
9: ; preds = %7, %4
%10 = tail call i32 @text_copy(i32 %0, i8** @get_next_line.offset)
%11 = icmp eq i32 %10, -1
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = load i8*, i8** @get_next_line.offset
%14 = tail call i8* @get_line(i8* %13, i8** %1)
store i8* %14, i8** @get_next_line.offset
%15 = icmp eq i32 %10, 0
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = tail call i32 @ft_strlen(i8* %14)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8*, i8** %1
%21 = tail call i32 @ft_strlen(i8* %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19, %16, %12
br label %24
24: ; preds = %19, %9, %2, %23
%25 = phi i32 [ 1, %23 ], [ -1, %2 ], [ -1, %9 ], [ 0, %19 ]
ret i32 %25
}