#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 dyStringQuoteString(struct dyString *dy, char quotChar, char *text) {
  char c;
  dyStringAppendC(dy, quotChar);
  while ((c = *text++) != 0) {
    if (c == quotChar)
      dyStringAppendC(dy, '\\');
    dyStringAppendC(dy, c);
  }
  dyStringAppendC(dy, quotChar);
}


x86 assembly (clang, -O0):
<dyStringQuoteString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <dyStringAppendC@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1183 <dyStringQuoteString+0x73>
movsbl -0x19(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    1171 <dyStringQuoteString+0x61>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <dyStringAppendC@plt>
mov    -0x8(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1030 <dyStringAppendC@plt>
jmp    1133 <dyStringQuoteString+0x23>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <dyStringAppendC@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dyStringQuoteString>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <dyStringAppendC@plt>
mov    0x0(%rbp),%bl
test   %bl,%bl
je     116b <dyStringQuoteString+0x5b>
add    $0x1,%rbp
jmp    1157 <dyStringQuoteString+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %bl,%esi
mov    %r15,%rdi
call   1030 <dyStringAppendC@plt>
movzbl 0x0(%rbp),%ebx
add    $0x1,%rbp
test   %bl,%bl
je     116b <dyStringQuoteString+0x5b>
cmp    %r14b,%bl
jne    1140 <dyStringQuoteString+0x30>
mov    %r15,%rdi
mov    $0x5c,%esi
call   1030 <dyStringAppendC@plt>
jmp    1140 <dyStringQuoteString+0x30>
movsbl %r14b,%esi
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <dyStringAppendC@plt>

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

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