#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*/ strcpy(char *, char *);
void fix_any_dollar_signs(char *d) {
  static char tmp[65535 + 1];
  char *tmp_ptr = tmp;
  strcpy(tmp, d);
  while (*tmp_ptr) {
    if (*tmp_ptr == '$') {
      *d++ = '\\';
      *d++ = *tmp_ptr++;
    } else
      *d++ = *tmp_ptr++;
  }
  *d = '\0';
}


x86 assembly (clang, -O0):
<fix_any_dollar_signs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f0e(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b4 <fix_any_dollar_signs+0xa4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    118d <fix_any_dollar_signs+0x7d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    11af <fix_any_dollar_signs+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1137 <fix_any_dollar_signs+0x27>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_any_dollar_signs>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x2f22(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    1143 <fix_any_dollar_signs+0x33>
nopl   0x0(%rax,%rax,1)
movb   $0x5c,(%r14)
movzbl (%rbx),%eax
mov    %al,0x1(%r14)
add    $0x2,%r14
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x24,%al
je     1130 <fix_any_dollar_signs+0x20>
test   %al,%al
je     115b <fix_any_dollar_signs+0x4b>
mov    %al,(%r14)
add    $0x1,%r14
add    $0x1,%rbx
jmp    1143 <fix_any_dollar_signs+0x33>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@fix_any_dollar_signs.tmp = internal global [65536 x i8] zeroinitializer
define void @fix_any_dollar_signs(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @fix_any_dollar_signs.tmp, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %2
%5 = call i32 @strcpy(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @fix_any_dollar_signs.tmp, i64 0, i64 0), i8* %4)
br label %6
6: ; preds = %29, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 36
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
store i8 92, i8* %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
%20 = load i8, i8* %18
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
store i8 %20, i8* %21
br label %29
23: ; preds = %10
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
%26 = load i8, i8* %24
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %2
store i8 %26, i8* %27
br label %29
29: ; preds = %23, %15
br label %6
30: ; preds = %6
%31 = load i8*, i8** %2
store i8 0, i8* %31
ret void
}

LLVM IR (-O2):
@fix_any_dollar_signs.tmp = internal global [65536 x i8] zeroinitializer
define void @fix_any_dollar_signs(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @fix_any_dollar_signs.tmp, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %13, %1
%4 = phi i8* [ %0, %1 ], [ %14, %13 ]
%5 = phi i8* [ getelementptr inbounds ([65536 x i8], [65536 x i8]* @fix_any_dollar_signs.tmp, i64 0, i64 0), %1 ], [ %15, %13 ]
%6 = load i8, i8* %5
switch i8 %6, label %11 [
i8 0, label %16
i8 36, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
store i8 92, i8* %4
%9 = load i8, i8* %5
%10 = getelementptr inbounds i8, i8* %4, i64 2
store i8 %9, i8* %8
br label %13
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %6, i8* %4
br label %13
13: ; preds = %11, %7
%14 = phi i8* [ %10, %7 ], [ %12, %11 ]
%15 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
16: ; preds = %3
store i8 0, i8* %4
ret void
}