// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]tundra/src/LuaInterpolate.cpp
// Function: t2::DoInterpolate(t2::StringBuffer&, char const*, unsigned long, t2::LuaEnvLookup&)
static bool DoInterpolate(StringBuffer& output, const char* str, size_t len, LuaEnvLookup& lookup)
{
  const char* end = str + len;

  while (str < end)
  {
    char ch = *str++;

    if ('$' == ch)
    {
      if (end != str && '(' == str[0])
      {
        // Don't interpolate $(<) or $(@) without a lookaside table.
        // We leave them in the string.
        if (lookup.m_VarIndex || (str[1] != '<' && str[1] != '@'))
        {
          ++str;
          const char* end_paren = FindEndParen(str, end - str);
          if (!end_paren)
          {
            fprintf(stderr, "unbalanced parens\n");
            return false;
          }
          if (!InterpolateVar(output, str, end_paren - str, lookup))
            return false;
          str = end_paren + 1;
          continue;
        }
      }
    }

    output.Add(&ch, 1);
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rcx, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
movb $0x1, %al
testq %rdx, %rdx
jle 0x85b8
addq %rsi, %rdx
movq %rdx, 0xb0(%rsp)
leaq 0x1(%rsi), %r15
movb (%rsi), %bpl
cmpb $0x24, %bpl
setne %al
cmpq %r15, %rdx
sete %cl
orb %al, %cl
jne 0x803d
cmpb $0x28, (%r15)
jne 0x803d
movq 0x18(%rsp), %rax
cmpl $0x0, 0xc(%rax)
je 0x802b
leaq 0x2(%rsi), %rax
movq %rdx, %rcx
subq %rax, %rcx
je 0x85ad
addq $0x3, %rsi
movl $0x1, %edi
movq %rsi, %r15
xorl %edx, %edx
movzbl -0x1(%r15), %esi
cmpl $0x29, %esi
je 0x7f0c
cmpl $0x28, %esi
jne 0x7f10
incl %edi
jmp 0x7f10
decl %edi
je 0x7f20
incq %rdx
incq %r15
cmpq %rdx, %rcx
jne 0x7ef9
jmp 0x85ad
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0xd8(%rsp)
xorl %esi, %esi
movq %rsi, 0xe0(%rsp)
leaq 0x128(%rsp), %rcx
movq %rsi, 0x10(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
leaq 0xd8(%rsp), %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rcx
callq 0x7e75
testb %al, %al
je 0x85ca
movl $0x1, %esi
leaq 0xd8(%rsp), %rdi
callq 0x8bc0
movb $0x0, (%rax)
movq 0x130(%rsp), %r12
testq %r12, %r12
cmoveq 0xe0(%rsp), %r12
movq 0x128(%rsp), %r13
leaq 0xe8(%rsp), %rax
cmoveq %rax, %r13
movq %r13, %rdi
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
je 0x8068
movq %rax, %r14
movq %rax, %rdi
subq %r13, %r14
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
je 0x80cc
xorl %ebp, %ebp
movl $0x3a, %ebx
cmpb $0x5c, -0x1(%rax)
jne 0x7ffc
incq %rax
movq %rax, %rdi
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
jne 0x7fdf
jmp 0x8070
cmpq $0xa, %rbp
je 0x85ca
movb $0x0, (%rax)
incq %rax
movq %rax, 0x140(%rsp,%rbp,8)
incq %rbp
movq %rax, %rdi
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
jne 0x7fdf
jmp 0x8075
movzbl 0x2(%rsi), %eax
cmpl $0x3c, %eax
je 0x803d
cmpl $0x40, %eax
jne 0x7edb
movl $0x1, %esi
movq 0x8(%rsp), %rdi
callq 0x8bc0
movb %bpl, (%rax)
movq %r15, %rsi
movq 0xb0(%rsp), %rdx
cmpq %rdx, %r15
jb 0x7ea6
jmp 0x85b6
decq %r12
movq %r12, %r14
jmp 0x80cc
testq %rbp, %rbp
je 0x80cc
xorl %eax, %eax
movq 0x140(%rsp,%rax,8), %rcx
xorl %edx, %edx
xorl %r8d, %r8d
movslq %r8d, %rsi
movzbl (%rcx,%rsi), %edi
incq %rsi
cmpl $0x5c, %edi
je 0x8099
testl %edi, %edi
jne 0x80b0
jmp 0x80bc
addl $0x2, %r8d
cmpb $0x3a, (%rcx,%rsi)
movl $0x5c, %edi
cmovel %ebx, %edi
cmovnel %esi, %r8d
movl %r8d, %esi
movb %dil, (%rcx,%rdx)
incq %rdx
movl %esi, %r8d
jmp 0x8084
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
incq %rax
cmpq %rbp, %rax
jne 0x8077
jmp 0x80ce
xorl %ebp, %ebp
leaq 0xc0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x8648
cmpb $0x0, 0xc8(%rsp)
je 0x8585
movq 0xd0(%rsp), %r14
testq %rbp, %rbp
je 0x815b
xorl %r12d, %r12d
movq %r14, %r13
movq $0x0, 0x10(%rsp)
leaq 0x27f35(%rip), %rbx     # 0x3004c
movq 0x140(%rsp,%r12,8), %rdi
movzbl (%rdi), %eax
cmpl $0x5b, %eax
je 0x8134
cmpl $0x6a, %eax
jne 0x8151
incq %rdi
movq %rdi, %rbx
jmp 0x8151
incq %rdi
callq 0x6760
movslq %eax, %r13
leaq -0x1(%r13), %rcx
movq %rcx, 0x10(%rsp)
cmpq %rcx, %r14
jbe 0x8585
incq %r12
cmpq %r12, %rbp
jne 0x8117
jmp 0x816e
leaq 0x27eea(%rip), %rbx     # 0x3004c
movq $0x0, 0x10(%rsp)
movq %r14, %r13
movq %rbx, %rdi
callq 0x6240
movq %rax, 0x20(%rsp)
movb $0x1, %r12b
movq 0x10(%rsp), %rax
cmpq %r13, %rax
leaq 0x30(%rsp), %r14
jae 0x8588
movq %rbp, 0xa8(%rsp)
movq %rbx, %rbp
movq %rax, %rbx
movq %rbp, 0xa0(%rsp)
movq %r13, 0x98(%rsp)
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
leaq 0xb8(%rsp), %rdx
callq 0x87ee
testq %rax, %rax
je 0x8585
movq %rbx, 0x28(%rsp)
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x30(%rsp)
xorl %edx, %edx
movq %rdx, 0x38(%rsp)
leaq 0x80(%rsp), %rcx
movq %rdx, 0x10(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq 0xb8(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rcx
callq 0x7e75
testb %al, %al
leaq 0x30(%rsp), %r12
je 0x857d
movq 0xa8(%rsp), %rax
testq %rax, %rax
je 0x84c0
movq %rax, %rbx
xorl %ebp, %ebp
movq 0x140(%rsp,%rbp,8), %r14
movzbl (%r14), %eax
cmpl $0x5a, %eax
jle 0x8284
leal -0x61(%rax), %ecx
cmpl $0x14, %ecx
ja 0x836a
leaq 0x2814e(%rip), %rdx     # 0x303a8
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %r14
movq %r14, %rdi
callq 0x6240
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
callq 0x8bc0
movq %rax, %rdi
jmp 0x83ca
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x82ba
leaq 0x280fd(%rip), %rdx     # 0x30390
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %r14
movq %r14, %rdi
callq 0x6240
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x88f2
jmp 0x84b4
cmpl $0x23, %eax
je 0x835d
cmpl $0x50, %eax
jne 0x8562
incq %r14
movq %r14, %rdi
callq 0x6240
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x885a
jmp 0x84b4
movq %r12, %rdi
callq 0x8a42
jmp 0x84b4
movq 0x88(%rsp), %rax
testq %rax, %rax
movq 0x38(%rsp), %rdx
cmovneq %rax, %rdx
movq 0x80(%rsp), %rcx
leaq 0x40(%rsp), %rsi
cmoveq %rsi, %rcx
movl %edx, %edx
testl %edx, %edx
jle 0x84b4
leaq -0x1(%rdx), %rsi
cmpb $0x2e, -0x1(%rcx,%rdx)
movq %rsi, %rdx
jne 0x831e
testq %rax, %rax
leaq 0x88(%rsp), %rax
leaq 0x38(%rsp), %rcx
cmoveq %rcx, %rax
movq %rsi, (%rax)
jmp 0x84b4
movq %r12, %rdi
callq 0x89da
jmp 0x84b4
movq %r12, %rdi
callq 0x8b46
jmp 0x84b4
cmpl $0x5b, %eax
je 0x84b4
jmp 0x8562
incq %r14
movq %r14, %rdi
callq 0x6240
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
callq 0x8bc0
movq 0x88(%rsp), %rdx
testq %rdx, %rdx
movq 0x80(%rsp), %r12
cmoveq 0x38(%rsp), %rdx
leaq 0x40(%rsp), %rax
cmoveq %rax, %r12
leaq (%r12,%r13), %rdi
subq %r13, %rdx
movq %r12, %rsi
callq 0x67c0
movq %r12, %rdi
leaq 0x30(%rsp), %r12
movq %r14, %rsi
movq %r13, %rdx
callq 0x63d0
jmp 0x84b4
movq 0x88(%rsp), %rax
testq %rax, %rax
cmoveq 0x38(%rsp), %rax
movq 0x80(%rsp), %rcx
leaq 0x40(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x84b4
xorl %edx, %edx
cmpb $0x5c, (%rcx,%rdx)
jne 0x8411
movb $0x2f, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8407
jmp 0x84b4
movq 0x88(%rsp), %rax
testq %rax, %rax
cmoveq 0x38(%rsp), %rax
movq 0x80(%rsp), %rcx
leaq 0x40(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x84b4
xorl %edx, %edx
cmpb $0x2f, (%rcx,%rdx)
jne 0x8451
movb $0x5c, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8447
jmp 0x84b4
movq 0x88(%rsp), %rax
testq %rax, %rax
cmoveq 0x38(%rsp), %rax
movq 0x80(%rsp), %rcx
leaq 0x40(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x84b4
xorl %edx, %edx
cmpb $0x5c, (%rcx,%rdx)
jne 0x848e
movb $0x2f, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8484
jmp 0x84b4
movq %r12, %rdi
callq 0x899c
jmp 0x84b4
movq %r12, %rdi
callq 0x895e
jmp 0x84b4
movq %r12, %rdi
callq 0x8a8a
incq %rbp
cmpq %rbx, %rbp
jne 0x8236
movq 0x28(%rsp), %rax
cmpq 0x10(%rsp), %rax
movq 0xa0(%rsp), %rbp
jbe 0x84f3
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x63d0
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %r12
movq %r12, %r13
testq %r12, %r12
jne 0x8510
movq 0x38(%rsp), %r13
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x8bc0
testq %r12, %r12
leaq 0x40(%rsp), %rcx
cmoveq %rcx, %r14
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x63d0
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x8616
movq 0x28(%rsp), %rbx
incq %rbx
movq 0x98(%rsp), %r13
cmpq %r13, %rbx
movb $0x1, %r12b
jne 0x81af
jmp 0x8588
movq 0x39a6f(%rip), %rax     # 0x41fd8
movq (%rax), %rdi
leaq 0x27edb(%rip), %rsi     # 0x3044e
movq %r14, %rdx
xorl %eax, %eax
callq 0x6670
movq %r12, %rdi
callq 0x8616
xorl %r12d, %r12d
leaq 0xc0(%rsp), %rdi
callq 0x8ba2
leaq 0xd8(%rsp), %rdi
callq 0x8616
testb %r12b, %r12b
jne 0x804f
jmp 0x85b2
callq 0x693b
xorl %eax, %eax
jmp 0x85b8
movb $0x1, %al
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd8(%rsp), %rdi
callq 0x8616
jmp 0x85b2
jmp 0x85db
movq %rax, %rbx
jmp 0x8601
movq %rax, %rbx
jmp 0x85f4
jmp 0x85e7
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8616
leaq 0xc0(%rsp), %rdi
callq 0x8ba2
leaq 0xd8(%rsp), %rdi
callq 0x8616
movq %rbx, %rdi
callq 0x6820