#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 *);
void remove_eol(char *str) {
  int i;
  if (str == 0)
    return;
  if (strlen(str) > 0) {
    for (i = 1; i <= strlen(str); i++) {
      if ((str[i] == 10) || (str[i] == 13)) {
        str[i] = 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<remove_eol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <remove_eol+0x1c>
jmp    11af <remove_eol+0x9f>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jle    11af <remove_eol+0x9f>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11aa <remove_eol+0x9a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     118b <remove_eol+0x7b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    1197 <remove_eol+0x87>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    119c <remove_eol+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <remove_eol+0x35>
jmp    11af <remove_eol+0x9f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_eol>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1169 <remove_eol+0x59>
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1169 <remove_eol+0x59>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1169 <remove_eol+0x59>
xor    %ebx,%ebx
jmp    1159 <remove_eol+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x0,0x1(%r14,%rbx,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jge    1169 <remove_eol+0x59>
movzbl 0x1(%r14,%rbx,1),%eax
cmp    $0xd,%al
je     1140 <remove_eol+0x30>
cmp    $0xa,%al
je     1140 <remove_eol+0x30>
jmp    1146 <remove_eol+0x36>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @remove_eol(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
br label %43
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %43
11: ; preds = %7
store i32 1, i32* %3
br label %12
12: ; preds = %39, %11
%13 = load i32, i32* %3
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %42
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = sext 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, 10
br i1 %24, label %33, label %25
25: ; preds = %17
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 13
br i1 %32, label %33, label %38
33: ; preds = %25, %17
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %33, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %12
42: ; preds = %12
br label %43
43: ; preds = %6, %42, %7
ret void
}

LLVM IR (-O2):
define void @remove_eol(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp slt i32 %7, 1
br i1 %8, label %19, label %9
9: ; preds = %6, %14
%10 = phi i64 [ %15, %14 ], [ 1, %6 ]
%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 = %9, %9
store i8 0, i8* %11
br label %14
14: ; preds = %9, %13
%15 = add nuw nsw i64 %10, 1
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %10, %17
br i1 %18, label %9, label %19
19: ; preds = %14, %6, %3, %1
ret void
}