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


x86 assembly (clang, -O0):
<luaI_addquoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x22,%edi
call   1040 <luaL_addchar@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1187 <luaI_addquoted+0x67>
mov    -0x8(%rbp),%rax
lea    0xeb2(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     116a <luaI_addquoted+0x4a>
mov    $0x5c,%edi
call   1040 <luaL_addchar@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <luaL_addchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1136 <luaI_addquoted+0x16>
mov    $0x22,%edi
call   1040 <luaL_addchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luaI_addquoted>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x22,%edi
call   1040 <luaL_addchar@plt>
mov    (%rbx),%al
test   %al,%al
je     1180 <luaI_addquoted+0x60>
add    $0x1,%rbx
lea    0xebe(%rip),%r14
jmp    1164 <luaI_addquoted+0x44>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl -0x1(%rbx),%edi
call   1040 <luaL_addchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1180 <luaI_addquoted+0x60>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     1150 <luaI_addquoted+0x30>
mov    $0x5c,%edi
call   1040 <luaL_addchar@plt>
jmp    1150 <luaI_addquoted+0x30>
mov    $0x22,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <luaL_addchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\22\\\0A\00"
define void @luaI_addquoted(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @luaL_addchar(i8 signext 34)
br label %4
4: ; preds = %19, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @luaL_addchar(i8 signext 92)
br label %15
15: ; preds = %13, %8
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = call i32 @luaL_addchar(i8 signext %17)
br label %19
19: ; preds = %15
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %4
22: ; preds = %4
%23 = call i32 @luaL_addchar(i8 signext 34)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\22\\\0A\00"
define void @luaI_addquoted(i8* nocapture %0) {
%2 = tail call i32 @luaL_addchar(i8 signext 34)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1, %12
%6 = phi i8 [ %16, %12 ], [ %3, %1 ]
%7 = phi i8* [ %15, %12 ], [ %0, %1 ]
%8 = tail call i64 @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @luaL_addchar(i8 signext 92)
br label %12
12: ; preds = %10, %5
%13 = load i8, i8* %7
%14 = tail call i32 @luaL_addchar(i8 signext %13)
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %5
18: ; preds = %12, %1
%19 = tail call i32 @luaL_addchar(i8 signext 34)
ret void
}