#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 */
struct dyString {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dyStringAppendC(struct dyString *, char);
void dyStringAppendEscapeQuotes(struct dyString *dy, char *string, char quot,
                                char esc) {
  char c;
  char *s = string;
  while ((c = *s++) != 0) {
    if (c == quot)
      dyStringAppendC(dy, esc);
    dyStringAppendC(dy, c);
  }
}


x86 assembly (clang, -O0):
<dyStringAppendEscapeQuotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x13(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1181 <dyStringAppendEscapeQuotes+0x71>
movsbl -0x13(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    116f <dyStringAppendEscapeQuotes+0x5f>
mov    -0x8(%rbp),%rdi
movsbl -0x12(%rbp),%esi
call   1030 <dyStringAppendC@plt>
mov    -0x8(%rbp),%rdi
movsbl -0x13(%rbp),%esi
call   1030 <dyStringAppendC@plt>
jmp    1132 <dyStringAppendEscapeQuotes+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dyStringAppendEscapeQuotes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%r12b
test   %r12b,%r12b
je     116b <dyStringAppendEscapeQuotes+0x5b>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbx
movsbl %cl,%r15d
jmp    1159 <dyStringAppendEscapeQuotes+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %r12b,%esi
mov    %rbp,%rdi
call   1030 <dyStringAppendC@plt>
movzbl (%rbx),%r12d
add    $0x1,%rbx
test   %r12b,%r12b
je     116b <dyStringAppendEscapeQuotes+0x5b>
cmp    %r14b,%r12b
jne    1140 <dyStringAppendEscapeQuotes+0x30>
mov    %rbp,%rdi
mov    %r15d,%esi
call   1030 <dyStringAppendC@plt>
jmp    1140 <dyStringAppendEscapeQuotes+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dyString = type { i32 }
define void @dyStringAppendEscapeQuotes(%struct.dyString* %0, i8* %1, i8 signext %2, i8 signext %3) {
%5 = alloca %struct.dyString*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8*
store %struct.dyString* %0, %struct.dyString** %5
store i8* %1, i8** %6
store i8 %2, i8* %7
store i8 %3, i8* %8
%11 = load i8*, i8** %6
store i8* %11, i8** %10
br label %12
12: ; preds = %28, %4
%13 = load i8*, i8** %10
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %10
%15 = load i8, i8* %13
store i8 %15, i8* %9
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %12
%19 = load i8, i8* %9
%20 = sext i8 %19 to i32
%21 = load i8, i8* %7
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load %struct.dyString*, %struct.dyString** %5
%26 = load i8, i8* %8
%27 = call i32 @dyStringAppendC(%struct.dyString* %25, i8 signext %26)
br label %28
28: ; preds = %24, %18
%29 = load %struct.dyString*, %struct.dyString** %5
%30 = load i8, i8* %9
%31 = call i32 @dyStringAppendC(%struct.dyString* %29, i8 signext %30)
br label %12
32: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.dyString = type { i32 }
define void @dyStringAppendEscapeQuotes(%struct.dyString* %0, i8* nocapture %1, i8 signext %2, i8 signext %3) {
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4, %14
%8 = phi i8 [ %16, %14 ], [ %5, %4 ]
%9 = phi i8* [ %10, %14 ], [ %1, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = icmp eq i8 %8, %2
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @dyStringAppendC(%struct.dyString* %0, i8 signext %3)
br label %14
14: ; preds = %12, %7
%15 = tail call i32 @dyStringAppendC(%struct.dyString* %0, i8 signext %8)
%16 = load i8, i8* %10
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %7
18: ; preds = %14, %4
ret void
}