#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_isspace(char const);
int ft_find_end(char const *s, int *index, int high) {
  while (*index >= 0 && high != *index) {
    if (!ft_isspace(s[*index]) && high == -1) {
      high = *index;
      break;
    }
    (*index)--;
  }
  return (high);
}


x86 assembly (clang, -O0):
<ft_find_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x15(%rbp)
jl     1144 <ft_find_end+0x34>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1154 <ft_find_end+0x44>
jmp    1199 <ft_find_end+0x89>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <ft_isspace@plt>
cmp    $0x0,%eax
jne    1189 <ft_find_end+0x79>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1189 <ft_find_end+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <ft_find_end+0x89>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    1123 <ft_find_end+0x13>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_find_end>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    (%rsi),%eax
test   %eax,%eax
js     1158 <ft_find_end+0x48>
cmp    %ebp,%eax
je     1158 <ft_find_end+0x48>
mov    %rsi,%rbx
mov    %rdi,%r14
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%eax
movsbl (%r14,%rax,1),%edi
call   1030 <ft_isspace@plt>
mov    (%rbx),%ecx
cmp    $0xffffffff,%ebp
jne    1147 <ft_find_end+0x37>
test   %eax,%eax
je     1156 <ft_find_end+0x46>
lea    -0x1(%rcx),%eax
mov    %eax,(%rbx)
test   %ecx,%ecx
jle    1158 <ft_find_end+0x48>
cmp    %ebp,%eax
jne    1130 <ft_find_end+0x20>
jmp    1158 <ft_find_end+0x48>
mov    %ecx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ft_find_end(i8* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 0
%6 = icmp eq i32 %4, %2
%7 = or i1 %5, %6
br i1 %7, label %24, label %8
8: ; preds = %3
%9 = icmp eq i32 %2, -1
br label %10
10: ; preds = %8, %19
%11 = phi i32 [ %4, %8 ], [ %20, %19 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @ft_isspace(i8 signext %14)
%16 = icmp eq i32 %15, 0
%17 = and i1 %9, %16
%18 = load i32, i32* %1
br i1 %17, label %24, label %19
19: ; preds = %10
%20 = add nsw i32 %18, -1
store i32 %20, i32* %1
%21 = icmp slt i32 %18, 1
%22 = icmp eq i32 %20, %2
%23 = or i1 %21, %22
br i1 %23, label %24, label %10
24: ; preds = %19, %10, %3
%25 = phi i32 [ %2, %3 ], [ %18, %10 ], [ %2, %19 ]
ret i32 %25
}