#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 *);
void storage__rtrim(char *io) {
  char *p = io + strlen(io);
  while (--p && p >= io && *p <= ' ')
    *p = '\0';
}


x86 assembly (clang, -O0):
<storage__rtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     117b <storage__rtrim+0x6b>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jb     117b <storage__rtrim+0x6b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setle  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118b <storage__rtrim+0x7b>
jmp    1197 <storage__rtrim+0x87>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    113d <storage__rtrim+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<storage__rtrim>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jb     1141 <storage__rtrim+0x31>
nopw   0x0(%rax,%rax,1)
cmpb   $0x20,(%rax)
jg     1141 <storage__rtrim+0x31>
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jae    1130 <storage__rtrim+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @storage__rtrim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8* %8, i8** %3
br label %9
9: ; preds = %24, %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 -1
store i8* %11, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8*, i8** %2
%16 = icmp uge i8* %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 32
br label %22
22: ; preds = %17, %13, %9
%23 = phi i1 [ false, %13 ], [ false, %9 ], [ %21, %17 ]
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = load i8*, i8** %3
store i8 0, i8* %25
br label %9
26: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @storage__rtrim(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = icmp ult i8* %5, %0
br i1 %6, label %14, label %7
7: ; preds = %1, %11
%8 = phi i8* [ %12, %11 ], [ %5, %1 ]
%9 = load i8, i8* %8
%10 = icmp slt i8 %9, 33
br i1 %10, label %11, label %14
11: ; preds = %7
store i8 0, i8* %8
%12 = getelementptr inbounds i8, i8* %8, i64 -1
%13 = icmp ult i8* %12, %0
br i1 %13, label %14, label %7
14: ; preds = %7, %11, %1
ret void
}