#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 *strip_white_space(char *p) {
  char *q;
  while (*p && (*p == ' ' || *p == '\t'))
    p++;
  for (q = p + strlen(p) - 1; q >= p && (*q == ' ' || *q == '\t'); q--)
    ;
  q[1] = 0;
  return p;
}


x86 assembly (clang, -O0):
<strip_white_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     115c <strip_white_space+0x4c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
je     1156 <strip_white_space+0x46>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    116c <strip_white_space+0x5c>
jmp    117d <strip_white_space+0x6d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <strip_white_space+0xc>
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
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     11e0 <strip_white_space+0xd0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x22(%rbp)
je     11da <strip_white_space+0xca>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11f0 <strip_white_space+0xe0>
jmp    1206 <strip_white_space+0xf6>
jmp    11f5 <strip_white_space+0xe5>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    11a2 <strip_white_space+0x92>
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_white_space>:
push   %rbx
mov    %rdi,%rbx
jmp    1124 <strip_white_space+0x14>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1120 <strip_white_space+0x10>
cmp    $0x9,%al
je     1120 <strip_white_space+0x10>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
add    %rbx,%rax
jmp    1158 <strip_white_space+0x48>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rcx
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rcx
jb     116a <strip_white_space+0x5a>
movzbl (%rcx),%edx
cmp    $0x20,%dl
je     1150 <strip_white_space+0x40>
cmp    $0x9,%dl
je     1150 <strip_white_space+0x40>
movb   $0x0,(%rax)
mov    %rbx,%rax
pop    %rbx
ret

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

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