// File: halfflat[P]tinyopt/test/googletest/googletest/src/gtest.cc
// Function: testing::internal::UnitTestImpl::FilterTests(testing::internal::UnitTestImpl::ReactionToSharding)
int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
  const int32_t total_shards = shard_tests == HONOR_SHARDING_PROTOCOL
                                   ? Int32FromEnvOrDie(kTestTotalShards, -1)
                                   : -1;
  const int32_t shard_index = shard_tests == HONOR_SHARDING_PROTOCOL
                                  ? Int32FromEnvOrDie(kTestShardIndex, -1)
                                  : -1;

  const PositiveAndNegativeUnitTestFilter gtest_flag_filter(
      GTEST_FLAG_GET(filter));
  const UnitTestFilter disable_test_filter(kDisableTestFilter);
  // num_runnable_tests are the number of tests that will
  // run across all shards (i.e., match filter and are not disabled).
  // num_selected_tests are the number of tests to be run on
  // this shard.
  int num_runnable_tests = 0;
  int num_selected_tests = 0;
  for (auto* test_suite : test_suites_) {
    const std::string& test_suite_name = test_suite->name();
    test_suite->set_should_run(false);

    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
      TestInfo* const test_info = test_suite->test_info_list()[j];
      const std::string test_name(test_info->name());
      // A test is disabled if test suite name or test name matches
      // kDisableTestFilter.
      const bool is_disabled =
          disable_test_filter.MatchesName(test_suite_name) ||
          disable_test_filter.MatchesName(test_name);
      test_info->is_disabled_ = is_disabled;

      const bool matches_filter =
          gtest_flag_filter.MatchesTest(test_suite_name, test_name);
      test_info->matches_filter_ = matches_filter;

      const bool is_runnable =
          (GTEST_FLAG_GET(also_run_disabled_tests) || !is_disabled) &&
          matches_filter;

      const bool is_in_another_shard =
          shard_tests != IGNORE_SHARDING_PROTOCOL &&
          !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
      test_info->is_in_another_shard_ = is_in_another_shard;
      const bool is_selected = is_runnable && !is_in_another_shard;

      num_runnable_tests += is_runnable;
      num_selected_tests += is_selected;

      test_info->should_run_ = is_selected;
      test_suite->set_should_run(test_suite->should_run() || is_selected);
    }
  }
  return num_selected_tests;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x9bd2c
leaq 0x30b26(%rip), %rdi     # 0xcc840
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8be40
movl %eax, -0x1dc(%rbp)
jmp 0x9bd39
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1dc(%rbp)
jmp 0x9bd39
movl -0x1dc(%rbp), %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x9bd61
leaq 0x30b11(%rip), %rdi     # 0xcc860
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8be40
movl %eax, -0x1e0(%rbp)
jmp 0x9bd6e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1e0(%rbp)
jmp 0x9bd6e
movl -0x1e0(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq 0x7bd7a(%rip), %rsi     # 0x117af8
leaq -0xb8(%rbp), %rdi
callq 0x82bf0
leaq -0x129(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x10e10
movq -0x1e8(%rbp), %rdx
leaq 0x30b15(%rip), %rsi     # 0xcc8c0
leaq -0x128(%rbp), %rdi
callq 0x1d070
jmp 0x9bdb9
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x827f0
jmp 0x9bdce
leaq -0x128(%rbp), %rdi
callq 0x10fc8
leaq -0x129(%rbp), %rdi
callq 0x10810
movq -0x1d8(%rbp), %rax
movl $0x0, -0x140(%rbp)
movl $0x0, -0x144(%rbp)
addq $0xb8, %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdi
callq 0xab030
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
callq 0xab720
movq %rax, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xab750
testb $0x1, %al
jne 0x9be50
jmp 0x9c2cd
leaq -0x158(%rbp), %rdi
callq 0xab790
movq (%rax), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdi
callq 0xa8fe0
movq %rax, -0x1f0(%rbp)
jmp 0x9be7b
leaq -0x191(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x10e10
movq -0x1f0(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x1d070
jmp 0x9beaa
leaq -0x191(%rbp), %rdi
callq 0x10810
leaq -0x190(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x168(%rbp), %rdi
xorl %esi, %esi
callq 0xab7b0
jmp 0x9bed4
movq $0x0, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x168(%rbp), %rdi
callq 0xab7d0
movq %rax, -0x200(%rbp)
jmp 0x9bf02
movq -0x200(%rbp), %rdi
callq 0xa89d0
movq %rax, %rcx
movq -0x208(%rbp), %rax
cmpq %rcx, %rax
jae 0x9c2a2
movq -0x168(%rbp), %rdi
callq 0xab7d0
movq %rax, -0x210(%rbp)
jmp 0x9bf36
movq -0x210(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0xa8b20
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rdi
callq 0xa3360
movq %rax, -0x218(%rbp)
jmp 0x9bf68
leaq -0x1c9(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x10e10
movq -0x218(%rbp), %rsi
movq -0x220(%rbp), %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x1d070
jmp 0x9bf97
leaq -0x1c9(%rbp), %rdi
callq 0x10810
movq -0x170(%rbp), %rsi
leaq -0x108(%rbp), %rdi
callq 0x82ab0
movb %al, -0x221(%rbp)
jmp 0x9bfbe
movb -0x221(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x222(%rbp)
jne 0x9bffc
jmp 0x9bfd3
leaq -0x108(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x82ab0
movb %al, -0x223(%rbp)
jmp 0x9bfee
movb -0x223(%rbp), %al
movb %al, -0x222(%rbp)
jmp 0x9bffc
movb -0x222(%rbp), %al
andb $0x1, %al
movb %al, -0x1ca(%rbp)
movb -0x1ca(%rbp), %cl
movq -0x1a8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x81(%rax)
movq -0x170(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
leaq -0x1c8(%rbp), %rdx
callq 0x82f50
movb %al, -0x224(%rbp)
jmp 0x9c042
movb -0x224(%rbp), %al
andb $0x1, %al
movb %al, -0x1cb(%rbp)
movb -0x1cb(%rbp), %cl
movq -0x1a8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x82(%rax)
testb $0x1, 0x7ba66(%rip)     # 0x117ad3
jne 0x9c080
xorl %eax, %eax
testb $0x1, -0x1ca(%rbp)
movb %al, -0x225(%rbp)
jne 0x9c08c
movb -0x1cb(%rbp), %al
movb %al, -0x225(%rbp)
movb -0x225(%rbp), %al
andb $0x1, %al
movb %al, -0x1cc(%rbp)
xorl %eax, %eax
cmpl $0x1, -0xc(%rbp)
movb %al, -0x226(%rbp)
je 0x9c0c1
movl -0x10(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x140(%rbp), %edx
callq 0x9ca40
xorb $-0x1, %al
movb %al, -0x226(%rbp)
movb -0x226(%rbp), %al
andb $0x1, %al
movb %al, -0x1cd(%rbp)
movb -0x1cd(%rbp), %cl
movq -0x1a8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x83(%rax)
xorl %eax, %eax
testb $0x1, -0x1cc(%rbp)
movb %al, -0x227(%rbp)
je 0x9c104
movb -0x1cd(%rbp), %al
xorb $-0x1, %al
movb %al, -0x227(%rbp)
movb -0x227(%rbp), %al
andb $0x1, %al
movb %al, -0x1ce(%rbp)
movzbl -0x1cc(%rbp), %ecx
andl $0x1, %ecx
movl -0x140(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x140(%rbp)
movzbl -0x1ce(%rbp), %ecx
andl $0x1, %ecx
movl -0x144(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x144(%rbp)
movb -0x1ce(%rbp), %cl
movq -0x1a8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x80(%rax)
movq -0x168(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0xa9190
movb %al, -0x228(%rbp)
jmp 0x9c173
movb -0x228(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x231(%rbp)
jne 0x9c194
jmp 0x9c188
movb -0x1ce(%rbp), %al
movb %al, -0x231(%rbp)
movq -0x230(%rbp), %rdi
movb -0x231(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0xab7b0
jmp 0x9c1ae
leaq -0x1c8(%rbp), %rdi
callq 0x10fc8
movq -0x1a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1a0(%rbp)
jmp 0x9bedf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
jmp 0x9c203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x10fc8
leaq -0x129(%rbp), %rdi
callq 0x10810
jmp 0x9c30c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
jmp 0x9c300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x191(%rbp), %rdi
callq 0x10810
jmp 0x9c300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
jmp 0x9c2bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x1c9(%rbp), %rdi
callq 0x10810
jmp 0x9c2bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x10fc8
jmp 0x9c2bf
leaq -0x190(%rbp), %rdi
callq 0x10fc8
leaq -0x158(%rbp), %rdi
callq 0xab7f0
jmp 0x9be34
leaq -0x190(%rbp), %rdi
callq 0x10fc8
jmp 0x9c300
movl -0x144(%rbp), %eax
movl %eax, -0x238(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x82b30
leaq -0xb8(%rbp), %rdi
callq 0x83010
movl -0x238(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x108(%rbp), %rdi
callq 0x82b30
leaq -0xb8(%rbp), %rdi
callq 0x83010
movq -0x138(%rbp), %rdi
callq 0x10e00
nopw %cs:(%rax,%rax)