#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 strip_line(char *line) {
  char *p = line + strlen(line);
  while (p > line && (p[-1] == '\n' || p[-1] == '\r'))
    *p-- = 0;
}


x86 assembly (clang, -O0):
<strip_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    117d <strip_line+0x6d>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     1177 <strip_line+0x67>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118d <strip_line+0x7d>
jmp    11a4 <strip_line+0x94>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
jmp    113d <strip_line+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_line>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    114a <strip_line+0x3a>
mov    %eax,%eax
add    %rbx,%rax
jmp    113c <strip_line+0x2c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jbe    114a <strip_line+0x3a>
movzbl -0x1(%rax),%ecx
cmp    $0xd,%cl
je     1130 <strip_line+0x20>
cmp    $0xa,%cl
je     1130 <strip_line+0x20>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @strip_line(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %4, %11
%8 = phi i8* [ %9, %11 ], [ %6, %4 ]
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = load i8, i8* %9
switch i8 %10, label %13 [
i8 10, label %11
i8 13, label %11
]
11: ; preds = %7, %7
store i8 0, i8* %8
%12 = icmp ugt i8* %9, %0
br i1 %12, label %7, label %13
13: ; preds = %11, %7, %1
ret void
}