#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 *);
char *discard_escape_char(char *input) {
  static char ca_dest[100];
  int i;
  int j = 0;
  for (i = 0; i < strlen(input); i++) {
    if ((input[i] != '\\') || ((i > 0) && (input[i - 1] == '\\'))) {
      ca_dest[j++] = input[i];
    }
  }
  ca_dest[j++] = '\0';
  return ca_dest;
}


x86 assembly (clang, -O0):
<discard_escape_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11b5 <discard_escape_char+0xa5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    117f <discard_escape_char+0x6f>
cmpl   $0x0,-0xc(%rbp)
jle    11a2 <discard_escape_char+0x92>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11a2 <discard_escape_char+0x92>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2ea1(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    11a7 <discard_escape_char+0x97>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <discard_escape_char+0x1a>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2e76(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e6b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<discard_escape_char>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    118f <discard_escape_char+0x7f>
mov    (%rbx),%al
xor    %r14d,%r14d
cmp    $0x5c,%al
je     1138 <discard_escape_char+0x28>
mov    %al,0x2f0e(%rip)
mov    $0x1,%r14d
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1192 <discard_escape_char+0x82>
mov    $0x1,%ebp
lea    0x2eef(%rip),%r15
jmp    117e <discard_escape_char+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %r14d,%rcx
add    $0x1,%r14d
mov    %al,(%rcx,%r15,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1192 <discard_escape_char+0x82>
movzbl (%rbx,%rbp,1),%eax
cmp    $0x5c,%al
jne    1160 <discard_escape_char+0x50>
cmpb   $0x5c,-0x1(%rbx,%rbp,1)
je     1160 <discard_escape_char+0x50>
jmp    116b <discard_escape_char+0x5b>
xor    %r14d,%r14d
movslq %r14d,%rcx
lea    0x2ea4(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@discard_escape_char.ca_dest = internal global [100 x i8] zeroinitializer
define i8* @discard_escape_char(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %41, %1
%6 = load i32, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %44
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 92
br i1 %17, label %30, label %18
18: ; preds = %10
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %18
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 92
br i1 %29, label %30, label %40
30: ; preds = %21, %10
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 %38
store i8 %35, i8* %39
br label %40
40: ; preds = %30, %21, %18
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %5
44: ; preds = %5
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds [100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 %47
store i8 0, i8* %48
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 0)
}

LLVM IR (-O2):
@discard_escape_char.ca_dest = internal global [100 x i8] zeroinitializer
define i8* @discard_escape_char(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %34
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 92
br i1 %6, label %8, label %7
7: ; preds = %4
store i8 %5, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 0)
br label %8
8: ; preds = %4, %7
%9 = phi i32 [ 1, %7 ], [ 0, %4 ]
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %34
12: ; preds = %8, %28
%13 = phi i64 [ %30, %28 ], [ 1, %8 ]
%14 = phi i32 [ %29, %28 ], [ %9, %8 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 92
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = add nuw i64 %13, 4294967295
%20 = and i64 %19, 4294967295
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 92
br i1 %23, label %24, label %28
24: ; preds = %18, %12
%25 = add nsw i32 %14, 1
%26 = sext i32 %14 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 %26
store i8 %16, i8* %27
br label %28
28: ; preds = %18, %24
%29 = phi i32 [ %25, %24 ], [ %14, %18 ]
%30 = add nuw nsw i64 %13, 1
%31 = tail call i32 @strlen(i8* %0)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %12, label %34
34: ; preds = %28, %8, %1
%35 = phi i32 [ 0, %1 ], [ %9, %8 ], [ %29, %28 ]
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 %36
store i8 0, i8* %37
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @discard_escape_char.ca_dest, i64 0, i64 0)
}