#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*/ isblank(char);
void remove_space(char *str) {
  char *s1 = str;
  int i;
  for (i = 0; str[i] != '\0'; ++i) {
    if (!isblank(str[i])) {
      *s1++ = str[i];
    }
  }
  *s1 = '\0';
}


x86 assembly (clang, -O0):
<remove_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1189 <remove_space+0x79>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isblank@plt>
cmp    $0x0,%eax
jne    1176 <remove_space+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    117b <remove_space+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <remove_space+0x1b>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_space>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1154 <remove_space+0x44>
lea    0x1(%r14),%rbx
jmp    113b <remove_space+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1154 <remove_space+0x44>
movsbl %al,%edi
call   1030 <isblank@plt>
test   %eax,%eax
jne    1130 <remove_space+0x20>
movzbl -0x1(%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
jmp    1130 <remove_space+0x20>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @remove_space(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %31, %1
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %6
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @isblank(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %14
%23 = load i8*, i8** %2
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
store i8 %27, i8* %28
br label %30
30: ; preds = %22, %14
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %6
34: ; preds = %6
%35 = load i8*, i8** %3
store i8 0, i8* %35
ret void
}

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