// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
addq %rsi, %rdx
pushq $0x3a
popq %rbp
pushq $0x5c
popq %r12
movq %rdx, 0x38(%rsp)
cmpq %rdx, %r13
setae %r8b
jae 0x7f24
leaq 0x1(%r13), %rbx
movb (%r13), %r14b
cmpb $0x24, %r14b
setne %al
cmpq %rbx, %rdx
sete %cl
orb %al, %cl
jne 0x7b42
cmpb $0x28, (%rbx)
jne 0x7b42
movq 0x10(%rsp), %rax
cmpl $0x0, 0xc(%rax)
je 0x7b2f
leaq 0x2(%r13), %rsi
movq %rdx, %rax
subq %rsi, %rax
addq $0x3, %r13
pushq $0x1
popq %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x7f2c
movzbl -0x1(%r13), %edi
cmpl $0x29, %edi
je 0x7a55
cmpl $0x28, %edi
jne 0x7a59
incl %ecx
jmp 0x7a59
decl %ecx
je 0x7a61
incq %rdx
incq %r13
jmp 0x7a39
movl %r8d, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x128(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0xd8(%rsp), %rdi
movq 0x10(%rsp), %rcx
callq 0x79b7
testb %al, %al
je 0x7b5f
leaq 0xd8(%rsp), %rdi
callq 0x7fb8
movq 0x130(%rsp), %rbx
testq %rbx, %rbx
cmoveq 0xe0(%rsp), %rbx
movq 0x128(%rsp), %r14
leaq 0xe8(%rsp), %rax
cmoveq %rax, %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x6210
testq %rax, %rax
je 0x7bbb
movq %rax, %r15
subq %r14, %r15
xorl %ebx, %ebx
movq %rax, %rdi
movl %ebp, %esi
callq 0x6210
testq %rax, %rax
je 0x7b66
cmpb $0x5c, -0x1(%rax)
jne 0x7b16
incq %rax
jmp 0x7afc
cmpq $0xa, %rbx
je 0x7b5f
movb $0x0, (%rax)
incq %rax
movq %rax, 0x140(%rsp,%rbx,8)
incq %rbx
jmp 0x7afc
movzbl 0x2(%r13), %eax
cmpl $0x3c, %eax
je 0x7b42
cmpl $0x40, %eax
jne 0x7a26
movq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x85c6
movq 0x38(%rsp), %rdx
movb %r14b, (%rax)
movq %rbx, %r13
jmp 0x79e4
xorl %ebx, %ebx
jmp 0x7f08
xorl %eax, %eax
cmpq %rbx, %rax
je 0x7bc3
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 0x7b8f
testl %edi, %edi
jne 0x7ba4
jmp 0x7bb0
addl $0x2, %r8d
cmpb $0x3a, (%rcx,%rsi)
movl %r12d, %edi
cmovel %ebp, %edi
cmovnel %esi, %r8d
movl %r8d, %esi
movb %dil, (%rcx,%rdx)
incq %rdx
movl %esi, %r8d
jmp 0x7b7a
movl %edx, %edx
movb $0x0, (%rcx,%rdx)
incq %rax
jmp 0x7b68
decq %rbx
movq %rbx, %r15
xorl %ebx, %ebx
leaq 0x58(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x7fc6
cmpb $0x0, 0x60(%rsp)
je 0x7efc
movq %rbx, 0x40(%rsp)
movq 0x68(%rsp), %rbx
leaq 0x24458(%rip), %rax     # 0x2c04c
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, %r15
xorl %r14d, %r14d
cmpq %r14, 0x40(%rsp)
je 0x7c50
movq 0x140(%rsp,%r14,8), %rdi
movzbl (%rdi), %eax
cmpl $0x5b, %eax
je 0x7c2e
cmpl $0x6a, %eax
jne 0x7c4b
incq %rdi
movq %rdi, 0x18(%rsp)
jmp 0x7c4b
incq %rdi
callq 0x6760
movslq %eax, %r15
leaq -0x1(%r15), %rcx
movq %rcx, 0x20(%rsp)
cmpq %rcx, %rbx
jbe 0x7efc
incq %r14
jmp 0x7c08
movq 0x18(%rsp), %rdi
callq 0x6240
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rbx
movq %r15, 0x48(%rsp)
cmpq %r15, %rbx
jae 0x7ed3
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
leaq 0x50(%rsp), %rdx
callq 0x8166
testq %rax, %rax
je 0x7efc
movq %rbx, 0x30(%rsp)
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
leaq 0xc0(%rsp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq 0x50(%rsp), %rdx
leaq 0x70(%rsp), %rdi
movq %rax, %rsi
movq 0x10(%rsp), %rcx
callq 0x79b7
testb %al, %al
je 0x7ef2
xorl %ebx, %ebx
cmpq %rbx, 0x40(%rsp)
je 0x7e43
movq 0x140(%rsp,%rbx,8), %r14
movzbl (%r14), %eax
leal -0x61(%rax), %ecx
cmpl $0x14, %ecx
ja 0x7d17
leaq 0x246a9(%rip), %rdx     # 0x2c3a8
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x70(%rsp), %rdi
callq 0x8316
jmp 0x7e3b
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x7d4f
leaq 0x2466a(%rip), %rdx     # 0x2c390
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %r14
movq %r14, %rdi
callq 0x6240
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x82aa
jmp 0x7e3b
cmpl $0x23, %eax
je 0x7e31
cmpl $0x50, %eax
je 0x7e14
cmpl $0x5b, %eax
je 0x7e3b
jmp 0x7ed7
incq %r14
movq %r14, %rdi
callq 0x6240
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x81fa
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x836e
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x8342
jmp 0x7e3b
incq %r14
movq %r14, %rdi
callq 0x6240
movq %rax, %r15
leaq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x85c6
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x63d0
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x83aa
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x84d2
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x83e6
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x848a
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x8426
jmp 0x7e3b
incq %r14
movq %r14, %rdi
callq 0x6240
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8250
jmp 0x7e3b
leaq 0x70(%rsp), %rdi
callq 0x8570
incq %rbx
jmp 0x7cd9
movq 0x30(%rsp), %rax
cmpq 0x20(%rsp), %rax
jbe 0x7e70
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x85c6
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x63d0
movq 0xc0(%rsp), %r14
movq 0xc8(%rsp), %rbx
movq %rbx, %r15
testq %rbx, %rbx
jne 0x7e8d
movq 0x78(%rsp), %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x85c6
testq %rbx, %rbx
leaq 0x80(%rsp), %rcx
cmoveq %rcx, %r14
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x63d0
leaq 0x70(%rsp), %rdi
callq 0x7fa0
movq 0x30(%rsp), %rbx
incq %rbx
movq 0x48(%rsp), %r15
jmp 0x7c69
movb $0x1, %bl
jmp 0x7efe
movq 0x3a0fa(%rip), %rax     # 0x41fd8
movq (%rax), %rdi
leaq 0x24566(%rip), %rsi     # 0x2c44e
movq %r14, %rdx
xorl %eax, %eax
callq 0x6670
leaq 0x70(%rsp), %rdi
callq 0x7fa0
xorl %ebx, %ebx
leaq 0x58(%rsp), %rdi
callq 0x85aa
leaq 0xd8(%rsp), %rdi
callq 0x7fa0
testb %bl, %bl
movq 0x38(%rsp), %rdx
jne 0x79e4
jmp 0x7f50
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x7f50
movq 0x3a0a5(%rip), %rax     # 0x41fd8
movq (%rax), %rcx
leaq 0x244fe(%rip), %rdi     # 0x2c43b
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
callq 0x68e0
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7f68
movq %rax, %rbx
jmp 0x7f8b
movq %rax, %rbx
jmp 0x7f81
jmp 0x7f74
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x7fa0
leaq 0x58(%rsp), %rdi
callq 0x85aa
leaq 0xd8(%rsp), %rdi
callq 0x7fa0
movq %rbx, %rdi
callq 0x6820