#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 strip_end_blank(char *where) {
  char *now = where + strlen(where) - 1;
  while ((*now) && (now >= where) && ((*now == ' ') || (*now == '\t')))
    now--;
  if ((*now) && (now >= where)) {
    *(now + 1) = '\0';
  }
}


x86 assembly (clang, -O0):
<strip_end_blank>:
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
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1194 <strip_end_blank+0x84>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jb     1194 <strip_end_blank+0x84>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1a(%rbp)
je     118e <strip_end_blank+0x7e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a4 <strip_end_blank+0x94>
jmp    11b5 <strip_end_blank+0xa5>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1141 <strip_end_blank+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11db <strip_end_blank+0xcb>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     11db <strip_end_blank+0xcb>
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_end_blank>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    -0x1(%rbx,%rcx,1),%al
test   %al,%al
je     115b <strip_end_blank+0x4b>
lea    (%rbx,%rcx,1),%rdx
add    $0xffffffffffffffff,%rdx
cmp    %rbx,%rdx
jb     115b <strip_end_blank+0x4b>
add    %rbx,%rcx
add    $0xfffffffffffffffe,%rcx
nopl   0x0(%rax,%rax,1)
cmp    $0x20,%al
je     1148 <strip_end_blank+0x38>
cmp    $0x9,%al
jne    115d <strip_end_blank+0x4d>
movzbl (%rcx),%eax
test   %al,%al
je     115b <strip_end_blank+0x4b>
lea    -0x1(%rcx),%rdx
cmp    %rbx,%rcx
mov    %rdx,%rcx
jae    1140 <strip_end_blank+0x30>
pop    %rbx
ret
movb   $0x0,0x2(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
define void @strip_end_blank(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
%9 = getelementptr inbounds i8, i8* %8, i64 -1
store i8* %9, i8** %3
br label %10
10: ; preds = %33, %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %31
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8*, i8** %2
%18 = icmp uge i8* %16, %17
br i1 %18, label %19, label %31
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 %29, 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 label %29
29: ; preds = %24, %19
%30 = phi i1 [ true, %19 ], [ %28, %24 ]
br label %31
31: ; preds = %29, %15, %10
%32 = phi i1 [ false, %15 ], [ false, %10 ], [ %30, %29 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 -1
store i8* %35, i8** %3
br label %10
36: ; preds = %31
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %36
%42 = load i8*, i8** %3
%43 = load i8*, i8** %2
%44 = icmp uge i8* %42, %43
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 1
store i8 0, i8* %47
br label %48
48: ; preds = %45, %41, %36
ret void
}

LLVM IR (-O2):
define void @strip_end_blank(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 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = icmp ult i8* %5, %0
%9 = or i1 %7, %8
br i1 %9, label %21, label %10
10: ; preds = %1, %14
%11 = phi i8 [ %16, %14 ], [ %6, %1 ]
%12 = phi i8* [ %15, %14 ], [ %5, %1 ]
%13 = phi i8* [ %12, %14 ], [ %4, %1 ]
switch i8 %11, label %20 [
i8 32, label %14
i8 9, label %14
]
14: ; preds = %10, %10
%15 = getelementptr inbounds i8, i8* %12, i64 -1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
%18 = icmp ult i8* %15, %0
%19 = or i1 %17, %18
br i1 %19, label %21, label %10
20: ; preds = %10
store i8 0, i8* %13
br label %21
21: ; preds = %14, %1, %20
ret void
}