#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 ShareChop(char *source) {
  int nLen;
  nLen = strlen(source);
  if (source[nLen - 1] == 10 || source[nLen - 1] == 13)
    source[nLen - 1] = 0;
  if (source[nLen - 2] == 10 || source[nLen - 2] == 13)
    source[nLen - 2] = 0;
}


x86 assembly (clang, -O0):
<ShareChop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     115c <ShareChop+0x4c>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    116d <ShareChop+0x5d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11a1 <ShareChop+0x91>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    11b2 <ShareChop+0xa2>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShareChop>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
mov    -0x1(%rax,%rbx,1),%cl
cmp    $0xd,%cl
je     1129 <ShareChop+0x19>
cmp    $0xa,%cl
jne    112e <ShareChop+0x1e>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    -0x2(%rax,%rbx,1),%cl
cmp    $0xd,%cl
je     113c <ShareChop+0x2c>
cmp    $0xa,%cl
jne    1141 <ShareChop+0x31>
movb   $0x0,-0x2(%rbx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @ShareChop(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
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sub nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %23, label %14
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 13
br i1 %22, label %23, label %29
23: ; preds = %14, %1
%24 = load i8*, i8** %2
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 0, i8* %28
br label %29
29: ; preds = %23, %14
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %47, label %38
38: ; preds = %29
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 13
br i1 %46, label %47, label %53
47: ; preds = %38, %29
%48 = load i8*, i8** %2
%49 = load i32, i32* %3
%50 = sub nsw i32 %49, 2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8 0, i8* %52
br label %53
53: ; preds = %47, %38
ret void
}

LLVM IR (-O2):
define void @ShareChop(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %8 [
i8 10, label %7
i8 13, label %7
]
7: ; preds = %1, %1
store i8 0, i8* %5
br label %8
8: ; preds = %1, %7
%9 = add nsw i32 %2, -2
%10 = sext i32 %9 to i64
%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
ret void
}