#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*/ find_indices(char *, int *, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ ft_putchar(char);
int /*<<< orphan*/ ft_putendl(char *);
int /*<<< orphan*/ ft_putnbr(int);
int /*<<< orphan*/ ft_putstr(char *);
char *ft_strjoin(char *, char *);
char *ft_strncpy(char *, char *, int);
char *ft_strnew(int);
int read(int const, char *, int);
int get_next_line(const int fd, char **line) {
  char *fulltext;
  char *tmp;
  char buf[32 + 1];
  static int nb_call;
  int i;
  int j;
  int indices[2];
  ft_putendl("DEBUT GNL");
  buf[32] = 0;
  if (nb_call == 0) {
    fulltext = ft_strnew(10);
    while ((i = read(fd, buf, 32))) {
      buf[i] = 0;
      tmp = fulltext;
      fulltext = ft_strjoin(fulltext, buf);
      free(tmp);
    }
  }
  ft_putendl("TEST");
  find_indices(fulltext, indices, nb_call);
  ft_putstr("indices[0] & indices[1] = ");
  ft_putnbr(indices[0]);
  ft_putchar(' ');
  ft_putnbr(indices[1]);
  ft_putendl("");
  *line = ft_strncpy(*line, &fulltext[indices[0]], indices[1] - indices[0]);
  ft_putendl("TEST2");
  if (fulltext[indices[0] + indices[1]] == '\0')
    return (0);
  nb_call++;
  return (1);
}


x86 assembly (clang, -O0):
<get_next_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe4a(%rip),%rdi
call   1050 <ft_putendl@plt>
movb   $0x0,-0x30(%rbp)
cmpl   $0x0,0x2eae(%rip)
jne    122c <get_next_line+0x8c>
mov    $0xa,%edi
call   1070 <ft_strnew@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x20,%edx
call   1060 <read@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
je     1227 <get_next_line+0x87>
movslq -0x54(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10a0 <ft_strjoin@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
jmp    11da <get_next_line+0x3a>
jmp    122c <get_next_line+0x8c>
lea    0xdd7(%rip),%rdi
call   1050 <ft_putendl@plt>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    0x2e2e(%rip),%edx
call   1030 <find_indices@plt>
lea    0xdbd(%rip),%rdi
call   10c0 <ft_putstr@plt>
mov    -0x60(%rbp),%edi
call   1090 <ft_putnbr@plt>
mov    $0x20,%edi
call   1080 <ft_putchar@plt>
mov    -0x5c(%rbp),%edi
call   1090 <ft_putnbr@plt>
lea    0xdb1(%rip),%rdi
call   1050 <ft_putendl@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x60(%rbp),%rax
add    %rax,%rsi
mov    -0x5c(%rbp),%edx
sub    -0x60(%rbp),%edx
call   10b0 <ft_strncpy@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    0xd7f(%rip),%rdi
call   1050 <ft_putendl@plt>
mov    -0x18(%rbp),%rax
mov    -0x60(%rbp),%ecx
add    -0x5c(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    12d6 <get_next_line+0x136>
movl   $0x0,-0x4(%rbp)
jmp    12ec <get_next_line+0x14c>
mov    0x2d98(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d8f(%rip)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
lea    0xe47(%rip),%rdi
call   1050 <ft_putendl@plt>
movb   $0x0,0x30(%rsp)
cmpl   $0x0,0x2eaa(%rip)
jne    1239 <get_next_line+0x99>
mov    $0xa,%edi
call   1070 <ft_strnew@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x20,%edx
call   1060 <read@plt>
test   %eax,%eax
je     1236 <get_next_line+0x96>
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <ft_strjoin@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x20,%edx
call   1060 <read@plt>
mov    %rbp,%rbx
test   %eax,%eax
jne    1200 <get_next_line+0x60>
jmp    1239 <get_next_line+0x99>
mov    %rbx,%rbp
lea    0xdca(%rip),%rdi
call   1050 <ft_putendl@plt>
mov    0x2e29(%rip),%edx
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1030 <find_indices@plt>
lea    0xdb0(%rip),%rdi
call   10c0 <ft_putstr@plt>
mov    0x8(%rsp),%edi
call   1090 <ft_putnbr@plt>
mov    $0x20,%edi
call   1080 <ft_putchar@plt>
mov    0xc(%rsp),%edi
call   1090 <ft_putnbr@plt>
lea    0xda2(%rip),%rdi
call   1050 <ft_putendl@plt>
mov    (%r14),%rdi
movslq 0x8(%rsp),%rsi
mov    0xc(%rsp),%edx
sub    %esi,%edx
add    %rbp,%rsi
call   10b0 <ft_strncpy@plt>
mov    %rax,(%r14)
lea    0xd7e(%rip),%rdi
call   1050 <ft_putendl@plt>
movslq 0x8(%rsp),%rax
movslq 0xc(%rsp),%rcx
add    %rax,%rcx
cmpb   $0x0,0x0(%rbp,%rcx,1)
je     12d3 <get_next_line+0x133>
addl   $0x1,0x2da8(%rip)
mov    $0x1,%eax
jmp    12d5 <get_next_line+0x135>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_next_line.nb_call = internal global i32 0
@.str = [10 x i8] c"DEBUT GNL\00"
@.str.1 = [5 x i8] c"TEST\00"
@.str.2 = [27 x i8] c"indices[0] & indices[1] = \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [6 x i8] c"TEST2\00"
define i32 @get_next_line(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [33 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2 x i32]
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 @ft_putendl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 32
store i8 0, i8* %13
%14 = load i32, i32* @get_next_line.nb_call
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %2
%17 = call i8* @ft_strnew(i32 10)
store i8* %17, i8** %6
br label %18
18: ; preds = %23, %16
%19 = load i32, i32* %4
%20 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 32)
store i32 %21, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 %25
store i8 0, i8* %26
%27 = load i8*, i8** %6
store i8* %27, i8** %7
%28 = load i8*, i8** %6
%29 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%30 = call i8* @ft_strjoin(i8* %28, i8* %29)
store i8* %30, i8** %6
%31 = load i8*, i8** %7
%32 = call i32 @free(i8* %31)
br label %18
33: ; preds = %18
br label %34
34: ; preds = %33, %2
%35 = call i32 @ft_putendl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = load i8*, i8** %6
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%38 = load i32, i32* @get_next_line.nb_call
%39 = call i32 @find_indices(i8* %36, i32* %37, i32 %38)
%40 = call i32 @ft_putstr(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%42 = load i32, i32* %41
%43 = call i32 @ft_putnbr(i32 %42)
%44 = call i32 @ft_putchar(i8 signext 32)
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%46 = load i32, i32* %45
%47 = call i32 @ft_putnbr(i32 %46)
%48 = call i32 @ft_putendl(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%49 = load i8**, i8*** %5
%50 = load i8*, i8** %49
%51 = load i8*, i8** %6
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%53 = load i32, i32* %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%57 = load i32, i32* %56
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%59 = load i32, i32* %58
%60 = sub nsw i32 %57, %59
%61 = call i8* @ft_strncpy(i8* %50, i8* %55, i32 %60)
%62 = load i8**, i8*** %5
store i8* %61, i8** %62
%63 = call i32 @ft_putendl(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%64 = load i8*, i8** %6
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%66 = load i32, i32* %65
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%68 = load i32, i32* %67
%69 = add nsw i32 %66, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %64, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %34
store i32 0, i32* %3
br label %79
76: ; preds = %34
%77 = load i32, i32* @get_next_line.nb_call
%78 = add nsw i32 %77, 1
store i32 %78, i32* @get_next_line.nb_call
store i32 1, i32* %3
br label %79
79: ; preds = %76, %75
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@get_next_line.nb_call = internal unnamed_addr global i32 0
@.str = [10 x i8] c"DEBUT GNL\00"
@.str.1 = [5 x i8] c"TEST\00"
@.str.2 = [27 x i8] c"indices[0] & indices[1] = \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [6 x i8] c"TEST2\00"
define i32 @get_next_line(i32 %0, i8** nocapture %1) {
%3 = alloca [33 x i8]
%4 = alloca [2 x i32]
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%6 = bitcast [2 x i32]* %4 to i8*
%7 = tail call i32 @ft_putendl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 32
store i8 0, i8* %8
%9 = load i32, i32* @get_next_line.nb_call
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = tail call i8* @ft_strnew(i32 10)
%13 = call i32 @read(i32 %0, i8* %5, i32 32)
%14 = icmp eq i32 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %11, %15
%16 = phi i32 [ %22, %15 ], [ %13, %11 ]
%17 = phi i8* [ %20, %15 ], [ %12, %11 ]
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i8* @ft_strjoin(i8* %17, i8* %5)
%21 = call i32 @free(i8* %17)
%22 = call i32 @read(i32 %0, i8* %5, i32 32)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %15
24: ; preds = %15, %11, %2
%25 = phi i8* [ undef, %2 ], [ %12, %11 ], [ %20, %15 ]
%26 = call i32 @ft_putendl(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%28 = load i32, i32* @get_next_line.nb_call
%29 = call i32 @find_indices(i8* %25, i32* %27, i32 %28)
%30 = call i32 @ft_putstr(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %27
%32 = call i32 @ft_putnbr(i32 %31)
%33 = call i32 @ft_putchar(i8 signext 32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%35 = load i32, i32* %34
%36 = call i32 @ft_putnbr(i32 %35)
%37 = call i32 @ft_putendl(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%38 = load i8*, i8** %1
%39 = load i32, i32* %27
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %25, i64 %40
%42 = load i32, i32* %34
%43 = sub nsw i32 %42, %39
%44 = call i8* @ft_strncpy(i8* %38, i8* %41, i32 %43)
store i8* %44, i8** %1
%45 = call i32 @ft_putendl(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %27
%47 = load i32, i32* %34
%48 = add nsw i32 %47, %46
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %25, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %24
%54 = load i32, i32* @get_next_line.nb_call
%55 = add nsw i32 %54, 1
store i32 %55, i32* @get_next_line.nb_call
br label %56
56: ; preds = %24, %53
%57 = phi i32 [ 1, %53 ], [ 0, %24 ]
ret i32 %57
}