#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 TOOLS_RemovePadding(char **ppInputStr) {
  char *pStartPtr;
  char *pEndPtr;
  if (ppInputStr == NULL) {
    return;
  }
  for (pEndPtr = (*ppInputStr + strlen(*ppInputStr) - 1); *pEndPtr == ' ';
       pEndPtr--) {
  }
  *(pEndPtr + 1) = '\0';
  for (pStartPtr = *ppInputStr; *pStartPtr == ' '; pStartPtr++) {
  }
  *ppInputStr = pStartPtr;
  return;
}


x86 assembly (clang, -O0):
<TOOLS_RemovePadding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <TOOLS_RemovePadding+0x1c>
jmp    11c1 <TOOLS_RemovePadding+0xb1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%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),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    117d <TOOLS_RemovePadding+0x6d>
jmp    116c <TOOLS_RemovePadding+0x5c>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1157 <TOOLS_RemovePadding+0x47>
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b6 <TOOLS_RemovePadding+0xa6>
jmp    11a5 <TOOLS_RemovePadding+0x95>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1190 <TOOLS_RemovePadding+0x80>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TOOLS_RemovePadding>:
test   %rdi,%rdi
je     1164 <TOOLS_RemovePadding+0x54>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %r14,%rax
add    $0x1,%rax
cmpb   $0x20,-0x2(%rax)
lea    -0x1(%rax),%rax
je     1130 <TOOLS_RemovePadding+0x20>
movb   $0x0,(%rax)
mov    (%rbx),%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
je     1150 <TOOLS_RemovePadding+0x40>
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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