#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 *strchr(char *, char);
void remove_newlines(char *s) {
  char *p;
  if (!s || !*s)
    return;
  for (p = s; p;)
    if ((p = strchr(p, '\n')))
      *p++ = ' ';
  for (p = s; p;)
    if ((p = strchr(p, '\r')))
      *p++ = ' ';
}


x86 assembly (clang, -O0):
<remove_newlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1134 <remove_newlines+0x24>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1139 <remove_newlines+0x29>
jmp    11c5 <remove_newlines+0xb5>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117f <remove_newlines+0x6f>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     117a <remove_newlines+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
jmp    1141 <remove_newlines+0x31>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c5 <remove_newlines+0xb5>
mov    -0x10(%rbp),%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11c0 <remove_newlines+0xb0>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
jmp    1187 <remove_newlines+0x77>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_newlines>:
push   %rbx
test   %rdi,%rdi
je     116b <remove_newlines+0x5b>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116b <remove_newlines+0x5b>
mov    %rbx,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     114b <remove_newlines+0x3b>
movb   $0x20,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
jmp    1130 <remove_newlines+0x20>
mov    %rbx,%rdi
xchg   %ax,%ax
mov    $0xd,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116b <remove_newlines+0x5b>
movb   $0x20,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
jmp    1150 <remove_newlines+0x40>
pop    %rbx
ret

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

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