#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*/ strncpy(char *, char const *, int);
char *RemoveCR(const char *txt) {
  static char Buffer[2048];
  char *pt;
  strncpy(Buffer, txt, 2047);
  Buffer[2047] = 0;
  for (pt = Buffer; *pt; pt++)
    if (*pt == '\n' || *pt == '\r')
      *pt = ' ';
  return Buffer;
}


x86 assembly (clang, -O0):
<RemoveCR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f19(%rip),%rdi
mov    $0x7ff,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3707(%rip)
lea    0x2f01(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     118d <RemoveCR+0x7d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1170 <RemoveCR+0x60>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1177 <RemoveCR+0x67>
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
jmp    117c <RemoveCR+0x6c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1143 <RemoveCR+0x33>
lea    0x2eac(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RemoveCR>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f25(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7ff,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3710(%rip)
jmp    1147 <RemoveCR+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x20,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1140 <RemoveCR+0x30>
cmp    $0xd,%al
je     1140 <RemoveCR+0x30>
test   %al,%al
jne    1143 <RemoveCR+0x33>
lea    0x2ee3(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@RemoveCR.Buffer = internal global [2048 x i8] zeroinitializer
define i8* @RemoveCR(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strncpy(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0), i8* %4, i32 2047)
store i8 0, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 2047)
store i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0), i8** %3
br label %6
6: ; preds = %23, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 10
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %22
20: ; preds = %15, %10
%21 = load i8*, i8** %3
store i8 32, i8* %21
br label %22
22: ; preds = %20, %15
br label %23
23: ; preds = %22
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
br label %6
26: ; preds = %6
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@RemoveCR.Buffer = internal global [2048 x i8] zeroinitializer
define i8* @RemoveCR(i8* %0) {
%2 = tail call i32 @strncpy(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0), i8* %0, i32 2047)
store i8 0, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 2047)
br label %3
3: ; preds = %7, %1
%4 = phi i8* [ getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0), %1 ], [ %8, %7 ]
%5 = load i8, i8* %4
switch i8 %5, label %7 [
i8 0, label %9
i8 10, label %6
i8 13, label %6
]
6: ; preds = %3, %3
store i8 32, i8* %4
br label %7
7: ; preds = %3, %6
%8 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
9: ; preds = %3
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @RemoveCR.Buffer, i64 0, i64 0)
}