#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 */
size_t chrLen(char const *);
void chrFandl(const char *string, size_t *index1, size_t *index2) {
  if (!string)
    return;
  *index2 = chrLen(string);
  if (*index2 == 0) {
    *index2 = 0;
    *index1 = 1;
  } else {
    (*index2)--;
    for (*index1 = 0; *index1 <= *index2; (*index1)++) {
      if (string[*index1] != ' ')
        break;
    }
  }
}


x86 assembly (clang, -O0):
<chrFandl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1134 <chrFandl+0x24>
jmp    11d7 <chrFandl+0xc7>
mov    -0x8(%rbp),%rdi
call   1030 <chrLen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1170 <chrFandl+0x60>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x1,(%rax)
jmp    11d7 <chrFandl+0xc7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
ja     11d2 <chrFandl+0xc2>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11ba <chrFandl+0xaa>
jmp    11d2 <chrFandl+0xc2>
jmp    11bf <chrFandl+0xaf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1189 <chrFandl+0x79>
jmp    11d7 <chrFandl+0xc7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chrFandl>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1162 <chrFandl+0x52>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <chrLen@plt>
test   %rax,%rax
je     1154 <chrFandl+0x44>
add    $0xffffffffffffffff,%rax
mov    %rax,(%r14)
movq   $0x0,(%r15)
xor    %eax,%eax
nopl   (%rax)
cmpb   $0x20,(%rbx,%rax,1)
jne    1162 <chrFandl+0x52>
add    $0x1,%rax
mov    %rax,(%r15)
cmp    (%r14),%rax
jbe    1140 <chrFandl+0x30>
jmp    1162 <chrFandl+0x52>
movq   $0x0,(%r14)
movq   $0x1,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

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