#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(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *_arrange(char *s) {
  char *r = malloc(strlen(s) + 1);
  char *p;
  strcpy(r, s);
  for (p = r; *p != '\0'; p++)
    if (*p == '\t' || *p == '\n')
      *p = ' ';
  return r;
}


x86 assembly (clang, -O0):
<_arrange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b7 <_arrange+0x87>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     119a <_arrange+0x6a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a1 <_arrange+0x71>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
jmp    11a6 <_arrange+0x76>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116a <_arrange+0x3a>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_arrange>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
jmp    1167 <_arrange+0x37>
nopl   0x0(%rax,%rax,1)
movb   $0x20,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
lea    -0x9(%rcx),%edx
cmp    $0x2,%dl
jb     1160 <_arrange+0x30>
test   %cl,%cl
jne    1163 <_arrange+0x33>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @_arrange(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i8* @malloc(i64 %3)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
br label %6
6: ; preds = %10, %1
%7 = phi i8* [ %4, %1 ], [ %11, %10 ]
%8 = load i8, i8* %7
switch i8 %8, label %10 [
i8 0, label %12
i8 9, label %9
i8 10, label %9
]
9: ; preds = %6, %6
store i8 32, i8* %7
br label %10
10: ; preds = %6, %9
%11 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
12: ; preds = %6
ret i8* %4
}