#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 /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strsub(char *, char *, int, int);
void StripSpaces(char *data) {
  int i, j;
  char STR1[4096];
  i = 1;
  j = (int)strlen(data);
  if (!j)
    return;
  while ((data[i - 1] == ' ') && (i < j))
    i++;
  while ((data[j - 1] == ' ') && (j > 1))
    j--;
  strsub(STR1, data, (int)i, (int)(j - i + 1));
  strcpy(data, STR1);
}


x86 assembly (clang, -O0):
<StripSpaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1161 <StripSpaces+0x31>
jmp    1239 <StripSpaces+0x109>
jmp    1166 <StripSpaces+0x36>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x1011(%rbp)
jne    1197 <StripSpaces+0x67>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setl   %al
mov    %al,-0x1011(%rbp)
mov    -0x1011(%rbp),%al
test   $0x1,%al
jne    11aa <StripSpaces+0x7a>
jmp    11b8 <StripSpaces+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <StripSpaces+0x36>
jmp    11bd <StripSpaces+0x8d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x1012(%rbp)
jne    11ec <StripSpaces+0xbc>
cmpl   $0x1,-0x10(%rbp)
setg   %al
mov    %al,-0x1012(%rbp)
mov    -0x1012(%rbp),%al
test   $0x1,%al
jne    11ff <StripSpaces+0xcf>
jmp    120d <StripSpaces+0xdd>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <StripSpaces+0x8d>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    $0x1,%ecx
call   1050 <strsub@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripSpaces>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     11a2 <StripSpaces+0x72>
movslq %eax,%rcx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    115f <StripSpaces+0x2f>
cmp    %rcx,%rdx
jl     1150 <StripSpaces+0x20>
sub    %edx,%eax
add    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%eax
cmpb   $0x20,-0x1(%rbx,%rcx,1)
jne    1187 <StripSpaces+0x57>
lea    -0x1(%rcx),%rsi
cmp    $0x1,%rcx
mov    %rsi,%rcx
jg     1170 <StripSpaces+0x40>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%ecx
call   1050 <strsub@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @StripSpaces(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4096 x i8]
store i8* %0, i8** %2
store i32 1, i32* %3
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
br label %61
12: ; preds = %1
br label %13
13: ; preds = %28, %12
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%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 = %13
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br label %26
26: ; preds = %22, %13
%27 = phi i1 [ false, %13 ], [ %25, %22 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %13
31: ; preds = %26
br label %32
32: ; preds = %46, %31
%33 = load i8*, i8** %2
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 32
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, 1
br label %44
44: ; preds = %41, %32
%45 = phi i1 [ false, %32 ], [ %43, %41 ]
br i1 %45, label %46, label %49
46: ; preds = %44
%47 = load i32, i32* %4
%48 = add nsw i32 %47, -1
store i32 %48, i32* %4
br label %32
49: ; preds = %44
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%51 = load i8*, i8** %2
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = load i32, i32* %3
%55 = sub nsw i32 %53, %54
%56 = add nsw i32 %55, 1
%57 = call i32 @strsub(i8* %50, i8* %51, i32 %52, i32 %56)
%58 = load i8*, i8** %2
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%60 = call i32 @strcpy(i8* %58, i8* %59)
br label %61
61: ; preds = %49, %11
ret void
}

LLVM IR (-O2):
define void @StripSpaces(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = trunc i64 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %34, label %7
7: ; preds = %1
%8 = shl i64 %4, 32
%9 = ashr exact i64 %8, 32
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 1, %7 ], [ %18, %10 ]
%12 = add nsw i64 %11, -1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
%16 = icmp slt i64 %11, %9
%17 = select i1 %15, i1 %16, i1 false
%18 = add nuw nsw i64 %11, 1
br i1 %17, label %10, label %19
19: ; preds = %10, %19
%20 = phi i64 [ %21, %19 ], [ %9, %10 ]
%21 = add nsw i64 %20, -1
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 32
%25 = icmp sgt i64 %20, 1
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %19, label %27
27: ; preds = %19
%28 = trunc i64 %11 to i32
%29 = trunc i64 %20 to i32
%30 = sub nsw i32 1, %28
%31 = add i32 %30, %29
%32 = call i32 @strsub(i8* %3, i8* %0, i32 %28, i32 %31)
%33 = call i32 @strcpy(i8* %0, i8* %3)
br label %34
34: ; preds = %1, %27
ret void
}