#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*/ __strCopySub(char **, char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
char *strCreate();
size_t strFindLastNotOf(char *, char *);
int /*<<< orphan*/ strFree(char *);
void __strTrimRight(char **stringPtr) {
  char *ns;
  size_t pos;
  assert(stringPtr != NULL);
  assert(*stringPtr != NULL);
  ns = strCreate();
  pos = strFindLastNotOf(*stringPtr, " \t\r\n");
  if (pos >= 0)
    __strCopySub(&ns, *stringPtr, 0, pos + 1);
  strFree(*stringPtr);
  *stringPtr = ns;
}


x86 assembly (clang, -O0):
<__strTrimRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1040 <strCreate@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strFindLastNotOf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jb     11ca <__strTrimRight+0x7a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
lea    -0x10(%rbp),%rdi
xor    %edx,%edx
call   1060 <__strCopySub@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1070 <strFree@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__strTrimRight>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1040 <strCreate@plt>
mov    %rax,0x8(%rsp)
mov    (%rbx),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strFindLastNotOf@plt>
mov    (%rbx),%rsi
lea    0x1(%rax),%rcx
lea    0x8(%rsp),%rdi
xor    %edx,%edx
call   1060 <__strCopySub@plt>
mov    (%rbx),%rdi
call   1070 <strFree@plt>
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
define void @__strTrimRight(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i64
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = icmp ne i8** %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i8* (...) @strCreate()
store i8* %14, i8** %3
%15 = load i8**, i8*** %2
%16 = load i8*, i8** %15
%17 = call i64 @strFindLastNotOf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = icmp uge i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %1
%21 = load i8**, i8*** %2
%22 = load i8*, i8** %21
%23 = load i64, i64* %4
%24 = add i64 %23, 1
%25 = call i32 @__strCopySub(i8** %3, i8* %22, i32 0, i64 %24)
br label %26
26: ; preds = %20, %1
%27 = load i8**, i8*** %2
%28 = load i8*, i8** %27
%29 = call i32 @strFree(i8* %28)
%30 = load i8*, i8** %3
%31 = load i8**, i8*** %2
store i8* %30, i8** %31
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
define void @__strTrimRight(i8** %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp ne i8** %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = load i8*, i8** %0
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i8* (...) @strCreate()
store i8* %11, i8** %2
%12 = load i8*, i8** %0
%13 = tail call i64 @strFindLastNotOf(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %0
%15 = add i64 %13, 1
%16 = call i32 @__strCopySub(i8** %2, i8* %14, i32 0, i64 %15)
%17 = load i8*, i8** %0
%18 = call i32 @strFree(i8* %17)
%19 = load i8*, i8** %2
store i8* %19, i8** %0
ret void
}