// File: /workspace/github_c_makefile_star2_O3/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 %rdi, (%rsp)
movq 0x8(%rdi), %r12
movb $0x1, %r13b
testq %r12, %r12
je 0x6314
movq %rdx, %r14
movq %rsi, 0x8(%rsp)
xorl %r13d, %r13d
movq %rdx, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq (%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r13,8), %r15
cmpl $0x2, (%r15)
jne 0x6311
leaq (,%r13,4), %rax
addq %r13, %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x10(%r14,%rax,4)
leaq 0x30(%rsp), %rdi
callq 0xdc4a
movq %r15, %rdi
leaq 0x1036c(%rip), %rsi     # 0x16500
xorl %edx, %edx
callq 0x63a8
movq %rax, %rbx
movq %r15, %rdi
leaq 0xfcf8(%rip), %rsi      # 0x15ea0
callq 0x6414
movq %rax, %rbp
testq %rbx, %rbx
je 0x61d2
cmpb $0x0, (%rbx)
je 0x61d2
movq %rbx, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xdb34
movq %rbx, 0x28(%rsp)
testq %rbp, %rbp
je 0x6218
movq 0x8(%rbp), %r14
testq %r14, %r14
je 0x6218
xorl %ebx, %ebx
movq 0x10(%rbp), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x4, (%rax)
jne 0x6210
movq 0x8(%rax), %r12
movq %r12, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xdb34
incq %rbx
cmpq %rbx, %r14
jne 0x61e7
movq %r15, %rdi
leaq 0xfc85(%rip), %rsi      # 0x15ea7
xorl %edx, %edx
callq 0x63a8
movq %rax, %r15
testq %rax, %rax
je 0x6249
movq %r15, %rdi
callq 0x3150
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xdb34
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x6267
testq %r15, %r15
jne 0x6270
testq %rbp, %rbp
jne 0x6270
cmpb $0x0, (%rax)
jne 0x6270
jmp 0x6311
orq %r15, %rbp
je 0x6311
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %rax
leaq (%r14,%rax,4), %rsi
leaq 0x30(%rsp), %rdi
callq 0xdc61
incq %r13
movq 0x10(%rsp), %r12
cmpq %r12, %r13
jne 0x6155
leaq (%r12,%r12,4), %rax
leaq (%r14,%rax,4), %rbx
bsrq %r12, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b67
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8c26
cmpq $0x1, %r12
movb $0x1, %r13b
movq 0x8(%rsp), %rdx
je 0x62f7
leaq -0x1(%r12), %rax
leaq 0x14(%r14), %rbx
movq -0x14(%rbx), %rcx
cmpq (%rbx), %rcx
jne 0x62ee
movq 0x8(%rbx), %rcx
cmpq %rcx, -0xc(%rbx)
je 0x6329
addq $0x14, %rbx
decq %rax
jne 0x62db
addq $0x10, %r14
xorl %eax, %eax
movslq (%r14), %rcx
movl %eax, (%rdx,%rcx,4)
incq %rax
addq $0x14, %r14
cmpq %rax, %r12
jne 0x62fd
jmp 0x6314
xorl %r13d, %r13d
movl %r13d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq -0x4(%rbx), %rax
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
xorl %r13d, %r13d
cmpl $0x2, (%rdi)
movslq 0x10(%rbx), %rax
cmovneq %r13, %rdi
movq (%rcx,%rax,8), %r14
cmpl $0x2, (%r14)
cmovneq %r13, %r14
leaq 0xfb4d(%rip), %r15      # 0x15ea7
movq %r15, %rsi
xorl %edx, %edx
callq 0x63a8
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x63a8
movq %rax, %r14
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xddf3
leaq 0xfb24(%rip), %rsi      # 0x15eb2
movl $0x1, %edi
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x5d74
jmp 0x6314