#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 /*<<< orphan*/ pst_debug(int, char *, char *);
int /*<<< orphan*/ pst_debug_func(char *);
int /*<<< orphan*/ pst_debug_func_ret();
void removeCR(char *c) {
  char *a, *b;
  {
    pst_debug_func("removeCR");
    pst_debug(709,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/"
              "src/readpst.c",
              "Entering function\n");
  };
  a = b = c;
  while (*a != '\0') {
    *b = *a;
    if (*a != '\r')
      b++;
    a++;
  }
  *b = '\0';
  {
    pst_debug(717,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/"
              "src/readpst.c",
              "Leaving function\n");
    pst_debug_func_ret();
  };
}


x86 assembly (clang, -O0):
<removeCR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1040 <pst_debug_func@plt>
mov    $0x2c5,%edi
lea    0xeb5(%rip),%rsi
lea    0xf3a(%rip),%rdx
call   1030 <pst_debug@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b5 <removeCR+0x85>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     11a4 <removeCR+0x74>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116c <removeCR+0x3c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    $0x2cd,%edi
lea    0xe41(%rip),%rsi
lea    0xed9(%rip),%rdx
call   1030 <pst_debug@plt>
mov    $0x0,%al
call   1050 <pst_debug_func_ret@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeCR>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1040 <pst_debug_func@plt>
lea    0xec2(%rip),%rsi
lea    0xf47(%rip),%rdx
mov    $0x2c5,%edi
call   1030 <pst_debug@plt>
mov    (%rbx),%al
test   %al,%al
je     1189 <removeCR+0x59>
lea    0x1(%rbx),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,(%rbx)
movzbl (%rcx),%eax
xor    %edx,%edx
cmpb   $0xd,-0x1(%rcx)
setne  %dl
add    %rdx,%rbx
add    $0x1,%rcx
test   %al,%al
jne    1170 <removeCR+0x40>
movb   $0x0,(%rbx)
lea    0xe76(%rip),%rsi
lea    0xf0e(%rip),%rdx
mov    $0x2cd,%edi
call   1030 <pst_debug@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <pst_debug_func_ret@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"removeCR\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/src/readpst.c\00"
@.str.2 = [19 x i8] c"Entering function\0A\00"
@.str.3 = [18 x i8] c"Leaving function\0A\00"
define void @removeCR(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 @pst_debug_func(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @pst_debug(i32 709, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%7 = load i8*, i8** %2
store i8* %7, i8** %4
store i8* %7, i8** %3
br label %8
8: ; preds = %24, %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = load i8*, i8** %4
store i8 %15, i8* %16
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 13
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
br label %24
24: ; preds = %21, %13
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %8
27: ; preds = %8
%28 = load i8*, i8** %4
store i8 0, i8* %28
%29 = call i32 @pst_debug(i32 717, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (...) @pst_debug_func_ret()
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"removeCR\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/libpst/refs/heads/master/src/readpst.c\00"
@.str.2 = [19 x i8] c"Entering function\0A\00"
@.str.3 = [18 x i8] c"Leaving function\0A\00"
define void @removeCR(i8* nocapture %0) {
%2 = tail call i32 @pst_debug_func(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @pst_debug(i32 709, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %15, %6 ], [ %4, %1 ]
%8 = phi i8* [ %13, %6 ], [ %0, %1 ]
%9 = phi i8* [ %14, %6 ], [ %0, %1 ]
store i8 %7, i8* %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 13
%12 = zext i1 %11 to i64
%13 = getelementptr i8, i8* %8, i64 %12
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %6, %1
%18 = phi i8* [ %0, %1 ], [ %13, %6 ]
store i8 0, i8* %18
%19 = tail call i32 @pst_debug(i32 717, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (...) @pst_debug_func_ret()
ret void
}