#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 strlen(char *);
char *_rtrim(char *pStr) {
  char *p;
  if ((pStr == (0)) || (*pStr == 0)) {
    return pStr;
  }
  p = &pStr[strlen(pStr) - 1];
  while (*p == ' ' || *p == '\t')
    *p-- = '\0';
  return pStr;
}


x86 assembly (clang, -O0):
<_rtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1137 <_rtrim+0x27>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1144 <_rtrim+0x34>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bc <_rtrim+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     118d <_rtrim+0x7d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119d <_rtrim+0x8d>
jmp    11b4 <_rtrim+0xa4>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    1168 <_rtrim+0x58>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_rtrim>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1154 <_rtrim+0x44>
cmpb   $0x0,(%rbx)
je     1154 <_rtrim+0x44>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
jmp    1147 <_rtrim+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
movzbl (%rax),%ecx
cmp    $0x20,%cl
je     1140 <_rtrim+0x30>
cmp    $0x9,%cl
je     1140 <_rtrim+0x30>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @_rtrim(i8* returned %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
br label %11
11: ; preds = %14, %6
%12 = phi i8* [ %10, %6 ], [ %15, %14 ]
%13 = load i8, i8* %12
switch i8 %13, label %16 [
i8 32, label %14
i8 9, label %14
]
14: ; preds = %11, %11
%15 = getelementptr inbounds i8, i8* %12, i64 -1
store i8 0, i8* %12
br label %11
16: ; preds = %11, %1, %3
ret i8* %0
}