// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]tundra/unittest/Test_TargetSelect.cpp
// Function: TargetSelectTest::RunTest(char const**, int, t2::TargetSpec const*, unsigned long, char const**, unsigned long)
static bool RunTest(
      const char** names, int name_count,
      const TargetSpec* expected_specs, size_t expected_spec_count,
      const char** expected_names, size_t expected_name_count)
  {
    MemAllocHeap heap;
    HeapInit(&heap);

    uint32_t config_hashes[ARRAY_SIZE(s_Configs)]         = { Djb2Hash(s_Configs[0]), Djb2Hash(s_Configs[1]), Djb2Hash(s_Configs[2]) };
    uint32_t variant_hashes[ARRAY_SIZE(s_Variants)]       = { Djb2Hash(s_Variants[0]), Djb2Hash(s_Variants[1]), Djb2Hash(s_Variants[2]) };
    uint32_t subvariant_hashes[ARRAY_SIZE(s_SubVariants)] = { Djb2Hash(s_SubVariants[0]), Djb2Hash(s_SubVariants[1]) };

    TargetSelectInput input;
    input.m_ConfigCount = ARRAY_SIZE(config_hashes);
    input.m_VariantCount = ARRAY_SIZE(variant_hashes);
    input.m_SubVariantCount = ARRAY_SIZE(subvariant_hashes);
    input.m_ConfigNameHashes = config_hashes;
    input.m_VariantNameHashes = variant_hashes;
    input.m_SubVariantNameHashes = subvariant_hashes;

    input.m_InputNameCount = name_count;
    input.m_InputNames = names;

    input.m_DefaultConfigIndex = 0;
    input.m_DefaultVariantIndex = 0;
    input.m_DefaultSubVariantIndex = 0;

    Buffer<TargetSpec> specs;
    Buffer<const char*> target_names;

    BufferInit(&specs);
    BufferInit(&target_names);

    SelectTargets(input, &heap, &specs, &target_names);

    std::sort(specs.m_Storage, specs.m_Storage + specs.m_Size);
    std::sort(target_names.m_Storage, target_names.m_Storage + target_names.m_Size, [](const char* l, const char* r) { return strcmp(l, r) < 0; });

    bool success = false;

    if (specs.m_Size == expected_spec_count)
    {
      if (0 == memcmp(specs.m_Storage, expected_specs, sizeof(TargetSpec) * expected_spec_count))
      {
        if (target_names.m_Size == expected_name_count)
        {
          size_t i = 0;
          for ( ; i < expected_name_count; ++i)
          {
            if (0 != strcmp(expected_names[i], target_names[i]))
            {
              break;
            }
          }

          if (i == expected_name_count)
          {
            success = true;
          }
        }
      }
    }

    BufferDestroy(&target_names, &heap);
    BufferDestroy(&specs, &heap);

    HeapDestroy(&heap);

    return success;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, %r12
movq %rdx, 0x58(%rsp)
movl %esi, %r15d
movq %rdi, %rbp
leaq 0xf(%rsp), %rdi
callq 0x42d9c
leaq 0x190e2(%rip), %rdi     # 0x56896
callq 0x418a4
leaq 0x74(%rsp), %r13
movl %eax, (%r13)
leaq 0x1928c(%rip), %rdi     # 0x56a55
callq 0x418a4
movl %eax, 0x4(%r13)
leaq 0x191a3(%rip), %rdi     # 0x5697c
callq 0x418a4
movl %eax, 0x8(%r13)
leaq 0x1919d(%rip), %rdi     # 0x56986
callq 0x418a4
leaq 0x68(%rsp), %r14
movl %eax, (%r14)
leaq 0x191c1(%rip), %rdi     # 0x569be
callq 0x418a4
movl %eax, 0x4(%r14)
leaq 0x1917f(%rip), %rdi     # 0x5698c
callq 0x418a4
movl %eax, 0x8(%r14)
leaq 0x191f3(%rip), %rdi     # 0x56a10
callq 0x418a4
leaq 0x60(%rsp), %rbx
movl %eax, (%rbx)
leaq 0x191b8(%rip), %rdi     # 0x569e8
callq 0x418a4
movl %eax, 0x4(%rbx)
movabsq $0x300000003, %rax      # imm = 0x300000003
leaq 0x80(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, 0x8(%rdi)
movq %r13, 0x10(%rdi)
movq %r14, 0x18(%rdi)
movq %rbx, 0x20(%rdi)
movl %r15d, 0x28(%rdi)
movq %rbp, 0x30(%rdi)
xorl %eax, %eax
movq %rax, 0x38(%rdi)
movl $0x0, 0x40(%rdi)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r15
movaps %xmm0, (%r15)
movq %rax, 0x10(%r15)
leaq 0x10(%rsp), %rcx
movaps %xmm0, (%rcx)
movq %rax, 0x10(%rcx)
leaq 0xf(%rsp), %rsi
movq %r15, %rdx
callq 0x43384
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3d8d7
movq 0x30(%rsp), %r15
leaq (%rax,%rax,2), %rcx
leaq (%r15,%rcx,4), %r13
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x3db58
movq %r15, %rdi
movq %r13, %rsi
callq 0x3dc17
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x3d90d
movq 0x10(%rsp), %r15
leaq (%r15,%rax,8), %r13
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x3e10b
movq %r15, %rdi
movq %r13, %rsi
callq 0x3e1ba
cmpq %r12, 0x38(%rsp)
jne 0x3d96d
movq 0x30(%rsp), %rdi
shlq $0x2, %r12
leaq (%r12,%r12,2), %rdx
movq 0x58(%rsp), %rsi
callq 0xc630
xorl %ebp, %ebp
testl %eax, %eax
jne 0x3d97b
movq 0x50(%rsp), %rbx
cmpq %rbx, 0x18(%rsp)
jne 0x3d97b
testq %rbx, %rbx
je 0x3d971
movq 0x10(%rsp), %r15
xorl %r14d, %r14d
movq 0x48(%rsp), %r12
movq (%r12,%r14,8), %rdi
movq (%r15,%r14,8), %rsi
callq 0xc900
testl %eax, %eax
jne 0x3d974
incq %r14
cmpq %r14, %rbx
jne 0x3d94f
movq %rbx, %r14
jmp 0x3d974
xorl %ebp, %ebp
jmp 0x3d97b
xorl %r14d, %r14d
cmpq %rbx, %r14
sete %bpl
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x3d9a0
leaq 0xf(%rsp), %rdi
callq 0x42da6
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x3d9c5
leaq 0xf(%rsp), %rdi
callq 0x42da6
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0xf(%rsp), %rdi
callq 0x42d9d
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop