// File: ambersun1234[P]AVL_Tree/./googletest/googletest/src/gtest.cc
// Function: testing::internal::UnitTestImpl::RunAllTests()
bool UnitTestImpl::RunAllTests() {
  // True iff 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();

  // 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();

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

#if GTEST_HAS_DEATH_TEST
  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
# 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(list_tests)) {
    // This must be called *after* FilterTests() has been called.
    ListTestsMatchingFilter();
    return true;
  }

  random_seed_ = GTEST_FLAG(shuffle) ?
      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;

  // True iff 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(repeat);
  // Repeats forever if the repeat count is negative.
  const bool forever = repeat < 0;
  for (int i = 0; forever || i != repeat; i++) {
    // We want to preserve failures generated by ad-hoc test
    // assertions executed before RUN_ALL_TESTS().
    ClearNonAdHocTestResult();

    const TimeInMillis start = GetTimeInMillis();

    // Shuffles test cases and tests if requested.
    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
      random()->Reseed(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 case if there is at least one test to run.
    if (has_tests_to_run) {
      // Sets up all environments beforehand.
      repeater->OnEnvironmentsSetUpStart(*parent_);
      ForEach(environments_, SetUpEnvironment);
      repeater->OnEnvironmentsSetUpEnd(*parent_);

      // Runs the tests only if there was no fatal failure during global
      // set-up.
      if (!Test::HasFatalFailure()) {
        for (int test_index = 0; test_index < total_test_case_count();
             test_index++) {
          GetMutableTestCase(test_index)->Run();
        }
      }

      // Tears down all environments in reverse order afterwards.
      repeater->OnEnvironmentsTearDownStart(*parent_);
      std::for_each(environments_.rbegin(), environments_.rend(),
                    TearDownEnvironment);
      repeater->OnEnvironmentsTearDownEnd(*parent_);
    }

    elapsed_time_ = GetTimeInMillis() - start;

    // 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(shuffle)) {
      // Picks a new random seed for each iteration.
      random_seed_ = GetNextRandomSeed(random_seed_);
    }
  }

  repeater->OnTestProgramEnd(*parent_);

  if (!gtest_is_initialized_before_run_all_tests) {
    ColoredPrintf(
        COLOR_RED,
        "\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
#if GTEST_FOR_GOOGLE_
    ColoredPrintf(COLOR_RED,
                  "For more details, see http://wiki/Main/ValidGUnitMain.\n");
#endif  // GTEST_FOR_GOOGLE_
  }

  return !failed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x2c630
andb $0x1, %al
movb %al, -0x11(%rbp)
testb $0x1, 0x51864(%rip)     # 0x7c8f9
je 0x2b0a0
movb $0x1, -0x1(%rbp)
jmp 0x2b3d8
movq -0x58(%rbp), %rdi
callq 0x2c210
callq 0x2c670
movq -0x58(%rbp), %rdi
movb $0x0, -0x12(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x3d600
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, -0x12(%rbp)
movb -0x12(%rbp), %al
leaq 0x2c078(%rip), %rdi     # 0x57150
leaq 0x2c091(%rip), %rsi     # 0x57170
andb $0x1, %al
movzbl %al, %edx
callq 0x20e00
movq -0x58(%rbp), %rdi
andb $0x1, %al
movb %al, -0x13(%rbp)
movb -0x13(%rbp), %cl
movl $0x1, %esi
xorl %eax, %eax
testb $0x1, %cl
cmovnel %eax, %esi
callq 0x2c6f0
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movb %al, -0x14(%rbp)
testb $0x1, 0x51828(%rip)     # 0x7c941
je 0x2b12d
movq -0x58(%rbp), %rdi
callq 0x2cb80
movb $0x1, -0x1(%rbp)
jmp 0x2b3d8
testb $0x1, 0x51841(%rip)     # 0x7c975
je 0x2b146
movl 0x51830(%rip), %edi     # 0x7c96c
callq 0x3dcd0
movl %eax, -0x5c(%rbp)
jmp 0x2b14d
xorl %eax, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2b14d
movq -0x58(%rbp), %rdi
movl -0x5c(%rbp), %eax
movl %eax, 0x1b4(%rdi)
movb $0x0, -0x15(%rbp)
callq 0x37d10
movq %rax, %rdi
callq 0x18830
movq %rax, -0x20(%rbp)
callq 0x18e70
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x1c0(%rax)
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
testb $0x1, -0x12(%rbp)
je 0x2b1a0
movl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2b1a9
movl 0x517ca(%rip), %eax     # 0x7c970
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
setl %al
andb $0x1, %al
movb %al, -0x25(%rbp)
movl $0x0, -0x2c(%rbp)
movb $0x1, %al
testb $0x1, -0x25(%rbp)
movb %al, -0x61(%rbp)
jne 0x2b1d9
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x2b1e5
jmp 0x2b3a3
movq -0x58(%rbp), %rdi
callq 0x3dd20
callq 0x18e70
movq %rax, -0x38(%rbp)
testb $0x1, -0x14(%rbp)
je 0x2b22a
testb $0x1, 0x51771(%rip)     # 0x7c975
je 0x2b22a
movq -0x58(%rbp), %rdi
callq 0x3dd50
movq %rax, %rdi
movq -0x58(%rbp), %rax
movl 0x1b4(%rax), %esi
callq 0x3dd70
movq -0x58(%rbp), %rdi
callq 0x2d150
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq (%rdi), %rax
callq *0x18(%rax)
testb $0x1, -0x14(%rbp)
je 0x2b32d
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x58(%rbp), %rdi
addq $0xa0, %rdi
leaq 0x1fd3(%rip), %rsi      # 0x2d240
callq 0x3d5b0
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x28(%rax)
callq 0x1f560
testb $0x1, %al
jne 0x2b2cd
movl $0x0, -0x3c(%rbp)
movq -0x58(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, -0x68(%rbp)
callq 0x189a0
movl %eax, %ecx
movl -0x68(%rbp), %eax
cmpl %ecx, %eax
jge 0x2b2cb
movq -0x58(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x3c640
movq %rax, %rdi
callq 0x20600
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2b294
jmp 0x2b2cd
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x58(%rax)
movq -0x58(%rbp), %rsi
addq $0xa0, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3de00
movq -0x58(%rbp), %rsi
addq $0xa0, %rsi
leaq -0x50(%rbp), %rdi
callq 0x3de50
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq 0x1f4a(%rip), %rdx      # 0x2d260
callq 0x3dd90
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x60(%rax)
callq 0x18e70
movq %rax, %rcx
movq -0x58(%rbp), %rax
subq -0x38(%rbp), %rcx
movq %rcx, 0x1c8(%rax)
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq (%rdi), %rax
callq *0x68(%rax)
movq -0x58(%rbp), %rdi
callq 0x3c540
testb $0x1, %al
jne 0x2b366
movb $0x1, -0x15(%rbp)
movq -0x58(%rbp), %rdi
callq 0x2d280
testb $0x1, 0x515ff(%rip)     # 0x7c975
je 0x2b393
movq -0x58(%rbp), %rax
movl 0x1b4(%rax), %edi
callq 0x3dea0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x1b4(%rax)
jmp 0x2b395
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2b1c2
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x70(%rax)
testb $0x1, -0x11(%rbp)
jne 0x2b3ce
movl $0x1, %edi
leaq 0x2da95(%rip), %rsi     # 0x58e5c
movb $0x0, %al
callq 0x20c50
movb -0x15(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)