#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 */
scalar_t__ isspace(char);
void cleanString(char *strIn) {
  char *in;
  char *out;
  int where = 0;
  in = (char *)strIn;
  out = (char *)strIn;
  while (*in) {
    if (isspace(*in)) {
      switch (where) {
      case 0:
      case 2:
        break;
      case 1:
        *out = ' ';
        out++;
        where = 2;
        break;
      }
    } else {
      where = 1;
      *out = *in;
      out++;
    }
    in++;
  }
  *out = 0;
}


x86 assembly (clang, -O0):
<cleanString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11df <cleanString+0xcf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11af <cleanString+0x9f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     118b <cleanString+0x7b>
jmp    1169 <cleanString+0x59>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     1190 <cleanString+0x80>
jmp    117a <cleanString+0x6a>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
jne    11aa <cleanString+0x9a>
jmp    118b <cleanString+0x7b>
jmp    11aa <cleanString+0x9a>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
jmp    11ce <cleanString+0xbe>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <cleanString+0x23>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanString>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1166 <cleanString+0x56>
lea    0x1(%r14),%rbx
xor    %ebp,%ebp
jmp    114b <cleanString+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%rbx),%eax
mov    $0x1,%ebp
mov    %al,(%r14)
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1166 <cleanString+0x56>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     1130 <cleanString+0x20>
cmp    $0x1,%ebp
jne    1140 <cleanString+0x30>
mov    $0x2,%ebp
mov    $0x20,%al
jmp    1139 <cleanString+0x29>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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