#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_putendl(char *);
void find_indices(char *str, int *indices, int nb) {
  int start;
  int end;
  int count;
  ft_putendl("DEBUT FIND_INDICES");
  start = -1;
  count = 0;
  while (count < nb) {
    if (str[++start] == '\0')
      break;
    if (str[start] == '\n')
      count++;
  }
  ft_putendl("TEST3");
  indices[0] = start + 1;
  end = start + 1;
  while (str[end] && str[end] != '\n')
    end++;
  indices[1] = end;
  ft_putendl("FIN FIND_INDICES");
}


x86 assembly (clang, -O0):
<find_indices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <ft_putendl@plt>
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118e <find_indices+0x7e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    116b <find_indices+0x5b>
jmp    118e <find_indices+0x7e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1189 <find_indices+0x79>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <find_indices+0x2d>
lea    0xe7e(%rip),%rdi
call   1030 <ft_putendl@plt>
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11de <find_indices+0xce>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ee <find_indices+0xde>
jmp    11fc <find_indices+0xec>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11af <find_indices+0x9f>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
lea    0xe0c(%rip),%rdi
call   1030 <ft_putendl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_indices>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xed9(%rip),%rdi
call   1030 <ft_putendl@plt>
test   %r15d,%r15d
jle    1161 <find_indices+0x51>
xor    %ecx,%ecx
xor    %eax,%eax
jmp    114c <find_indices+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%eax
lea    0x1(%rbp),%rcx
cmp    %r15d,%eax
jge    115c <find_indices+0x4c>
mov    %rcx,%rbp
movzbl (%rbx,%rcx,1),%ecx
cmp    $0xa,%cl
je     1140 <find_indices+0x30>
test   %cl,%cl
jne    1143 <find_indices+0x33>
add    $0x1,%ebp
jmp    1163 <find_indices+0x53>
xor    %ebp,%ebp
lea    0xea9(%rip),%rdi
call   1030 <ft_putendl@plt>
mov    %ebp,(%r14)
movslq %ebp,%rax
add    %rax,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     1194 <find_indices+0x84>
cmp    $0xa,%al
je     1194 <find_indices+0x84>
add    $0x1,%ebp
add    $0x1,%rbx
jmp    1180 <find_indices+0x70>
mov    %ebp,0x4(%r14)
lea    0xe7a(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ft_putendl@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"DEBUT FIND_INDICES\00"
@.str.1 = [6 x i8] c"TEST3\00"
@.str.2 = [17 x i8] c"FIN FIND_INDICES\00"
define void @find_indices(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = call i32 @ft_putendl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %7
store i32 0, i32* %9
br label %11
11: ; preds = %36, %3
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %15
br label %37
25: ; preds = %15
%26 = load i8*, i8** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %36
36: ; preds = %33, %25
br label %11
37: ; preds = %24, %11
%38 = call i32 @ft_putendl(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 0
store i32 %40, i32* %42
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %45
45: ; preds = %63, %37
%46 = load i8*, i8** %4
%47 = load i32, i32* %8
%48 = sext 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 ne i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %45
%54 = load i8*, i8** %4
%55 = load i32, i32* %8
%56 = sext 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 ne i32 %59, 10
br label %61
61: ; preds = %53, %45
%62 = phi i1 [ false, %45 ], [ %60, %53 ]
br i1 %62, label %63, label %66
63: ; preds = %61
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %45
66: ; preds = %61
%67 = load i32, i32* %8
%68 = load i32*, i32** %5
%69 = getelementptr inbounds i32, i32* %68, i64 1
store i32 %67, i32* %69
%70 = call i32 @ft_putendl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"DEBUT FIND_INDICES\00"
@.str.1 = [6 x i8] c"TEST3\00"
@.str.2 = [17 x i8] c"FIN FIND_INDICES\00"
define void @find_indices(i8* nocapture %0, i32* nocapture writeonly %1, i32 %2) {
%4 = tail call i32 @ft_putendl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %20
6: ; preds = %3, %14
%7 = phi i64 [ %9, %14 ], [ -1, %3 ]
%8 = phi i32 [ %15, %14 ], [ 0, %3 ]
%9 = add nsw i64 %7, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %14 [
i8 0, label %17
i8 10, label %12
]
12: ; preds = %6
%13 = add nsw i32 %8, 1
br label %14
14: ; preds = %6, %12
%15 = phi i32 [ %13, %12 ], [ %8, %6 ]
%16 = icmp slt i32 %15, %2
br i1 %16, label %6, label %17
17: ; preds = %6, %14
%18 = trunc i64 %9 to i32
%19 = add i32 %18, 1
br label %20
20: ; preds = %17, %3
%21 = phi i32 [ 0, %3 ], [ %19, %17 ]
%22 = tail call i32 @ft_putendl(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %1
%23 = sext i32 %21 to i64
br label %24
24: ; preds = %28, %20
%25 = phi i64 [ %29, %28 ], [ %23, %20 ]
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
switch i8 %27, label %28 [
i8 0, label %30
i8 10, label %30
]
28: ; preds = %24
%29 = add i64 %25, 1
br label %24
30: ; preds = %24, %24
%31 = trunc i64 %25 to i32
%32 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %31, i32* %32
%33 = tail call i32 @ft_putendl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret void
}