#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*/ isspace(char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int tools_delete_spaces(char *expPtr) {
  int res = 1;
  char tmp[100] = {'\0'};
  strcpy(tmp, expPtr);
  int i = 0;
  int j = 0;
  int len = strlen(tmp);
  for (i = 0; i < len; i++) {
    char ch = tmp[i];
    if (!isspace(ch)) {
      expPtr[j] = ch;
      j++;
    }
  }
  expPtr[j] = '\0';
  res = 0;
  return res;
}


x86 assembly (clang, -O0):
<tools_delete_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    11e7 <tools_delete_spaces+0xa7>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x7d(%rbp)
movsbl -0x7d(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    11d4 <tools_delete_spaces+0x94>
mov    -0x7d(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11d9 <tools_delete_spaces+0x99>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1194 <tools_delete_spaces+0x54>
mov    -0x8(%rbp),%rax
movslq -0x78(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tools_delete_spaces>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b7 <tools_delete_spaces+0x87>
mov    %eax,%r14d
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    1199 <tools_delete_spaces+0x69>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     11ba <tools_delete_spaces+0x8a>
movzbl (%rsp,%rbx,1),%ebp
movsbl %bpl,%edi
call   1050 <isspace@plt>
test   %eax,%eax
jne    1190 <tools_delete_spaces+0x60>
movslq %r12d,%r12
mov    %bpl,(%r15,%r12,1)
add    $0x1,%r12d
jmp    1190 <tools_delete_spaces+0x60>
xor    %r12d,%r12d
movslq %r12d,%rax
movb   $0x0,(%r15,%rax,1)
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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