#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*/ memmove(char *, char *, scalar_t__);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strspn(char *, char *);
char *strstr(char *, char *);
char *kill_line_ending_backslash(char *str) {
  if (!str)
    return 0;
  char *p = str;
  while (0 != (p = strstr(p, "\\\n"))) {
    char *q = (p + 1);
    q += strspn(q, " \t\r\n");
    memmove(p, q, strlen(q) + 1);
  }
  p = str;
  while (0 != (p = strstr(p, "\\\r\n"))) {
    char *q = (p + 1);
    q += strspn(q, " \t\r\n");
    memmove(p, q, strlen(q) + 1);
  }
  return str;
}


x86 assembly (clang, -O0):
<kill_line_ending_backslash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <kill_line_ending_backslash+0x24>
movq   $0x0,-0x8(%rbp)
jmp    127c <kill_line_ending_backslash+0x13c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     11ec <kill_line_ending_backslash+0xac>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
jmp    116c <kill_line_ending_backslash+0x2c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1274 <kill_line_ending_backslash+0x134>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
jmp    11f4 <kill_line_ending_backslash+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kill_line_ending_backslash>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1230 <kill_line_ending_backslash+0xf0>
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11c0 <kill_line_ending_backslash+0x80>
mov    %rax,%rbx
lea    0xe90(%rip),%r15
lea    0xe86(%rip),%r12
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rdi
mov    %r15,%rsi
call   1040 <strspn@plt>
cltq
lea    (%rbx,%rax,1),%r13
add    $0x1,%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <memmove@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <kill_line_ending_backslash+0x40>
lea    0xe41(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1230 <kill_line_ending_backslash+0xf0>
mov    %rax,%rbx
lea    0xe25(%rip),%r15
lea    0xe23(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%rdi
mov    %r15,%rsi
call   1040 <strspn@plt>
cltq
lea    (%rbx,%rax,1),%r13
add    $0x1,%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <memmove@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11f0 <kill_line_ending_backslash+0xb0>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\\\0A\00"
@.str.1 = [5 x i8] c" \09\0D\0A\00"
@.str.2 = [4 x i8] c"\\\0D\0A\00"
define i8* @kill_line_ending_backslash(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %52
10: ; preds = %1
%11 = load i8*, i8** %3
store i8* %11, i8** %4
br label %12
12: ; preds = %16, %10
%13 = load i8*, i8** %4
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %4
%15 = icmp ne i8* null, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 @strspn(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = load i8*, i8** %5
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %5
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = load i8*, i8** %5
%27 = call i64 @strlen(i8* %26)
%28 = add nsw i64 %27, 1
%29 = call i32 @memmove(i8* %24, i8* %25, i64 %28)
br label %12
30: ; preds = %12
%31 = load i8*, i8** %3
store i8* %31, i8** %4
br label %32
32: ; preds = %36, %30
%33 = load i8*, i8** %4
%34 = call i8* @strstr(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %34, i8** %4
%35 = icmp ne i8* null, %34
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8* %38, i8** %6
%39 = load i8*, i8** %6
%40 = call i32 @strspn(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%41 = load i8*, i8** %6
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %6
%44 = load i8*, i8** %4
%45 = load i8*, i8** %6
%46 = load i8*, i8** %6
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 1
%49 = call i32 @memmove(i8* %44, i8* %45, i64 %48)
br label %32
50: ; preds = %32
%51 = load i8*, i8** %3
store i8* %51, i8** %2
br label %52
52: ; preds = %50, %9
%53 = load i8*, i8** %2
ret i8* %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\\0A\00"
@.str.1 = [5 x i8] c" \09\0D\0A\00"
@.str.2 = [4 x i8] c"\\\0D\0A\00"
define i8* @kill_line_ending_backslash(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = tail call i8* @strstr(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %9, %3
%7 = tail call i8* @strstr(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %31, label %20
9: ; preds = %3, %9
%10 = phi i8* [ %18, %9 ], [ %4, %3 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = tail call i32 @strspn(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = tail call i64 @strlen(i8* %14)
%16 = add nsw i64 %15, 1
%17 = tail call i32 @memmove(i8* %10, i8* %14, i64 %16)
%18 = tail call i8* @strstr(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %6, label %9
20: ; preds = %6, %20
%21 = phi i8* [ %29, %20 ], [ %7, %6 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = tail call i32 @strspn(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = tail call i64 @strlen(i8* %25)
%27 = add nsw i64 %26, 1
%28 = tail call i32 @memmove(i8* %21, i8* %25, i64 %27)
%29 = tail call i8* @strstr(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %20
31: ; preds = %20, %6, %1
ret i8* %0
}