// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, (%rsp)
movq 0x8(%rdi), %r15
testq %r15, %r15
je 0x6438
xorl %r12d, %r12d
movq %rbx, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r12,8), %r14
cmpl $0x2, (%r14)
jne 0x6494
leaq (%r12,%r12,4), %rax
movq %rax, 0x20(%rsp)
movl %r12d, 0x10(%rbx,%rax,4)
leaq 0x30(%rsp), %rdi
callq 0xe17e
movq %r14, %rdi
leaq 0x10208(%rip), %rsi     # 0x16510
xorl %edx, %edx
callq 0x6529
movq %rax, %rbx
movq %r14, %rdi
leaq 0xfb94(%rip), %rsi      # 0x15eb0
callq 0x65a4
movq %rax, %r13
testq %rbx, %rbx
je 0x6346
cmpb $0x0, (%rbx)
je 0x6346
movq %rbx, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xe068
movq %rbx, 0x28(%rsp)
testq %r13, %r13
je 0x638c
movq 0x8(%r13), %rbp
testq %rbp, %rbp
je 0x638c
xorl %ebx, %ebx
movq 0x10(%r13), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x4, (%rax)
jne 0x6384
movq 0x8(%rax), %r15
movq %r15, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xe068
incq %rbx
cmpq %rbx, %rbp
jne 0x635b
movq %r14, %rdi
leaq 0xfb21(%rip), %rsi      # 0x15eb7
xorl %edx, %edx
callq 0x6529
movq %rax, %r14
testq %rax, %rax
je 0x63bd
movq %r14, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xe068
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x63db
testq %r14, %r14
jne 0x63e4
testq %r13, %r13
jne 0x63e4
cmpb $0x0, (%rax)
jne 0x63e4
jmp 0x6494
orq %r14, %r13
je 0x6494
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rax
leaq (%rbx,%rax,4), %rsi
leaq 0x30(%rsp), %rdi
callq 0xe195
incq %r12
movq 0x10(%rsp), %r15
cmpq %r15, %r12
jne 0x62d0
leaq (%r15,%r15,4), %rax
leaq (%rbx,%rax,4), %r14
bsrq %r15, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8f05
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8fc4
cmpq $0x2, %r15
jb 0x6466
leaq -0x1(%r15), %rax
leaq 0x14(%rbx), %r12
movq -0x14(%r12), %rcx
cmpq (%r12), %rcx
jne 0x645d
movq 0x8(%r12), %rcx
cmpq %rcx, -0xc(%r12)
je 0x6499
addq $0x14, %r12
decq %rax
jne 0x6446
movb $0x1, %r14b
testq %r15, %r15
je 0x6514
addq $0x10, %rbx
xorl %eax, %eax
movq 0x8(%rsp), %rdx
movslq (%rbx), %rcx
movl %eax, (%rdx,%rcx,4)
incq %rax
addq $0x14, %rbx
cmpq %rax, %r15
jne 0x647d
jmp 0x6514
xorl %r14d, %r14d
jmp 0x6514
movslq -0x4(%r12), %rax
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
xorl %r14d, %r14d
cmpl $0x2, (%rdi)
movslq 0x10(%r12), %rax
cmovneq %r14, %rdi
movq (%rcx,%rax,8), %rbx
cmpl $0x2, (%rbx)
cmovneq %r14, %rbx
leaq 0xf9ec(%rip), %r15      # 0x15eb7
movq %r15, %rsi
xorl %edx, %edx
callq 0x6529
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x6529
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xe2cf
leaq 0xf9c3(%rip), %rsi      # 0x15ec2
movl $0x1, %edi
movq %r13, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x5ef0
movl %r14d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq