#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 *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strDelNL(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int strStrip(char *strip_it) {
  char *x_buf, *y_buf;
  int i = 0;
  x_buf = malloc(strlen(strip_it));
  y_buf = malloc(strlen(strip_it));
  memset(x_buf, 0, strlen(strip_it));
  strcpy(y_buf, strip_it);
  while (*y_buf != '\0') {
    if (*y_buf == ' ') {
      *y_buf++;
      continue;
    }
    x_buf[i++] = *y_buf++;
  }
  x_buf[i] = '\0';
  strcpy(strip_it, x_buf);
  strDelNL(strip_it);
  return 1;
}


x86 assembly (clang, -O0):
<strStrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1212 <strStrip+0xc2>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11e7 <strStrip+0x97>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b6 <strStrip+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11b6 <strStrip+0x66>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1070 <strDelNL@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strStrip>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %r12d,%r12d
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
xchg   %ax,%ax
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
cmp    $0x20,%al
je     11a0 <strStrip+0x50>
test   %al,%al
je     11ba <strStrip+0x6a>
mov    %al,(%r14,%r12,1)
add    $0x1,%r12
jmp    11a0 <strStrip+0x50>
mov    %r12d,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1070 <strDelNL@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @strStrip(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
%7 = call i32 @strlen(i8* %6)
%8 = call i8* @malloc(i32 %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %3
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @memset(i8* %12, i32 0, i32 %14)
%16 = load i8*, i8** %4
%17 = load i8*, i8** %2
%18 = call i32 @strcpy(i8* %16, i8* %17)
br label %19
19: ; preds = %33, %29, %1
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %42
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
%32 = load i8, i8* %30
br label %19
33: ; preds = %24
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
%36 = load i8, i8* %34
%37 = load i8*, i8** %3
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 %36, i8* %41
br label %19
42: ; preds = %19
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 0, i8* %46
%47 = load i8*, i8** %2
%48 = load i8*, i8** %3
%49 = call i32 @strcpy(i8* %47, i8* %48)
%50 = load i8*, i8** %2
%51 = call i32 @strDelNL(i8* %50)
ret i32 1
}

LLVM IR (-O2):
define i32 @strStrip(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i8* @malloc(i32 %2)
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @memset(i8* %3, i32 0, i32 %6)
%8 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %9
9: ; preds = %17, %1
%10 = phi i64 [ %19, %17 ], [ 0, %1 ]
%11 = phi i8* [ %18, %17 ], [ %5, %1 ]
br label %12
12: ; preds = %9, %15
%13 = phi i8* [ %16, %15 ], [ %11, %9 ]
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 0, label %21
i8 32, label %15
]
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = add nuw i64 %10, 1
%20 = getelementptr inbounds i8, i8* %3, i64 %10
store i8 %14, i8* %20
br label %9
21: ; preds = %12
%22 = and i64 %10, 4294967295
%23 = getelementptr inbounds i8, i8* %3, i64 %22
store i8 0, i8* %23
%24 = tail call i32 @strcpy(i8* %0, i8* %3)
%25 = tail call i32 @strDelNL(i8* %0)
ret i32 1
}