#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 *white_trim(char *x) {
  char *y;
  if (!x)
    return (x);
  y = x + strlen(x) - 1;
  while (y >= x &&
         ((*y) == ' ' || (*y) == '\t' || (*y) == '\n' || (*y) == '\r'))
    *y-- = 0;
  return x;
}


x86 assembly (clang, -O0):
<white_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <white_trim+0x24>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f0 <white_trim+0xe0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     11c1 <white_trim+0xb1>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x22(%rbp)
je     11bb <white_trim+0xab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x22(%rbp)
je     11bb <white_trim+0xab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x22(%rbp)
je     11bb <white_trim+0xab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11d1 <white_trim+0xc1>
jmp    11e8 <white_trim+0xd8>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    1159 <white_trim+0x49>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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