#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);
void rm_whitespace(char *source) {
  char *i = source;
  char *j = source;
  while (*j != 0) {
    *i = *j++;
    if (!isspace(*i))
      i++;
  }
  *i = 0;
}


x86 assembly (clang, -O0):
<rm_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1179 <rm_whitespace+0x69>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    1174 <rm_whitespace+0x64>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <rm_whitespace+0x1c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rm_whitespace>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     114d <rm_whitespace+0x3d>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,(%r14)
movsbl %al,%edi
call   1030 <isspace@plt>
cmp    $0x1,%eax
adc    $0x0,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <rm_whitespace+0x20>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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