#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 */
unsigned int _purify_newline(char const *, char *, unsigned int *);
unsigned int _purify_backslash(const char *input, char *out,
                               unsigned int *current_line) {
  unsigned int eaten = 0;
  for (;;) {
    if (input[0] == '\\') {
      char next;
      unsigned int next_eaten;
      unsigned int next_line = *current_line;
      eaten++;
      input++;
      next_eaten = _purify_newline(input, &next, &next_line);
      if (next == '\n') {
        eaten += next_eaten;
        input += next_eaten;
        *current_line = next_line;
      } else {
        *out = '\\';
        break;
      }
    } else {
      eaten += _purify_newline(input, out, current_line);
      break;
    }
  }
  return eaten;
}


x86 assembly (clang, -O0):
<_purify_backslash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11b2 <_purify_backslash+0xa2>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <_purify_newline@plt>
mov    %eax,-0x24(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
jne    11a1 <_purify_backslash+0x91>
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ad <_purify_backslash+0x9d>
mov    -0x10(%rbp),%rax
movb   $0x5c,(%rax)
jmp    11d3 <_purify_backslash+0xc3>
jmp    11ce <_purify_backslash+0xbe>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <_purify_newline@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11d3 <_purify_backslash+0xc3>
jmp    112b <_purify_backslash+0x1b>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_purify_backslash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %ebp,%ebp
cmpb   $0x5c,(%rdi)
jne    117a <_purify_backslash+0x6a>
mov    (%r14),%eax
xor    %ebp,%ebp
lea    0x3(%rsp),%r12
lea    0x4(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %eax,0x4(%rsp)
add    $0x1,%ebp
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <_purify_newline@plt>
cmpb   $0xa,0x3(%rsp)
jne    118c <_purify_backslash+0x7c>
add    %eax,%ebp
mov    %eax,%ecx
lea    (%rbx,%rcx,1),%rdi
mov    0x4(%rsp),%eax
mov    %eax,(%r14)
cmpb   $0x5c,(%rbx,%rcx,1)
mov    %rdi,%rbx
je     1140 <_purify_backslash+0x30>
jmp    117d <_purify_backslash+0x6d>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <_purify_newline@plt>
add    %eax,%ebp
jmp    1190 <_purify_backslash+0x80>
movb   $0x5c,(%r15)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_purify_backslash(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %11
11: ; preds = %49, %3
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %42
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
store i32 %19, i32* %10
%20 = load i32, i32* %7
%21 = add i32 %20, 1
store i32 %21, i32* %7
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = call i32 @_purify_newline(i8* %24, i8* %8, i32* %10)
store i32 %25, i32* %9
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %39
29: ; preds = %17
%30 = load i32, i32* %9
%31 = load i32, i32* %7
%32 = add i32 %31, %30
store i32 %32, i32* %7
%33 = load i32, i32* %9
%34 = load i8*, i8** %4
%35 = zext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %4
%37 = load i32, i32* %10
%38 = load i32*, i32** %6
store i32 %37, i32* %38
br label %41
39: ; preds = %17
%40 = load i8*, i8** %5
store i8 92, i8* %40
br label %50
41: ; preds = %29
br label %49
42: ; preds = %11
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = load i32*, i32** %6
%46 = call i32 @_purify_newline(i8* %43, i8* %44, i32* %45)
%47 = load i32, i32* %7
%48 = add i32 %47, %46
store i32 %48, i32* %7
br label %50
49: ; preds = %41
br label %11
50: ; preds = %42, %39
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
define i32 @_purify_backslash(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8
%5 = alloca i32
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 92
br i1 %7, label %8, label %28
8: ; preds = %3
%9 = bitcast i32* %5 to i8*
%10 = load i32, i32* %2
br label %11
11: ; preds = %8, %21
%12 = phi i32 [ %10, %8 ], [ %25, %21 ]
%13 = phi i8* [ %0, %8 ], [ %24, %21 ]
%14 = phi i32 [ 0, %8 ], [ %22, %21 ]
store i32 %12, i32* %5
%15 = add i32 %14, 1
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = call i32 @_purify_newline(i8* %16, i8* %4, i32* %5)
%18 = load i8, i8* %4
%19 = icmp eq i8 %18, 10
br i1 %19, label %21, label %20
20: ; preds = %11
store i8 92, i8* %1
br label %33
21: ; preds = %11
%22 = add i32 %17, %15
%23 = zext i32 %17 to i64
%24 = getelementptr inbounds i8, i8* %16, i64 %23
%25 = load i32, i32* %5
store i32 %25, i32* %2
%26 = load i8, i8* %24
%27 = icmp eq i8 %26, 92
br i1 %27, label %11, label %28
28: ; preds = %21, %3
%29 = phi i32 [ 0, %3 ], [ %22, %21 ]
%30 = phi i8* [ %0, %3 ], [ %24, %21 ]
%31 = call i32 @_purify_newline(i8* %30, i8* %1, i32* %2)
%32 = add i32 %31, %29
br label %33
33: ; preds = %20, %28
%34 = phi i32 [ %32, %28 ], [ %15, %20 ]
ret i32 %34
}