#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 || c == '\\')
      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     1190 <dyStringQuoteString+0x80>
movsbl -0x19(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     1170 <dyStringQuoteString+0x60>
movsbl -0x19(%rbp),%eax
cmp    $0x5c,%eax
jne    117e <dyStringQuoteString+0x6e>
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     1170 <dyStringQuoteString+0x60>
add    $0x1,%rbp
jmp    1164 <dyStringQuoteString+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x5c,%esi
call   1030 <dyStringAppendC@plt>
movsbl %bl,%esi
mov    %r15,%rdi
call   1030 <dyStringAppendC@plt>
movzbl 0x0(%rbp),%ebx
add    $0x1,%rbp
test   %bl,%bl
je     1170 <dyStringQuoteString+0x60>
cmp    %r14b,%bl
je     1140 <dyStringQuoteString+0x30>
cmp    $0x5c,%bl
jne    114d <dyStringQuoteString+0x3d>
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 = %30, %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 %34
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 %27, label %23
23: ; preds = %17
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 92
br i1 %26, label %27, label %30
27: ; preds = %23, %17
%28 = load %struct.dyString*, %struct.dyString** %4
%29 = call i32 @dyStringAppendC(%struct.dyString* %28, i8 signext 92)
br label %30
30: ; preds = %27, %23
%31 = load %struct.dyString*, %struct.dyString** %4
%32 = load i8, i8* %7
%33 = call i32 @dyStringAppendC(%struct.dyString* %31, i8 signext %32)
br label %11
34: ; preds = %11
%35 = load %struct.dyString*, %struct.dyString** %4
%36 = load i8, i8* %5
%37 = call i32 @dyStringAppendC(%struct.dyString* %35, i8 signext %36)
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 %20, label %7
7: ; preds = %3, %16
%8 = phi i8 [ %18, %16 ], [ %5, %3 ]
%9 = phi i8* [ %10, %16 ], [ %2, %3 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = icmp eq i8 %8, %1
%12 = icmp eq i8 %8, 92
%13 = or i1 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @dyStringAppendC(%struct.dyString* %0, i8 signext 92)
br label %16
16: ; preds = %7, %14
%17 = tail call i32 @dyStringAppendC(%struct.dyString* %0, i8 signext %8)
%18 = load i8, i8* %10
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %16, %3
%21 = tail call i32 @dyStringAppendC(%struct.dyString* %0, i8 signext %1)
ret void
}