#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 */
void backsub(char **pb_ptr, char **sptr_ptr) {
  char *pb = *pb_ptr, *sptr = *sptr_ptr;
  if (sptr[1] == '\\') {
    if (sptr[2] == '\\' && sptr[3] == '&') {
      *pb++ = '\\';
      *pb++ = '&';
      sptr += 4;
    } else if (sptr[2] == '&') {
      *pb++ = '\\';
      sptr += 2;
    } else {
      *pb++ = *sptr++;
      *pb++ = *sptr++;
    }
  } else if (sptr[1] == '&') {
    sptr++;
    *pb++ = *sptr++;
  } else
    *pb++ = *sptr++;
  *pb_ptr = pb;
  *sptr_ptr = sptr;
}


x86 assembly (clang, -O0):
<backsub>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5c,%eax
jne    120c <backsub+0x10c>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x5c,%eax
jne    118a <backsub+0x8a>
mov    -0x20(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x26,%eax
jne    118a <backsub+0x8a>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x26,(%rax)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1207 <backsub+0x107>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x26,%eax
jne    11be <backsub+0xbe>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1202 <backsub+0x102>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1207 <backsub+0x107>
jmp    1277 <backsub+0x177>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x26,%eax
jne    1250 <backsub+0x150>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1272 <backsub+0x172>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1277 <backsub+0x177>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<backsub>:
mov    (%rdi),%rax
mov    (%rsi),%rcx
mov    0x1(%rcx),%dl
cmp    $0x26,%dl
je     113c <backsub+0x3c>
cmp    $0x5c,%dl
jne    1145 <backsub+0x45>
lea    0x2(%rcx),%r9
mov    0x2(%rcx),%r8b
cmp    $0x26,%r8b
je     116b <backsub+0x6b>
cmp    $0x5c,%r8b
jne    115b <backsub+0x5b>
cmpb   $0x26,0x3(%rcx)
jne    115b <backsub+0x5b>
movw   $0x265c,(%rax)
add    $0x2,%rax
add    $0x4,%rcx
jmp    1151 <backsub+0x51>
add    $0x2,%rcx
movb   $0x26,(%rax)
jmp    114d <backsub+0x4d>
mov    (%rcx),%dl
add    $0x1,%rcx
mov    %dl,(%rax)
add    $0x1,%rax
mov    %rcx,%r9
mov    %rax,(%rdi)
mov    %r9,(%rsi)
ret
mov    (%rcx),%dl
mov    %dl,(%rax)
mov    0x1(%rcx),%cl
mov    %cl,0x1(%rax)
add    $0x2,%rax
jmp    1154 <backsub+0x54>
movb   $0x5c,(%rax)
add    $0x1,%rax
jmp    1154 <backsub+0x54>

LLVM IR (-O0):
define void @backsub(i8** %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
store i8* %8, i8** %5
%9 = load i8**, i8*** %4
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 92
br i1 %15, label %16, label %59
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 92
br i1 %21, label %22, label %35
22: ; preds = %16
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 38
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %5
store i8 92, i8* %29
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
store i8 38, i8* %31
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 4
store i8* %34, i8** %6
br label %58
35: ; preds = %22, %16
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 38
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
store i8 92, i8* %42
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 2
store i8* %45, i8** %6
br label %57
46: ; preds = %35
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %6
%49 = load i8, i8* %47
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
store i8 %49, i8* %50
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %6
%54 = load i8, i8* %52
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
store i8 %54, i8* %55
br label %57
57: ; preds = %46, %41
br label %58
58: ; preds = %57, %28
br label %80
59: ; preds = %2
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 38
br i1 %64, label %65, label %73
65: ; preds = %59
%66 = load i8*, i8** %6
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %6
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %6
%70 = load i8, i8* %68
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %5
store i8 %70, i8* %71
br label %79
73: ; preds = %59
%74 = load i8*, i8** %6
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %6
%76 = load i8, i8* %74
%77 = load i8*, i8** %5
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %5
store i8 %76, i8* %77
br label %79
79: ; preds = %73, %65
br label %80
80: ; preds = %79, %58
%81 = load i8*, i8** %5
%82 = load i8**, i8*** %3
store i8* %81, i8** %82
%83 = load i8*, i8** %6
%84 = load i8**, i8*** %4
store i8* %83, i8** %84
ret void
}

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