#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 CutOffExtraChars(char *ThisLine) {
  if (ThisLine[strlen(ThisLine) - 2] == '\r')
    ThisLine[strlen(ThisLine) - 2] = '\0';
  else if (ThisLine[strlen(ThisLine) - 1] == '\n')
    ThisLine[strlen(ThisLine) - 1] = '\0';
}


x86 assembly (clang, -O0):
<CutOffExtraChars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    116c <CutOffExtraChars+0x5c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11bc <CutOffExtraChars+0xac>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11b7 <CutOffExtraChars+0xa7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11bc <CutOffExtraChars+0xac>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CutOffExtraChars>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
mov    -0x2(%rax,%rbx,1),%bpl
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xd,%bpl
jne    1135 <CutOffExtraChars+0x25>
add    $0xfffffffe,%eax
jmp    1149 <CutOffExtraChars+0x39>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    114f <CutOffExtraChars+0x3f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
movb   $0x0,(%rbx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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