#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*/ luaI_addchar(char);
void luaI_addquoted(char *s) {
  luaI_addchar('"');
  for (; *s; s++) {
    if (*s == '"' || *s == '\\' || *s == '\n')
      luaI_addchar('\\');
    luaI_addchar(*s);
  }
  luaI_addchar('"');
}


x86 assembly (clang, -O0):
<luaI_addquoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x22,%edi
call   1030 <luaI_addchar@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     118a <luaI_addquoted+0x7a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1163 <luaI_addquoted+0x53>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1163 <luaI_addquoted+0x53>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    116d <luaI_addquoted+0x5d>
mov    $0x5c,%edi
call   1030 <luaI_addchar@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <luaI_addchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1126 <luaI_addquoted+0x16>
mov    $0x22,%edi
call   1030 <luaI_addchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luaI_addquoted>:
push   %rbx
mov    %rdi,%rbx
mov    $0x22,%edi
call   1030 <luaI_addchar@plt>
jmp    113d <luaI_addquoted+0x2d>
cmp    $0xa,%al
jne    114e <luaI_addquoted+0x3e>
mov    $0x5c,%edi
call   1030 <luaI_addchar@plt>
movzbl (%rbx),%eax
movsbl %al,%edi
call   1030 <luaI_addchar@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x21,%al
jle    1120 <luaI_addquoted+0x10>
cmp    $0x5c,%al
je     1124 <luaI_addquoted+0x14>
cmp    $0x22,%al
je     1124 <luaI_addquoted+0x14>
jmp    1131 <luaI_addquoted+0x21>
test   %al,%al
jne    1131 <luaI_addquoted+0x21>
mov    $0x22,%edi
pop    %rbx
jmp    1030 <luaI_addchar@plt>

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

LLVM IR (-O2):
define void @luaI_addquoted(i8* nocapture %0) {
%2 = tail call i32 @luaI_addchar(i8 signext 34)
br label %3
3: ; preds = %9, %1
%4 = phi i8* [ %0, %1 ], [ %12, %9 ]
%5 = load i8, i8* %4
switch i8 %5, label %9 [
i8 0, label %13
i8 34, label %6
i8 92, label %6
i8 10, label %6
]
6: ; preds = %3, %3, %3
%7 = tail call i32 @luaI_addchar(i8 signext 92)
%8 = load i8, i8* %4
br label %9
9: ; preds = %3, %6
%10 = phi i8 [ %5, %3 ], [ %8, %6 ]
%11 = tail call i32 @luaI_addchar(i8 signext %10)
%12 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
13: ; preds = %3
%14 = tail call i32 @luaI_addchar(i8 signext 34)
ret void
}