#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 */
scalar_t__ _citrus_bcs_isspace(char const);
void _citrus_bcs_trunc_rws_len(const char *__restrict p,
                               size_t *__restrict len) {
  while (*len > 0 && _citrus_bcs_isspace(p[*len - 1]))
    (*len)--;
}


x86 assembly (clang, -O0):
<_citrus_bcs_trunc_rws_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x11(%rbp)
jbe    1155 <_citrus_bcs_trunc_rws_len+0x45>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <_citrus_bcs_isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1165 <_citrus_bcs_trunc_rws_len+0x55>
jmp    1178 <_citrus_bcs_trunc_rws_len+0x68>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
jmp    1120 <_citrus_bcs_trunc_rws_len+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_bcs_trunc_rws_len>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%rbx
test   %rbx,%rbx
je     1148 <_citrus_bcs_trunc_rws_len+0x38>
mov    %rsi,%r15
mov    %rdi,%r14
add    $0xffffffffffffffff,%rbx
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <_citrus_bcs_isspace@plt>
test   %rax,%rax
je     1148 <_citrus_bcs_trunc_rws_len+0x38>
mov    %rbx,(%r15)
add    $0xffffffffffffffff,%rbx
jb     1130 <_citrus_bcs_trunc_rws_len+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @_citrus_bcs_trunc_rws_len(i8* noalias %0, i64* noalias %1) {
%3 = alloca i8*
%4 = alloca i64*
store i8* %0, i8** %3
store i64* %1, i64** %4
br label %5
5: ; preds = %20, %2
%6 = load i64*, i64** %4
%7 = load i64, i64* %6
%8 = icmp ugt i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i64*, i64** %4
%12 = load i64, i64* %11
%13 = sub i64 %12, 1
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = call i64 @_citrus_bcs_isspace(i8 signext %15)
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %9, %5
%19 = phi i1 [ false, %5 ], [ %17, %9 ]
br i1 %19, label %20, label %24
20: ; preds = %18
%21 = load i64*, i64** %4
%22 = load i64, i64* %21
%23 = add i64 %22, -1
store i64 %23, i64* %21
br label %5
24: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @_citrus_bcs_trunc_rws_len(i8* noalias nocapture %0, i64* noalias nocapture %1) {
%3 = load i64, i64* %1
%4 = icmp eq i64 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %12
%6 = phi i64 [ %7, %12 ], [ %3, %2 ]
%7 = add i64 %6, -1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @_citrus_bcs_isspace(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %5
store i64 %7, i64* %1
%13 = icmp eq i64 %7, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %12, %2
ret void
}