// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]tundra/src/DagGenerator.cpp
// Function: t2::ComputeNodeGuids(t2::JsonArrayValue const*, int*, t2::TempNodeGuid*)
bool ComputeNodeGuids(const JsonArrayValue* nodes, int32_t* remap_table, TempNodeGuid* guid_table)
{
  size_t node_count = nodes->m_Count;
  for (size_t i = 0; i < node_count; ++i)
  {
    const JsonObjectValue* nobj = nodes->m_Values[i]->AsObject();

    if (!nobj)
      return false;

    guid_table[i].m_Node = (int) i;

    HashState h;
    HashInit(&h);

    const char           *action     = FindStringValue(nobj, "Action");
    const JsonArrayValue *inputs     = FindArrayValue(nobj, "Inputs");

    if (action && action[0])
      HashAddString(&h, action);

    if (inputs)
    {
      for (size_t fi = 0, fi_count = inputs->m_Count; fi < fi_count; ++fi)
      {
        if (const JsonStringValue* str = inputs->m_Values[fi]->AsString())
        {
          HashAddString(&h, str->m_String);
        }
      }
    }

    const char *annotation = FindStringValue(nobj, "Annotation");

    if (annotation)
      HashAddString(&h, annotation);

    if ((!action || action[0] == '\0') && !inputs && !annotation)
    {
        return false;
    }

    HashFinalize(&h, &guid_table[i].m_Digest);
  }

  std::sort(guid_table, guid_table + node_count);

  for (size_t i = 1; i < node_count; ++i)
  {
    if (guid_table[i-1].m_Digest == guid_table[i].m_Digest)
    {
      int i0 = guid_table[i-1].m_Node;
      int i1 = guid_table[i].m_Node;
      const JsonObjectValue* o0 = nodes->m_Values[i0]->AsObject();
      const JsonObjectValue* o1 = nodes->m_Values[i1]->AsObject();
      const char* anno0 = FindStringValue(o0, "Annotation");
      const char* anno1 = FindStringValue(o1, "Annotation");
      char digest[kDigestStringSize];
      DigestToString(digest, guid_table[i].m_Digest);
      Log(kError, "duplicate node guids: %s and %s share common GUID (%s)", anno0, anno1, digest);
      return false;
    }
  }

  for (size_t i = 0; i < node_count; ++i)
  {
    remap_table[guid_table[i].m_Node] = (int32_t) i;
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r13
movq %rsi, 0x8(%rsp)
movq %rdi, (%rsp)
movq 0x8(%rdi), %rbp
xorl %ecx, %ecx
leaq 0x30(%rsp), %r12
movq %rdx, 0x18(%rsp)
movq %rbp, 0x10(%rsp)
cmpq %rbp, %rcx
je 0x5e51
movq (%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rcx,8), %r15
cmpl $0x2, (%r15)
jne 0x5e4a
imulq $0x14, %rcx, %rax
movq %rcx, 0x28(%rsp)
movq %rax, 0x20(%rsp)
movl %ecx, 0x10(%r13,%rax)
movq %r12, %rdi
callq 0xcd00
movq %r15, %rdi
leaq 0xe77b(%rip), %rsi      # 0x144fe
xorl %edx, %edx
callq 0x5f34
movq %rax, %rbp
movq %r15, %rdi
leaq 0xe107(%rip), %rsi      # 0x13e9e
callq 0x5f55
movq %rax, %r14
testq %rbp, %rbp
je 0x5db5
cmpb $0x0, (%rbp)
je 0x5db5
movq %r12, %rdi
movq %rbp, %rsi
callq 0x557d
testq %r14, %r14
je 0x5de3
movq 0x8(%r14), %r13
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x5de3
movq 0x10(%r14), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x4, (%rax)
jne 0x5dde
movq 0x8(%rax), %rsi
movq %r12, %rdi
callq 0x557d
incq %rbx
jmp 0x5dc0
movq %r15, %rdi
leaq 0xe0b8(%rip), %rsi      # 0x13ea5
xorl %edx, %edx
callq 0x5f34
movq %rax, %r15
testq %rax, %rax
je 0x5e07
movq %r12, %rdi
movq %r15, %rsi
callq 0x557d
testq %rbp, %rbp
je 0x5e1e
testq %r15, %r15
jne 0x5e23
testq %r14, %r14
jne 0x5e23
cmpb $0x0, (%rbp)
jne 0x5e23
jmp 0x5e4a
orq %r15, %r14
je 0x5e4a
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %rsi
addq %r13, %rsi
movq %r12, %rdi
callq 0xcd14
movq 0x28(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %rbp
jmp 0x5d3f
xorl %ebx, %ebx
jmp 0x5f20
imulq $0x14, %rbp, %rsi
addq %r13, %rsi
movq %r13, %rdi
callq 0x822a
xorl %ebx, %ebx
movq %r13, %rdi
incq %rbx
cmpq %rbp, %rbx
jae 0x5efe
leaq 0x14(%rdi), %r14
leaq 0x14(%rdi), %rsi
callq 0x7d72
movq %r14, %rdi
testb %al, %al
je 0x5e65
movslq -0x4(%r14), %rax
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
xorl %ebx, %ebx
cmpl $0x2, (%rdi)
movslq 0x10(%r14), %rax
cmovneq %rbx, %rdi
movq (%rcx,%rax,8), %r15
cmpl $0x2, (%r15)
cmovneq %rbx, %r15
leaq 0xdff0(%rip), %r12      # 0x13ea5
movq %r12, %rsi
xorl %edx, %edx
callq 0x5f34
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x5f34
movq %rax, %r15
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0xce31
leaq 0xdfc7(%rip), %rsi      # 0x13eb0
pushq $0x1
popq %rdi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x5981
jmp 0x5f20
addq $0x10, %r13
xorl %eax, %eax
movq 0x8(%rsp), %rdx
cmpq %rax, %rbp
je 0x5f1e
movslq (%r13), %rcx
movl %eax, (%rdx,%rcx,4)
incq %rax
addq $0x14, %r13
jmp 0x5f09
movb $0x1, %bl
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq