#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 CStrings__strlen_unbounded(char *);
scalar_t__ Characters__is_space_or_tab(char);
char *CStrings__trim_white_space(char *original) {
  int i;
  for (i = 0; Characters__is_space_or_tab(original[i]); i++)
    ;
  original += i;
  for (i = CStrings__strlen_unbounded(original) - 1;
       ((i >= 0) && (Characters__is_space_or_tab(original[i]))); i--)
    original[i] = 0;
  return original;
}


x86 assembly (clang, -O0):
<CStrings__trim_white_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <Characters__is_space_or_tab@plt>
cmp    $0x0,%rax
je     1161 <CStrings__trim_white_space+0x41>
jmp    1153 <CStrings__trim_white_space+0x33>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <CStrings__trim_white_space+0x13>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <CStrings__strlen_unbounded@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     11ab <CStrings__trim_white_space+0x8b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <Characters__is_space_or_tab@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11bb <CStrings__trim_white_space+0x9b>
jmp    11d5 <CStrings__trim_white_space+0xb5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <CStrings__trim_white_space+0x61>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CStrings__trim_white_space>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0xffffffffffffffff,%rbx
nop
movsbl 0x1(%r14,%rbx,1),%edi
call   1030 <Characters__is_space_or_tab@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1130 <CStrings__trim_white_space+0x10>
mov    %ebx,%eax
add    %rax,%r14
mov    %r14,%rdi
call   1040 <CStrings__strlen_unbounded@plt>
test   %eax,%eax
jle    1182 <CStrings__trim_white_space+0x62>
mov    %eax,%ebx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%r15d
movsbl (%r14,%r15,1),%edi
call   1030 <Characters__is_space_or_tab@plt>
test   %rax,%rax
je     1182 <CStrings__trim_white_space+0x62>
movb   $0x0,(%r14,%r15,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1160 <CStrings__trim_white_space+0x40>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @CStrings__trim_white_space(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %8, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i64 @Characters__is_space_or_tab(i8 signext %5)
%7 = icmp eq i64 %6, 0
%8 = add nuw i64 %3, 1
br i1 %7, label %9, label %2
9: ; preds = %2
%10 = and i64 %3, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = tail call i32 @CStrings__strlen_unbounded(i8* %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = zext i32 %12 to i64
br label %16
16: ; preds = %14, %24
%17 = phi i64 [ %15, %14 ], [ %18, %24 ]
%18 = add nsw i64 %17, -1
%19 = and i64 %18, 4294967295
%20 = getelementptr inbounds i8, i8* %11, i64 %19
%21 = load i8, i8* %20
%22 = tail call i64 @Characters__is_space_or_tab(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %16
store i8 0, i8* %20
%25 = icmp ugt i64 %17, 1
br i1 %25, label %16, label %26
26: ; preds = %16, %24, %9
ret i8* %11
}