// File: /workspace/github_c_makefile_star2_O1/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
testq %rdx, %rdx
setle 0x7(%rsp)
jle 0x865a
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %r12
addq %rsi, %r15
movq %rcx, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
leaq 0x1(%rbp), %rbx
movb (%rbp), %r14b
cmpb $0x24, %r14b
setne %al
cmpq %rbx, %r15
sete %cl
orb %al, %cl
jne 0x8060
cmpb $0x28, (%rbx)
jne 0x8060
cmpl $0x0, 0xc(%r13)
je 0x804e
addq $0x2, %rbp
movq %r15, %rax
subq %rbp, %rax
je 0x7f2e
movl $0x1, %ecx
movq %rbp, %r12
movzbl (%r12), %edx
cmpl $0x29, %edx
je 0x7f22
cmpl $0x28, %edx
jne 0x7f26
incl %ecx
jmp 0x7f26
decl %ecx
je 0x7f31
incq %r12
decq %rax
jne 0x7f0f
xorl %r12d, %r12d
testq %r12, %r12
je 0x8211
movq %r12, %rdx
subq %rbp, %rdx
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
xorl %ecx, %ecx
movq %rcx, 0xe0(%rsp)
leaq 0x128(%rsp), %rax
movq %rcx, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0xd8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rcx
callq 0x7e8d
testb %al, %al
je 0x8090
movl $0x1, %esi
leaq 0xd8(%rsp), %rdi
callq 0x8c9a
movb $0x0, (%rax)
movq 0x130(%rsp), %r15
testq %r15, %r15
cmoveq 0xe0(%rsp), %r15
movq 0x128(%rsp), %r13
leaq 0xe8(%rsp), %rax
cmoveq %rax, %r13
movq %r13, %rdi
movl $0x3a, %esi
callq 0x6210
movb $0x1, %r14b
testq %rax, %rax
je 0x8097
movq %rax, %rbx
movq %rax, %rdi
subq %r13, %rbx
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
je 0x80b0
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r15
cmpb $0x5c, -0x1(%rax)
jne 0x8027
incq %rax
movq %rax, %rdi
movl $0x3a, %esi
callq 0x6210
testq %rax, %rax
jne 0x8007
jmp 0x80be
movq 0x8(%rsp), %rcx
cmpq $0xa, %rcx
je 0x861c
movb $0x0, (%rax)
incq %rax
movq %rax, 0x140(%rsp,%rcx,8)
incq %rcx
movq %rcx, 0x8(%rsp)
jmp 0x8010
movzbl 0x2(%rbp), %eax
cmpl $0x3c, %eax
je 0x8060
cmpl $0x40, %eax
jne 0x7efb
movl $0x1, %esi
movq %r12, %rdi
callq 0x8c9a
movb %r14b, (%rax)
xorl %eax, %eax
testb $0x1, %al
jne 0x865a
movq %rbx, %rbp
cmpq %r15, %rbx
setae 0x7(%rsp)
jb 0x7eca
jmp 0x865a
xorl %ebx, %ebx
jmp 0x85f4
decq %r15
movq %r15, %rbx
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r15
jmp 0x8131
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r15
cmpq $0x0, 0x8(%rsp)
je 0x8131
xorl %eax, %eax
movq 0x140(%rsp,%rax,8), %rcx
xorl %edx, %edx
xorl %r8d, %r8d
movslq %r8d, %rsi
movzbl (%rcx,%rsi), %edi
incq %rsi
testl %edi, %edi
je 0x8112
cmpl $0x5c, %edi
jne 0x8105
addl $0x2, %r8d
cmpb $0x3a, (%rcx,%rsi)
movzbl %dil, %edi
movl $0x3a, %r9d
cmovel %r9d, %edi
cmovnel %esi, %r8d
movl %r8d, %esi
movslq %edx, %r8
incl %edx
movb %dil, (%rcx,%r8)
xorl %edi, %edi
jmp 0x8115
movb $0x1, %dil
movl %esi, %r8d
testb %dil, %dil
je 0x80d5
movslq %edx, %rdx
movb $0x0, (%rcx,%rdx)
incq %rax
cmpq 0x8(%rsp), %rax
jne 0x80c8
movb $0x1, %r14b
testb %r14b, %r14b
je 0x81f9
leaq 0xc0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x86e2
cmpb $0x0, 0xc8(%rsp)
je 0x8205
movq 0xd0(%rsp), %r14
movq 0x8(%rsp), %r15
testq %r15, %r15
setne %bl
je 0x8220
negq %r15
movl $0x1, %r13d
movq %r14, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0x27eb5(%rip), %rax     # 0x3004c
movq %rax, 0x28(%rsp)
movq 0x138(%rsp,%r13,8), %rdi
movzbl (%rdi), %ecx
cmpl $0x5b, %ecx
je 0x81bd
movb $0x1, %al
cmpl $0x6a, %ecx
jne 0x81db
incq %rdi
movq %rdi, 0x28(%rsp)
jmp 0x81db
incq %rdi
callq 0x6760
cltq
movq %rax, 0x30(%rsp)
leaq -0x1(%rax), %rcx
movq %rcx, 0x38(%rsp)
cmpq %rcx, %r14
seta %al
testb %al, %al
je 0x823a
cmpq 0x8(%rsp), %r13
setb %bl
leaq (%r15,%r13), %rax
incq %rax
incq %r13
cmpq $0x1, %rax
jne 0x819c
jmp 0x823a
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
jmp 0x85f4
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
jmp 0x85e7
callq 0x693b
movl $0x1, %eax
jmp 0x860f
leaq 0x27e25(%rip), %rax     # 0x3004c
movq %rax, 0x28(%rsp)
movq $0x0, 0x38(%rsp)
movq %r14, 0x30(%rsp)
testb $0x1, %bl
je 0x8250
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %r15
jmp 0x85e7
movq 0x28(%rsp), %rdi
callq 0x6240
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
setae %bl
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %r15
jae 0x85e7
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
leaq 0xb8(%rsp), %rdx
callq 0x8888
testq %rax, %rax
movq 0x10(%rsp), %r15
je 0x85e5
movq %rbx, 0x48(%rsp)
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x50(%rsp)
xorl %edx, %edx
movq %rdx, 0x58(%rsp)
leaq 0xa0(%rsp), %rcx
movq %rdx, 0x10(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq 0xb8(%rsp), %rdx
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
movq %r13, %rcx
callq 0x7e8d
testb %al, %al
je 0x8649
cmpq $0x0, 0x8(%rsp)
je 0x8550
xorl %r14d, %r14d
movq 0x140(%rsp,%r14,8), %rbx
movzbl (%rbx), %eax
cmpl $0x5a, %eax
jle 0x834e
leal -0x61(%rax), %ecx
cmpl $0x14, %ecx
ja 0x83f0
leaq 0x28086(%rip), %rdx     # 0x303a8
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %rbx
movq %rbx, %rdi
callq 0x6240
movq %rax, %r15
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x8c9a
movq %rax, %rdi
jmp 0x8452
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x8386
leaq 0x28033(%rip), %rdx     # 0x30390
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %rbx
movq %rbx, %rdi
callq 0x6240
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x898c
jmp 0x8542
cmpl $0x23, %eax
je 0x83e1
cmpl $0x50, %eax
jne 0x862e
incq %rbx
movq %rbx, %rdi
callq 0x6240
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x88f4
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8b1c
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8a74
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8ab4
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8c20
jmp 0x8542
cmpl $0x5b, %eax
je 0x8542
jmp 0x862e
incq %rbx
movq %rbx, %rdi
callq 0x6240
movq %rax, %r15
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x8c9a
movq 0xa8(%rsp), %rdx
testq %rdx, %rdx
movq 0xa0(%rsp), %r13
cmoveq 0x58(%rsp), %rdx
leaq 0x60(%rsp), %rax
cmoveq %rax, %r13
leaq (%r15,%r13), %rdi
subq %r15, %rdx
movq %r13, %rsi
callq 0x67c0
movq %r13, %rdi
movq 0x18(%rsp), %r13
movq %rbx, %rsi
movq %r15, %rdx
callq 0x63d0
jmp 0x8542
movq 0xa8(%rsp), %rax
testq %rax, %rax
cmoveq 0x58(%rsp), %rax
movq 0xa0(%rsp), %rcx
leaq 0x60(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x8542
xorl %edx, %edx
cmpb $0x5c, (%rcx,%rdx)
jne 0x8499
movb $0x2f, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x848f
jmp 0x8542
movq 0xa8(%rsp), %rax
testq %rax, %rax
cmoveq 0x58(%rsp), %rax
movq 0xa0(%rsp), %rcx
leaq 0x60(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x8542
xorl %edx, %edx
cmpb $0x2f, (%rcx,%rdx)
jne 0x84d9
movb $0x5c, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x84cf
jmp 0x8542
movq 0xa8(%rsp), %rax
testq %rax, %rax
cmoveq 0x58(%rsp), %rax
movq 0xa0(%rsp), %rcx
leaq 0x60(%rsp), %rdx
cmoveq %rdx, %rcx
testq %rax, %rax
je 0x8542
xorl %edx, %edx
cmpb $0x5c, (%rcx,%rdx)
jne 0x8516
movb $0x2f, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x850c
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8a36
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x89f8
jmp 0x8542
leaq 0x50(%rsp), %rdi
callq 0x8b64
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x82ff
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
jbe 0x857d
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x8c9a
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x63d0
movq 0xa0(%rsp), %rbx
movq 0xa8(%rsp), %r14
movq %r14, %r15
testq %r14, %r14
jne 0x859a
movq 0x58(%rsp), %r15
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x8c9a
testq %r14, %r14
leaq 0x60(%rsp), %rcx
cmoveq %rcx, %rbx
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x63d0
leaq 0x50(%rsp), %rdi
callq 0x86b0
movq 0x48(%rsp), %rbx
incq %rbx
cmpq 0x30(%rsp), %rbx
jne 0x827f
movb $0x1, %bl
jmp 0x8246
xorl %ebx, %ebx
leaq 0xc0(%rsp), %rdi
callq 0x8c7c
leaq 0xd8(%rsp), %rdi
callq 0x86b0
incq %r12
testb %bl, %bl
cmovneq %r12, %rbp
movzbl %bl, %eax
incl %eax
movq %rbp, %rbx
movq 0x20(%rsp), %r12
jmp 0x8072
movl $0xa, %eax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
jmp 0x8131
movq 0x399a3(%rip), %rax     # 0x41fd8
movq (%rax), %rdi
leaq 0x27e0f(%rip), %rsi     # 0x3044e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6670
leaq 0x50(%rsp), %rdi
callq 0x86b0
xorl %ebx, %ebx
jmp 0x8246
movb 0x7(%rsp), %al
andb $0x1, %al
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x867b
movq %rax, %rbx
jmp 0x868d
jmp 0x8680
movq %rax, %rbx
jmp 0x869a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x86b0
leaq 0xc0(%rsp), %rdi
callq 0x8c7c
leaq 0xd8(%rsp), %rdi
callq 0x86b0
movq %rbx, %rdi
callq 0x6820
nop