#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 *, int);
char *strchr(char *, char);
int strlen(char *);
char *xstrdup(char *);
char *process_str(char *rawstr) {
  char *str = xstrdup(rawstr + 1);
  char *eq;
  char *p = str;
  while ((eq = strchr(p, '\\')) != NULL) {
    *eq = *(eq + 1);
    memmove(eq + 1, eq + 2, strlen(eq) + 1);
    p = eq + 1;
  }
  str[strlen(str) - 1] = '\0';
  return str;
}


x86 assembly (clang, -O0):
<process_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
call   1050 <xstrdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11d2 <process_str+0x92>
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1060 <memmove@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1165 <process_str+0x25>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_str>:
push   %r15
push   %r14
push   %rbx
add    $0x1,%rdi
call   1050 <xstrdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1198 <process_str+0x58>
lea    0x1(%rax),%rbx
movzbl 0x1(%rax),%ecx
mov    %cl,(%rax)
lea    0x2(%rax),%r15
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <memmove@plt>
mov    %rbx,%rdi
jmp    1160 <process_str+0x20>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @process_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = call i8* @xstrdup(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
store i8* %9, i8** %5
br label %10
10: ; preds = %14, %1
%11 = load i8*, i8** %5
%12 = call i8* @strchr(i8* %11, i8 signext 92)
store i8* %12, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = load i8*, i8** %4
store i8 %17, i8* %18
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %24, 1
%26 = call i32 @memmove(i8* %20, i8* %22, i32 %25)
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %5
br label %10
29: ; preds = %10
%30 = load i8*, i8** %3
%31 = load i8*, i8** %3
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 0, i8* %35
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @process_str(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = tail call i8* @xstrdup(i8* %2)
%4 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 92)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %1, %6
%7 = phi i8* [ %14, %6 ], [ %4, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
store i8 %9, i8* %7
%10 = getelementptr inbounds i8, i8* %7, i64 2
%11 = tail call i32 @strlen(i8* %7)
%12 = add nsw i32 %11, 1
%13 = tail call i32 @memmove(i8* %8, i8* %10, i32 %12)
%14 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 92)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %6
16: ; preds = %6, %1
%17 = tail call i32 @strlen(i8* %3)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %3, i64 %19
store i8 0, i8* %20
ret i8* %3
}