// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x6e4e0
movq 0x5e11e(%rip), %rdi     # 0xc1860
callq 0x6bda0
movl %eax, -0x40(%rbp)
movq 0x5e117(%rip), %rdi     # 0xc1868
callq 0x6bda0
movl %eax, -0x3c(%rbp)
movq 0x5e110(%rip), %rdi     # 0xc1870
callq 0x6bda0
movl %eax, -0x38(%rbp)
movq 0x5e111(%rip), %rdi     # 0xc1880
callq 0x6bda0
movl %eax, -0x4c(%rbp)
movq 0x5e10a(%rip), %rdi     # 0xc1888
callq 0x6bda0
movl %eax, -0x48(%rbp)
movq 0x5e103(%rip), %rdi     # 0xc1890
callq 0x6bda0
movl %eax, -0x44(%rbp)
movq 0x5e104(%rip), %rdi     # 0xc18a0
callq 0x6bda0
movl %eax, -0x54(%rbp)
movq 0x5e0fd(%rip), %rdi     # 0xc18a8
callq 0x6bda0
movl %eax, -0x50(%rbp)
movl $0x3, -0xa0(%rbp)
movl $0x3, -0x9c(%rbp)
movl $0x2, -0x98(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x4c(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x54(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x60(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x641a0
leaq -0xd0(%rbp), %rdi
callq 0x641d0
leaq -0xa0(%rbp), %rdi
leaq -0x31(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x6f140
movq -0xb8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
imulq $0xc, -0xb0(%rbp), %rax
addq %rax, %rsi
callq 0x64200
movq -0xd0(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x64240
movb $0x0, -0xd2(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x6395b
movq -0xb8(%rbp), %rdi
movq -0x18(%rbp), %rsi
imulq $0xc, -0x20(%rbp), %rdx
callq 0xe2f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x63959
movq -0xc8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x63957
movq $0x0, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x63941
movq -0x28(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x64280
movq -0xe8(%rbp), %rdi
movq (%rax), %rsi
callq 0xf060
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x6392b
jmp 0x63941
jmp 0x6392d
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x638dc
movq -0xe0(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x63955
movb $0x1, -0xd2(%rbp)
jmp 0x63957
jmp 0x63959
jmp 0x6395b
leaq -0xd0(%rbp), %rdi
leaq -0x31(%rbp), %rsi
callq 0x642a0
leaq -0xb8(%rbp), %rdi
leaq -0x31(%rbp), %rsi
callq 0x64300
leaq -0x31(%rbp), %rdi
callq 0x6e4f0
movb -0xd2(%rbp), %al
andb $0x1, %al
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop