#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 */
char *strrchr(char *, char);
char *r_trim(char *s) {
  char *p;
  if (NULL != (p = strrchr(s, ' ')))
    *p = 0;
  if (NULL != (p = strrchr(s, '\t')))
    *p = 0;
  if (NULL != (p = strrchr(s, '\r')))
    *p = 0;
  if (NULL != (p = strrchr(s, '\n')))
    *p = 0;
  return s;
}


x86 assembly (clang, -O0):
<r_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1143 <r_trim+0x33>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x9,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     116a <r_trim+0x5a>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0xd,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1191 <r_trim+0x81>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     11b8 <r_trim+0xa8>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r_trim>:
push   %rbx
mov    %rdi,%rbx
mov    $0x20,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1126 <r_trim+0x16>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     113b <r_trim+0x2b>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1150 <r_trim+0x40>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1165 <r_trim+0x55>
movb   $0x0,(%rax)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @r_trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strrchr(i8* %4, i8 signext 32)
store i8* %5, i8** %3
%6 = icmp ne i8* null, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i8*, i8** %3
store i8 0, i8* %8
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %2
%11 = call i8* @strrchr(i8* %10, i8 signext 9)
store i8* %11, i8** %3
%12 = icmp ne i8* null, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i8*, i8** %3
store i8 0, i8* %14
br label %15
15: ; preds = %13, %9
%16 = load i8*, i8** %2
%17 = call i8* @strrchr(i8* %16, i8 signext 13)
store i8* %17, i8** %3
%18 = icmp ne i8* null, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i8*, i8** %3
store i8 0, i8* %20
br label %21
21: ; preds = %19, %15
%22 = load i8*, i8** %2
%23 = call i8* @strrchr(i8* %22, i8 signext 10)
store i8* %23, i8** %3
%24 = icmp ne i8* null, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i8*, i8** %3
store i8 0, i8* %26
br label %27
27: ; preds = %25, %21
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
define i8* @r_trim(i8* returned %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 32)
%3 = icmp eq i8* %2, null
br i1 %3, label %5, label %4
4: ; preds = %1
store i8 0, i8* %2
br label %5
5: ; preds = %4, %1
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 9)
%7 = icmp eq i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %5
store i8 0, i8* %6
br label %9
9: ; preds = %8, %5
%10 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 13)
%11 = icmp eq i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %9
store i8 0, i8* %10
br label %13
13: ; preds = %12, %9
%14 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 10)
%15 = icmp eq i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13
store i8 0, i8* %14
br label %17
17: ; preds = %16, %13
ret i8* %0
}