#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 parse_chop_whitespace(char *str) {
  char *tmp = str + strlen(str) - 1;
  while (tmp >= str &&
         (*tmp == ' ' || *tmp == '\t' || *tmp == '\n' || *tmp == '\r')) {
    *tmp = '\0';
    tmp--;
  }
}


x86 assembly (clang, -O0):
<parse_chop_whitespace>:
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),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jb     11a9 <parse_chop_whitespace+0x99>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1a(%rbp)
je     11a3 <parse_chop_whitespace+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x1a(%rbp)
je     11a3 <parse_chop_whitespace+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     11a3 <parse_chop_whitespace+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b9 <parse_chop_whitespace+0xa9>
jmp    11d1 <parse_chop_whitespace+0xc1>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1141 <parse_chop_whitespace+0x31>
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @parse_chop_whitespace(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 %13, label %7
7: ; preds = %1, %10
%8 = phi i8* [ %11, %10 ], [ %5, %1 ]
%9 = load i8, i8* %8
switch i8 %9, label %13 [
i8 32, label %10
i8 9, label %10
i8 10, label %10
i8 13, label %10
]
10: ; preds = %7, %7, %7, %7
store i8 0, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 -1
%12 = icmp ult i8* %11, %0
br i1 %12, label %13, label %7
13: ; preds = %10, %7, %1
ret void
}