#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 strlen(char *);
char *removeCRLF(char *str) {
  int i;
  for (i = strlen(str); i > 0; i--)
    if ((str[i - 1] == '\n') || (str[i - 1] == '\r'))
      str[i - 1] = '\0';
  return str;
}


x86 assembly (clang, -O0):
<removeCRLF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    118a <removeCRLF+0x7a>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1166 <removeCRLF+0x56>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    1177 <removeCRLF+0x67>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    117c <removeCRLF+0x6c>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <removeCRLF+0x18>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeCRLF>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1140 <removeCRLF+0x30>
mov    %eax,%ecx
test   $0x1,%cl
je     113b <removeCRLF+0x2b>
add    $0xffffffffffffffff,%rcx
mov    %ecx,%esi
mov    (%rbx,%rsi,1),%dl
cmp    $0xd,%dl
je     1137 <removeCRLF+0x27>
cmp    $0xa,%dl
jne    113b <removeCRLF+0x2b>
movb   $0x0,(%rbx,%rsi,1)
cmp    $0x1,%eax
jne    1145 <removeCRLF+0x35>
mov    %rbx,%rax
pop    %rbx
ret
add    $0xfffffffffffffffe,%rcx
jmp    1165 <removeCRLF+0x55>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx,%rax,1)
lea    -0x2(%rcx),%rax
add    $0x1,%rcx
cmp    $0x1,%rcx
mov    %rax,%rcx
jbe    1140 <removeCRLF+0x30>
lea    0x1(%rcx),%eax
movzbl (%rbx,%rax,1),%edx
cmp    $0xd,%dl
je     1176 <removeCRLF+0x66>
cmp    $0xa,%dl
jne    117a <removeCRLF+0x6a>
movb   $0x0,(%rbx,%rax,1)
mov    %ecx,%eax
movzbl (%rbx,%rax,1),%edx
cmp    $0xd,%dl
je     1150 <removeCRLF+0x40>
cmp    $0xa,%dl
je     1150 <removeCRLF+0x40>
jmp    1154 <removeCRLF+0x44>

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

LLVM IR (-O2):
define i8* @removeCRLF(i8* returned %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %32
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = and i64 %5, 1
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %4
%9 = add nsw i64 %5, -1
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %14 [
i8 10, label %13
i8 13, label %13
]
13: ; preds = %8, %8
store i8 0, i8* %11
br label %14
14: ; preds = %8, %13, %4
%15 = phi i64 [ %5, %4 ], [ %9, %13 ], [ %9, %8 ]
%16 = icmp eq i32 %2, 1
br i1 %16, label %32, label %17
17: ; preds = %14, %30
%18 = phi i64 [ %25, %30 ], [ %15, %14 ]
%19 = add nsw i64 %18, -1
%20 = and i64 %19, 4294967295
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
switch i8 %22, label %24 [
i8 10, label %23
i8 13, label %23
]
23: ; preds = %17, %17
store i8 0, i8* %21
br label %24
24: ; preds = %17, %23
%25 = add nsw i64 %18, -2
%26 = and i64 %25, 4294967295
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
switch i8 %28, label %30 [
i8 10, label %29
i8 13, label %29
]
29: ; preds = %24, %24
store i8 0, i8* %27
br label %30
30: ; preds = %29, %24
%31 = icmp ugt i64 %19, 1
br i1 %31, label %17, label %32
32: ; preds = %14, %30, %1
ret i8* %0
}