#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 *ini_rstrip(char *s) {
  char *p = s + strlen(s);
  while (p > s && ({
           int c = (*--p);
           !!((c >= '\t' && c <= '\r') || c == ' ');
         }))
    *p = '\0';
  return s;
}


x86 assembly (clang, -O0):
<ini_rstrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
jbe    11a2 <ini_rstrip+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl -0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jl     117f <ini_rstrip+0x6f>
mov    $0x1,%al
cmpl   $0xd,-0x14(%rbp)
mov    %al,-0x22(%rbp)
jle    1189 <ini_rstrip+0x79>
cmpl   $0x20,-0x14(%rbp)
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b2 <ini_rstrip+0xa2>
jmp    11be <ini_rstrip+0xae>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    113d <ini_rstrip+0x2d>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ini_rstrip>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    114e <ini_rstrip+0x3e>
mov    %eax,%eax
add    %rbx,%rax
jmp    113d <ini_rstrip+0x2d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,-0x1(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jbe    114e <ini_rstrip+0x3e>
movzbl -0x1(%rax),%ecx
lea    -0x9(%rcx),%edx
cmp    $0x5,%dl
jb     1130 <ini_rstrip+0x20>
cmp    $0x20,%cl
je     1130 <ini_rstrip+0x20>
mov    %rbx,%rax
pop    %rbx
ret

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

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