#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 */
char *GetSubString(char const *, int, int);
scalar_t__ malloc(int);
int strlen(char const *);
char *DeleteSpaces(const char *str) {
  int frontcounter = 0;
  int backcounter = 0;
  int goOn = 1;
  while (goOn) {
    switch (str[frontcounter]) {
    case ' ':
    case '\n':
    case '\t':
    case '\r':
      ++frontcounter;
      break;
    default:
      goOn = 0;
    }
  }
  goOn = 1;
  if (frontcounter == strlen(str)) {
    char *p = (char *)malloc(sizeof(char) * 1);
    p[0] = '\0';
    return p;
  }
  while (goOn) {
    switch (str[strlen(str) - 1 - backcounter]) {
    case ' ':
    case '\n':
    case '\t':
      ++backcounter;
      break;
    default:
      goOn = 0;
      break;
    }
  }
  if (frontcounter + backcounter == 0) {
    return GetSubString(str, 0, strlen(str));
  } else {
    return GetSubString(str, frontcounter,
                        strlen(str) - frontcounter - backcounter);
  }
}


x86 assembly (clang, -O0):
<DeleteSpaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b7 <DeleteSpaces+0x87>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
add    $0xfffffff7,%eax
sub    $0x2,%eax
jb     119d <DeleteSpaces+0x6d>
jmp    117b <DeleteSpaces+0x4b>
mov    -0x2c(%rbp),%eax
sub    $0xd,%eax
je     119d <DeleteSpaces+0x6d>
jmp    118c <DeleteSpaces+0x5c>
mov    -0x2c(%rbp),%eax
sub    $0x20,%eax
jne    11ab <DeleteSpaces+0x7b>
jmp    119d <DeleteSpaces+0x6d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <DeleteSpaces+0x82>
movl   $0x0,-0x1c(%rbp)
jmp    1151 <DeleteSpaces+0x21>
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jne    11fc <DeleteSpaces+0xcc>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12d0 <DeleteSpaces+0x1a0>
jmp    1201 <DeleteSpaces+0xd1>
cmpl   $0x0,-0x1c(%rbp)
je     126b <DeleteSpaces+0x13b>
mov    -0x10(%rbp),%rdi
mov    %rdi,-0x40(%rbp)
call   1030 <strlen@plt>
mov    %eax,%edx
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%ecx
not    %ecx
add    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
add    $0xfffffff7,%eax
sub    $0x2,%eax
jb     1251 <DeleteSpaces+0x121>
jmp    1240 <DeleteSpaces+0x110>
mov    -0x34(%rbp),%eax
sub    $0x20,%eax
jne    125f <DeleteSpaces+0x12f>
jmp    1251 <DeleteSpaces+0x121>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1266 <DeleteSpaces+0x136>
movl   $0x0,-0x1c(%rbp)
jmp    1201 <DeleteSpaces+0xd1>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cmp    $0x0,%eax
jne    12a1 <DeleteSpaces+0x171>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1050 <GetSubString@plt>
mov    %rax,-0x8(%rbp)
jmp    12d0 <DeleteSpaces+0x1a0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
sub    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
call   1050 <GetSubString@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DeleteSpaces>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
movabs $0x100002600,%rax
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%ecx
cmp    $0x20,%ecx
ja     1166 <DeleteSpaces+0x36>
bt     %rcx,%rax
jae    1166 <DeleteSpaces+0x36>
add    $0x1,%rbx
jmp    1150 <DeleteSpaces+0x20>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %ebx,%eax
jne    1188 <DeleteSpaces+0x58>
mov    $0x1,%edi
call   1040 <malloc@plt>
movb   $0x0,(%rax)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%ebp
movabs $0x100000600,%r12
mov    %ebx,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cltq
movsbl (%r14,%rax,1),%eax
cmp    $0x20,%eax
ja     11c5 <DeleteSpaces+0x95>
bt     %rax,%r12
jae    11c5 <DeleteSpaces+0x95>
add    $0x1,%r15d
add    $0xffffffff,%ebp
jmp    11a0 <DeleteSpaces+0x70>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %r15d,%r15d
je     11dc <DeleteSpaces+0xac>
sub    %r15d,%eax
mov    %r14,%rdi
mov    %ebx,%esi
jmp    11e1 <DeleteSpaces+0xb1>
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <GetSubString@plt>

LLVM IR (-O0):
define i8* @DeleteSpaces(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %21 [
i32 32, label %18
i32 10, label %18
i32 9, label %18
i32 13, label %18
]
18: ; preds = %11, %11, %11, %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %22
21: ; preds = %11
store i32 0, i32* %6
br label %22
22: ; preds = %21, %18
br label %8
23: ; preds = %8
store i32 1, i32* %6
%24 = load i32, i32* %4
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = icmp eq i32 %24, %26
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = call i64 @malloc(i32 1)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 0
store i8 0, i8* %32
%33 = load i8*, i8** %7
store i8* %33, i8** %2
br label %74
34: ; preds = %23
br label %35
35: ; preds = %53, %34
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %54
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = load i8*, i8** %3
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = load i32, i32* %5
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %39, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
switch i32 %48, label %52 [
i32 32, label %49
i32 10, label %49
i32 9, label %49
]
49: ; preds = %38, %38, %38
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %53
52: ; preds = %38
store i32 0, i32* %6
br label %53
53: ; preds = %52, %49
br label %35
54: ; preds = %35
%55 = load i32, i32* %4
%56 = load i32, i32* %5
%57 = add nsw i32 %55, %56
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %54
%60 = load i8*, i8** %3
%61 = load i8*, i8** %3
%62 = call i32 @strlen(i8* %61)
%63 = call i8* @GetSubString(i8* %60, i32 0, i32 %62)
store i8* %63, i8** %2
br label %74
64: ; preds = %54
%65 = load i8*, i8** %3
%66 = load i32, i32* %4
%67 = load i8*, i8** %3
%68 = call i32 @strlen(i8* %67)
%69 = load i32, i32* %4
%70 = sub nsw i32 %68, %69
%71 = load i32, i32* %5
%72 = sub nsw i32 %70, %71
%73 = call i8* @GetSubString(i8* %65, i32 %66, i32 %72)
store i8* %73, i8** %2
br label %74
74: ; preds = %64, %59, %28
%75 = load i8*, i8** %2
ret i8* %75
}

LLVM IR (-O2):
define i8* @DeleteSpaces(i8* %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i32 [ 0, %1 ], [ %9, %8 ]
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %10 [
i32 32, label %8
i32 10, label %8
i32 9, label %8
i32 13, label %8
]
8: ; preds = %2, %2, %2, %2
%9 = add nuw nsw i32 %3, 1
br label %2
10: ; preds = %2
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp eq i32 %3, %11
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i64 @malloc(i32 1)
%15 = inttoptr i64 %14 to i8*
store i8 0, i8* %15
br label %37
16: ; preds = %10, %25
%17 = phi i32 [ %26, %25 ], [ 0, %10 ]
%18 = tail call i32 @strlen(i8* %0)
%19 = xor i32 %17, -1
%20 = add i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
switch i32 %24, label %27 [
i32 32, label %25
i32 10, label %25
i32 9, label %25
]
25: ; preds = %16, %16, %16
%26 = add nuw nsw i32 %17, 1
br label %16
27: ; preds = %16
%28 = sub nsw i32 0, %17
%29 = icmp eq i32 %3, %28
%30 = tail call i32 @strlen(i8* %0)
br i1 %29, label %31, label %33
31: ; preds = %27
%32 = tail call i8* @GetSubString(i8* %0, i32 0, i32 %30)
br label %37
33: ; preds = %27
%34 = add nuw i32 %17, %3
%35 = sub i32 %30, %34
%36 = tail call i8* @GetSubString(i8* %0, i32 %3, i32 %35)
br label %37
37: ; preds = %33, %31, %13
%38 = phi i8* [ %15, %13 ], [ %32, %31 ], [ %36, %33 ]
ret i8* %38
}