#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 rstrip(char *buffer) {
  char *p;
  if (!*buffer)
    return;
  for (p = buffer + strlen(buffer) - 1; p >= buffer; p--) {
    if (!(*(p) == ' ' || *(p) == '\t' || *(p) == '\r' || *(p) == '\n'))
      break;
    *p = 0;
  }
}


x86 assembly (clang, -O0):
<rstrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    112e <rstrip+0x1e>
jmp    11be <rstrip+0xae>
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
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     11be <rstrip+0xae>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11a6 <rstrip+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11a6 <rstrip+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     11a6 <rstrip+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11a6 <rstrip+0x96>
jmp    11be <rstrip+0xae>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <rstrip+0x43>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rstrip>:
push   %rbx
cmpb   $0x0,(%rdi)
je     115b <rstrip+0x4b>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jb     115b <rstrip+0x4b>
movabs $0x100002600,%rcx
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%edx
cmp    $0x20,%rdx
ja     115b <rstrip+0x4b>
bt     %rdx,%rcx
jae    115b <rstrip+0x4b>
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jae    1140 <rstrip+0x30>
pop    %rbx
ret

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

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