#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*/ strcpy(char *, char *);
unsigned int strlen(char *);
void strip(char *string) {
  unsigned i = 0;
  for (i = 0; i < strlen(string); i++) {
    if (string[i] == '\n' || string[i] == ' ') {
      strcpy(string + i, string + i + 1);
    }
  }
}


x86 assembly (clang, -O0):
<strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jae    11ae <strip+0x8e>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     117e <strip+0x5e>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119b <strip+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    %rax,%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
jmp    11a0 <strip+0x80>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <strip+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
je     116f <strip+0x4f>
lea    0x1(%r15),%r14
xor    %ebx,%ebx
jmp    1160 <strip+0x40>
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%rdi
lea    (%r14,%rbx,1),%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jae    116f <strip+0x4f>
movzbl (%r15,%rbx,1),%eax
cmp    $0x20,%al
je     1140 <strip+0x20>
cmp    $0xa,%al
je     1140 <strip+0x20>
jmp    114d <strip+0x2d>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @strip(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1, %11
%5 = phi i64 [ %12, %11 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %11 [
i8 10, label %8
i8 32, label %8
]
8: ; preds = %4, %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = tail call i32 @strcpy(i8* %6, i8* %9)
br label %11
11: ; preds = %4, %8
%12 = add nuw nsw i64 %5, 1
%13 = tail call i32 @strlen(i8* %0)
%14 = zext i32 %13 to i64
%15 = icmp ult i64 %12, %14
br i1 %15, label %4, label %16
16: ; preds = %11, %1
ret void
}