#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__ isspace(unsigned char);
int trimRight_execute(unsigned char *input, long int input_len) {
  long int i = input_len - 1;
  while (i >= 0) {
    if (isspace(input[i]) == 0) {
      break;
    }
    input[i] = '\0';
    i--;
  }
  return i + 1;
}


x86 assembly (clang, -O0):
<trimRight_execute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jl     1174 <trimRight_execute+0x64>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    1157 <trimRight_execute+0x47>
jmp    1174 <trimRight_execute+0x64>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <trimRight_execute+0x1c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimRight_execute>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rsi,%rsi
jle    1146 <trimRight_execute+0x36>
mov    %rdi,%r14
nop
movzbl -0x1(%r14,%rbx,1),%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     1146 <trimRight_execute+0x36>
movb   $0x0,-0x1(%r14,%rbx,1)
add    $0xffffffffffffffff,%rbx
lea    0x1(%rbx),%rax
cmp    $0x1,%rax
ja     1120 <trimRight_execute+0x10>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @trimRight_execute(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = sub nsw i64 %6, 1
store i64 %7, i64* %5
br label %8
8: ; preds = %19, %2
%9 = load i64, i64* %5
%10 = icmp sge i64 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i64, i64* %5
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = call i64 @isspace(i8 zeroext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
br label %25
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i64, i64* %5
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8 0, i8* %22
%23 = load i64, i64* %5
%24 = add nsw i64 %23, -1
store i64 %24, i64* %5
br label %8
25: ; preds = %18, %8
%26 = load i64, i64* %5
%27 = add nsw i64 %26, 1
%28 = trunc i64 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
define i32 @trimRight_execute(i8* nocapture %0, i64 %1) {
%3 = icmp sgt i64 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %2, %11
%5 = phi i64 [ %6, %11 ], [ %1, %2 ]
%6 = add nsw i64 %5, -1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @isspace(i8 zeroext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
store i8 0, i8* %7
%12 = icmp ugt i64 %5, 1
br i1 %12, label %4, label %13
13: ; preds = %11, %4, %2
%14 = phi i64 [ %1, %2 ], [ %5, %4 ], [ 0, %11 ]
%15 = trunc i64 %14 to i32
ret i32 %15
}