// File: /workspace/github_cpp_makefile_star2_O2/halfflat[P]tinyopt/test/googletest/googletest/src/gtest.cc
// Function: testing::internal::UnitTestImpl::RunAllTests()
bool UnitTestImpl::RunAllTests() {
  // True if and only if Google Test is initialized before RUN_ALL_TESTS() is
  // called.
  const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();

  // Do not run any test if the --help flag was specified.
  if (g_help_flag) return true;

  // Repeats the call to the post-flag parsing initialization in case the
  // user didn't call InitGoogleTest.
  PostFlagParsingInit();

#if GTEST_HAS_FILE_SYSTEM
  // Even if sharding is not on, test runners may want to use the
  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
  // protocol.
  internal::WriteToShardStatusFileIfNeeded();
#endif  // GTEST_HAS_FILE_SYSTEM

  // True if and only if we are in a subprocess for running a thread-safe-style
  // death test.
  bool in_subprocess_for_death_test = false;

#ifdef GTEST_HAS_DEATH_TEST
  in_subprocess_for_death_test = (internal_run_death_test_flag_ != nullptr);
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
  if (in_subprocess_for_death_test) {
    GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
  }
#endif  // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
#endif  // GTEST_HAS_DEATH_TEST

  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
                                        in_subprocess_for_death_test);

  // Compares the full test names with the filter to decide which
  // tests to run.
  const bool has_tests_to_run =
      FilterTests(should_shard ? HONOR_SHARDING_PROTOCOL
                               : IGNORE_SHARDING_PROTOCOL) > 0;

  // Lists the tests and exits if the --gtest_list_tests flag was specified.
  if (GTEST_FLAG_GET(list_tests)) {
    // This must be called *after* FilterTests() has been called.
    ListTestsMatchingFilter();
    return true;
  }

  random_seed_ = GetRandomSeedFromFlag(GTEST_FLAG_GET(random_seed));

  // True if and only if at least one test has failed.
  bool failed = false;

  TestEventListener* repeater = listeners()->repeater();

  start_timestamp_ = GetTimeInMillis();
  repeater->OnTestProgramStart(*parent_);

  // How many times to repeat the tests?  We don't want to repeat them
  // when we are inside the subprocess of a death test.
  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG_GET(repeat);

  // Repeats forever if the repeat count is negative.
  const bool gtest_repeat_forever = repeat < 0;

  // Should test environments be set up and torn down for each repeat, or only
  // set up on the first and torn down on the last iteration? If there is no
  // "last" iteration because the tests will repeat forever, always recreate the
  // environments to avoid leaks in case one of the environments is using
  // resources that are external to this process. Without this check there would
  // be no way to clean up those external resources automatically.
  const bool recreate_environments_when_repeating =
      GTEST_FLAG_GET(recreate_environments_when_repeating) ||
      gtest_repeat_forever;

  for (int i = 0; gtest_repeat_forever || i != repeat; i++) {
    // We want to preserve failures generated by ad-hoc test
    // assertions executed before RUN_ALL_TESTS().
    ClearNonAdHocTestResult();

    Timer timer;

    // Shuffles test suites and tests if requested.
    if (has_tests_to_run && GTEST_FLAG_GET(shuffle)) {
      random()->Reseed(static_cast<uint32_t>(random_seed_));
      // This should be done before calling OnTestIterationStart(),
      // such that a test event listener can see the actual test order
      // in the event.
      ShuffleTests();
    }

    // Tells the unit test event listeners that the tests are about to start.
    repeater->OnTestIterationStart(*parent_, i);

    // Runs each test suite if there is at least one test to run.
    if (has_tests_to_run) {
      // Sets up all environments beforehand. If test environments aren't
      // recreated for each iteration, only do so on the first iteration.
      if (i == 0 || recreate_environments_when_repeating) {
        repeater->OnEnvironmentsSetUpStart(*parent_);
        ForEach(environments_, SetUpEnvironment);
        repeater->OnEnvironmentsSetUpEnd(*parent_);
      }

      // Runs the tests only if there was no fatal failure or skip triggered
      // during global set-up.
      if (Test::IsSkipped()) {
        // Emit diagnostics when global set-up calls skip, as it will not be
        // emitted by default.
        TestResult& test_result =
            *internal::GetUnitTestImpl()->current_test_result();
        for (int j = 0; j < test_result.total_part_count(); ++j) {
          const TestPartResult& test_part_result =
              test_result.GetTestPartResult(j);
          if (test_part_result.type() == TestPartResult::kSkip) {
            const std::string& result = test_part_result.message();
            printf("%s\n", result.c_str());
          }
        }
        fflush(stdout);
      } else if (!Test::HasFatalFailure()) {
        for (int test_index = 0; test_index < total_test_suite_count();
             test_index++) {
          GetMutableSuiteCase(test_index)->Run();
          if (GTEST_FLAG_GET(fail_fast) &&
              GetMutableSuiteCase(test_index)->Failed()) {
            for (int j = test_index + 1; j < total_test_suite_count(); j++) {
              GetMutableSuiteCase(j)->Skip();
            }
            break;
          }
        }
      } else if (Test::HasFatalFailure()) {
        // If there was a fatal failure during the global setup then we know we
        // aren't going to run any tests. Explicitly mark all of the tests as
        // skipped to make this obvious in the output.
        for (int test_index = 0; test_index < total_test_suite_count();
             test_index++) {
          GetMutableSuiteCase(test_index)->Skip();
        }
      }

      // Tears down all environments in reverse order afterwards. If test
      // environments aren't recreated for each iteration, only do so on the
      // last iteration.
      if (i == repeat - 1 || recreate_environments_when_repeating) {
        repeater->OnEnvironmentsTearDownStart(*parent_);
        std::for_each(environments_.rbegin(), environments_.rend(),
                      TearDownEnvironment);
        repeater->OnEnvironmentsTearDownEnd(*parent_);
      }
    }

    elapsed_time_ = timer.Elapsed();

    // Tells the unit test event listener that the tests have just finished.
    repeater->OnTestIterationEnd(*parent_, i);

    // Gets the result and clears it.
    if (!Passed()) {
      failed = true;
    }

    // Restores the original test order after the iteration.  This
    // allows the user to quickly repro a failure that happens in the
    // N-th iteration without repeating the first (N - 1) iterations.
    // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
    // case the user somehow changes the value of the flag somewhere
    // (it's always safe to unshuffle the tests).
    UnshuffleTests();

    if (GTEST_FLAG_GET(shuffle)) {
      // Picks a new random seed for each iteration.
      random_seed_ = GetNextRandomSeed(random_seed_);
    }
  }

  repeater->OnTestProgramEnd(*parent_);
  // Destroy environments in normal code, not in static teardown.
  bool delete_environment_on_teardown = true;
  if (delete_environment_on_teardown) {
    ForEach(environments_, internal::Delete<Environment>);
    environments_.clear();
  }

  if (!gtest_is_initialized_before_run_all_tests) {
    ColoredPrintf(
        GTestColor::kRed,
        "\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
        "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
        "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
        " will start to enforce the valid usage. "
        "Please fix it ASAP, or IT WILL START TO FAIL.\n");  // NOLINT
  }

  return !failed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x497e8
movb $0x1, %r15b
cmpb $0x0, 0x3c07f(%rip)     # 0x848e1
jne 0x48c89
movl %eax, %ebp
movq %rbx, %rdi
callq 0x49556
callq 0x49815
movq 0x238(%rbx), %r14
xorl %edx, %edx
testq %r14, %r14
setne %dl
leaq 0x11593(%rip), %rdi     # 0x59e20
leaq 0x115ac(%rip), %rsi     # 0x59e40
callq 0x41879
xorb $0x1, %al
movzbl %al, %esi
movq %rbx, %rdi
callq 0x49888
movl %eax, 0x1c(%rsp)
cmpb $0x1, 0x3c078(%rip)     # 0x84929
jne 0x488c0
movq %rbx, %rdi
callq 0x49ac4
jmp 0x48c89
movb %bpl, 0xa(%rsp)
movl 0x3c089(%rip), %edi     # 0x84954
callq 0x4ee75
movl %eax, 0x21c(%rbx)
movq 0x1f8(%rbx), %r15
callq 0x3d5b6
movq %rax, 0x228(%rbx)
movq 0x8(%rbx), %rsi
movq (%r15), %rax
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq *0x10(%rax)
pushq $0x1
popq %rax
movl %eax, %edx
testq %r14, %r14
jne 0x4890b
movl 0x3c04d(%rip), %edx     # 0x84958
testl %edx, %edx
sets %al
orb 0x3c046(%rip), %al      # 0x8495c
movb %al, 0x9(%rsp)
leaq 0xa0(%rbx), %rax
movq %rax, 0x20(%rsp)
leal -0x1(%rdx), %eax
movl %eax, 0x18(%rsp)
xorl %ebp, %ebp
pushq $0x70
popq %r12
xorl %r15d, %r15d
movq 0x10(%rsp), %r14
movq %rdx, 0x28(%rsp)
testl %edx, %edx
sets %al
cmpl %edx, %ebp
setne %cl
orb %al, %cl
je 0x48c35
movq %rbx, %rdi
callq 0x4ee94
callq 0xd830
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x48a02
cmpb $0x1, 0x3bfe8(%rip)     # 0x8495e
jne 0x4898c
movl 0x21c(%rbx), %eax
movl %eax, 0x220(%rbx)
movq %rbx, %rdi
callq 0x49de4
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
movl %ebp, %edx
callq *0x18(%rax)
testl %ebp, %ebp
sete %al
orb 0x9(%rsp), %al
testb $0x1, %al
je 0x489d3
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq 0x20(%rsp), %rdi
leaq 0x14a2(%rip), %rsi      # 0x49e63
callq 0x4ecb9
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
callq 0x40784
testb %al, %al
movl %r15d, 0xc(%rsp)
je 0x48a16
callq 0x4c032
movq 0x170(%rax), %r14
testq %r14, %r14
je 0x48aee
addq $0x90, %r14
jmp 0x48b0c
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
movl %ebp, %edx
callq *0x18(%rax)
jmp 0x48bcd
callq 0x40744
testb %al, %al
je 0x48a62
callq 0x40744
testb %al, %al
je 0x48b6d
xorl %r14d, %r14d
movq 0xc0(%rbx), %rax
subq 0xb8(%rbx), %rax
shrq $0x3, %rax
cmpl %eax, %r14d
jge 0x48b6d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4e7be
movq %rax, %rdi
callq 0x412c8
incl %r14d
jmp 0x48a2f
xorl %r15d, %r15d
pushq $0x1
popq %r14
movq 0xc0(%rbx), %rax
subq 0xb8(%rbx), %rax
shrq $0x3, %rax
cmpl %eax, %r15d
jge 0x48b6d
movq %rbx, %rdi
movl %r15d, %esi
callq 0x4e7be
movq %rax, %rdi
callq 0x410b4
cmpb $0x1, 0x3be44(%rip)     # 0x848e2
jne 0x48ab7
movq %rbx, %rdi
movl %r15d, %esi
callq 0x4e7be
movq %rax, %rdi
callq 0x4eea8
testb %al, %al
jne 0x48ad5
incl %r15d
incl %r14d
jmp 0x48a69
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4e7be
movq %rax, %rdi
callq 0x412c8
incl %r14d
movq 0xc0(%rbx), %rax
subq 0xb8(%rbx), %rax
shrq $0x3, %rax
cmpl %eax, %r14d
jl 0x48abf
jmp 0x48b6d
movq 0x168(%rax), %r14
testq %r14, %r14
je 0x48b03
addq $0x88, %r14
jmp 0x48b0c
addq $0x178, %rax            # imm = 0x178
movq %rax, %r14
xorl %r15d, %r15d
movq 0x40(%r14), %rax
subq 0x38(%r14), %rax
cqto
idivq %r12
cmpl %eax, %r15d
jge 0x48b5e
movq %r14, %rdi
movl %r15d, %esi
callq 0x3fadc
cmpl $0x3, (%rax)
jne 0x48b59
movq 0x50(%rax), %rsi
leaq 0x38(%rsp), %r13
movq %r13, %rdi
leaq 0xb(%rsp), %rdx
callq 0x1337a
movq 0x38(%rsp), %rdi
callq 0xd9a0
movq %r13, %rdi
callq 0xdbe8
incl %r15d
jmp 0x48b0f
movq 0x3b41b(%rip), %rax     # 0x83f80
movq (%rax), %rdi
callq 0xd6b0
cmpl 0x18(%rsp), %ebp
sete %al
orb 0x9(%rsp), %al
testb $0x1, %al
movl 0xc(%rsp), %r15d
movq 0x10(%rsp), %r14
je 0x48bcd
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x70(%rax)
movq 0xa0(%rbx), %r14
movq 0xa8(%rbx), %r15
cmpq %r14, %r15
je 0x48bb6
movq -0x8(%r15), %rdi
addq $-0x8, %r15
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x48ba1
movq 0x8(%rbx), %rsi
movq 0x10(%rsp), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x78(%rax)
movl 0xc(%rsp), %r15d
leaq 0x30(%rsp), %rdi
callq 0x4e2fc
movq %rax, 0x230(%rbx)
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
movl %ebp, %edx
callq *0x80(%rax)
movq %rbx, %rdi
callq 0x4e75e
movl %eax, %r14d
movq %rbx, %rdi
callq 0x49e6a
cmpb $0x1, 0x3bd54(%rip)     # 0x8495e
jne 0x48c1d
movl 0x21c(%rbx), %edi
callq 0x4eec9
movl %eax, 0x21c(%rbx)
xorb $0x1, %r14b
orb %r14b, %r15b
incl %ebp
movq 0x28(%rsp), %rdx
movq 0x10(%rsp), %r14
jmp 0x48940
movq 0x8(%rbx), %rsi
movq (%r14), %rax
movq %r14, %rdi
callq *0x88(%rax)
leaq 0x60a(%rip), %rsi       # 0x49256
movq 0x20(%rsp), %rdi
callq 0x4ecb9
movq 0xa0(%rbx), %rax
cmpq %rax, 0xa8(%rbx)
je 0x48c6d
movq %rax, 0xa8(%rbx)
cmpb $0x0, 0xa(%rsp)
jne 0x48c85
leaq 0x13bda(%rip), %rsi     # 0x5c855
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x41733
xorb $0x1, %r15b
andb $0x1, %r15b
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop