#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);
int strlen(char *);
void str_shell_unescape(char *s) {
  int len = strlen(s);
  for (; *s; s++, len--)
    if (*s == '\\')
      memmove(s, s + 1, len);
}


x86 assembly (clang, -O0):
<str_shell_unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1188 <str_shell_unescape+0x68>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1169 <str_shell_unescape+0x49>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    -0xc(%rbp),%edx
call   1040 <memmove@plt>
jmp    116e <str_shell_unescape+0x4e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <str_shell_unescape+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_shell_unescape>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
jmp    1145 <str_shell_unescape+0x25>
nop
lea    0x1(%rbx),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <memmove@plt>
add    $0x1,%rbx
add    $0xffffffff,%ebp
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1130 <str_shell_unescape+0x10>
test   %al,%al
jne    113e <str_shell_unescape+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @str_shell_unescape(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
store i32 %5, i32* %3
br label %6
6: ; preds = %22, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 92
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i32, i32* %3
%20 = call i32 @memmove(i8* %16, i8* %18, i32 %19)
br label %21
21: ; preds = %15, %10
br label %22
22: ; preds = %21
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @str_shell_unescape(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
br label %3
3: ; preds = %10, %1
%4 = phi i8* [ %0, %1 ], [ %11, %10 ]
%5 = phi i32 [ %2, %1 ], [ %12, %10 ]
%6 = load i8, i8* %4
switch i8 %6, label %10 [
i8 0, label %13
i8 92, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = tail call i32 @memmove(i8* %4, i8* %8, i32 %5)
br label %10
10: ; preds = %3, %7
%11 = getelementptr inbounds i8, i8* %4, i64 1
%12 = add nsw i32 %5, -1
br label %3
13: ; preds = %3
ret void
}