#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 */
size_t strlen(char *);
char *nojunk(char *linrec) {
  char *a;
  a = &(linrec[strlen(linrec)]);
  while (a > linrec)
    if (*(a - 1) == '\\n' || *(a - 1) == '\\r' || *(a - 1) == ' ')
      *(--a) = '\\0';
    else
      break;
  return linrec;
}


x86 assembly (clang, -O0):
<nojunk>:
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    %rax,%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    11a2 <nojunk+0x92>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c6e,%eax
je     1180 <nojunk+0x70>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c72,%eax
je     1180 <nojunk+0x70>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    1198 <nojunk+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x30,-0x1(%rax)
jmp    119d <nojunk+0x8d>
jmp    11a2 <nojunk+0x92>
jmp    113b <nojunk+0x2b>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nojunk>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rax,%rax
jle    1143 <nojunk+0x33>
add    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,-0x1(%rax)
jne    1143 <nojunk+0x33>
movb   $0x30,-0x1(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
ja     1130 <nojunk+0x20>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @nojunk(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 i64 @strlen(i8* %5)
%7 = getelementptr inbounds i8, i8* %4, i64 %6
store i8* %7, i8** %3
br label %8
8: ; preds = %34, %1
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = icmp ugt i8* %9, %10
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 -1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 23662
br i1 %17, label %30, label %18
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 23666
br i1 %23, label %30, label %24
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 -1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 32
br i1 %29, label %30, label %33
30: ; preds = %24, %18, %12
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %3
store i8 48, i8* %32
br label %34
33: ; preds = %24
br label %35
34: ; preds = %30
br label %8
35: ; preds = %33, %8
%36 = load i8*, i8** %2
ret i8* %36
}

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