#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 *index(char *, char);
int /*<<< orphan*/ memmove(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void cstrip_spaces(char *msg) {
  char *p;
  p = msg;
  while ((p = index((p), (' '))) != NULL) {
    p++;
    while (*p == ' ')
      memmove(p, p + 1, strlen(p));
  }
}


x86 assembly (clang, -O0):
<cstrip_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <index@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11b2 <cstrip_spaces+0x82>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11ad <cstrip_spaces+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
jmp    116c <cstrip_spaces+0x3c>
jmp    1144 <cstrip_spaces+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cstrip_spaces>:
push   %r14
push   %rbx
push   %rax
mov    $0x20,%esi
call   1040 <index@plt>
test   %rax,%rax
je     119c <cstrip_spaces+0x6c>
mov    %rax,%r14
jmp    1165 <cstrip_spaces+0x35>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <index@plt>
mov    %rax,%r14
test   %rax,%rax
je     119c <cstrip_spaces+0x6c>
lea    0x1(%r14),%rbx
cmpb   $0x20,0x1(%r14)
jne    1150 <cstrip_spaces+0x20>
add    $0x2,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
cmpb   $0x20,(%rbx)
je     1180 <cstrip_spaces+0x50>
jmp    1150 <cstrip_spaces+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cstrip_spaces(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %24, %1
%6 = load i8*, i8** %3
%7 = call i8* @index(i8* %6, i8 signext 32)
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %25
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
br label %12
12: ; preds = %17, %9
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* %21)
%23 = call i32 @memmove(i8* %18, i8* %20, i32 %22)
br label %12
24: ; preds = %12
br label %5
25: ; preds = %5
ret void
}

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