// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x827b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb850
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x80d2
movb $0x0, -0x1(%rbp)
jmp 0x8445
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
imulq $0x14, -0x30(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
leaq -0xe0(%rbp), %rdi
callq 0x16f20
movq -0x38(%rbp), %rdi
leaq 0x1c447(%rip), %rsi     # 0x24545
xorl %eax, %eax
movl %eax, %edx
callq 0x8460
movq %rax, -0xe8(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x1bdad(%rip), %rsi     # 0x23ec6
callq 0x84e0
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xe8(%rbp)
je 0x814e
movq -0xe8(%rbp), %rax
cmpb $0x0, (%rax)
je 0x814e
movq -0xe8(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x6de0
cmpq $0x0, -0xf0(%rbp)
je 0x81e4
movq $0x0, -0xf8(%rbp)
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rax
cmpq -0x100(%rbp), %rax
jae 0x81e2
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf8(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb890
movq %rax, -0x108(%rbp)
cmpq $0x0, -0x108(%rbp)
je 0x81cc
movq -0x108(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x6de0
jmp 0x81ce
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x8179
jmp 0x81e4
movq -0x38(%rbp), %rdi
leaq 0x1bcde(%rip), %rsi     # 0x23ecd
xorl %eax, %eax
movl %eax, %edx
callq 0x8460
movq %rax, -0x110(%rbp)
cmpq $0x0, -0x110(%rbp)
je 0x821c
movq -0x110(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x6de0
cmpq $0x0, -0xe8(%rbp)
je 0x8235
movq -0xe8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x8252
cmpq $0x0, -0xf0(%rbp)
jne 0x8252
cmpq $0x0, -0x110(%rbp)
jne 0x8252
movb $0x0, -0x1(%rbp)
jmp 0x8445
movq -0x20(%rbp), %rsi
imulq $0x14, -0x30(%rbp), %rax
addq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x16f70
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x809b
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rsi
imulq $0x14, -0x28(%rbp), %rax
addq %rax, %rsi
callq 0xb8d0
movq $0x1, -0x118(%rbp)
movq -0x118(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x83f2
movq -0x20(%rbp), %rdi
movq -0x118(%rbp), %rax
subq $0x1, %rax
imulq $0x14, %rax, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
imulq $0x14, -0x118(%rbp), %rax
addq %rax, %rsi
callq 0xb910
testb $0x1, %al
jne 0x82df
jmp 0x83d9
movq -0x20(%rbp), %rax
movq -0x118(%rbp), %rcx
subq $0x1, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x11c(%rbp)
movq -0x20(%rbp), %rax
imulq $0x14, -0x118(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x120(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x11c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb850
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x120(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb850
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rdi
leaq 0x1bb6b(%rip), %rsi     # 0x23ecd
xorl %eax, %eax
movl %eax, %edx
callq 0x8460
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rdi
leaq 0x1bb4d(%rip), %rsi     # 0x23ecd
xorl %eax, %eax
movl %eax, %edx
callq 0x8460
movq %rax, -0x140(%rbp)
movq -0x20(%rbp), %rsi
imulq $0x14, -0x118(%rbp), %rax
addq %rax, %rsi
leaq -0x170(%rbp), %rdi
callq 0x171b0
movq -0x138(%rbp), %rdx
movq -0x140(%rbp), %rcx
leaq -0x170(%rbp), %r8
movl $0x1, %edi
leaq 0x1bb0c(%rip), %rsi     # 0x23ed8
movb $0x0, %al
callq 0x7a60
movb $0x0, -0x1(%rbp)
jmp 0x8445
jmp 0x83db
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x829b
movq $0x0, -0x178(%rbp)
movq -0x178(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x8441
movq -0x178(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
imulq $0x14, -0x178(%rbp), %rsi
addq %rsi, %rcx
movslq 0x10(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x83fd
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)