// File: WeihuaZhu[P]hpc_prog2/./gtest/gtest-all.cc
// Function: testing::internal::UnitTestImpl::RunAllTests()
bool UnitTestImpl::RunAllTests() {
  // Makes sure InitGoogleTest() was called.
  if (!GTestIsInitialized()) {
    printf("%s",
           "\nThis test program did NOT call ::testing::InitGoogleTest "
           "before calling RUN_ALL_TESTS().  Please fix it.\n");
    return false;
  }

  // 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);
#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_);

  return !failed;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
callq 0x27f00
testb $0x1, %al
jne 0x26aab
leaq 0x26c9c(%rip), %rdi     # 0x4d72f
leaq 0x26b12(%rip), %rsi     # 0x4d5ac
movb $0x0, %al
callq 0xe090
movb $0x0, 0x67(%rsp)
jmp 0x26e2d
testb $0x1, 0x3f0e7(%rip)     # 0x65b99
je 0x26abe
movb $0x1, 0x67(%rsp)
jmp 0x26e2d
movq 0x10(%rsp), %rdi
callq 0x27a80
callq 0x27f10
movq 0x10(%rsp), %rdi
movb $0x0, 0x57(%rsp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x38230
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
leaq 0x24eb5(%rip), %rdi     # 0x4b9b0
leaq 0x24ece(%rip), %rsi     # 0x4b9d0
andb $0x1, %al
movzbl %al, %edx
callq 0x20140
movq 0x10(%rsp), %rdi
andb $0x1, %al
movb %al, 0x56(%rsp)
movb 0x56(%rsp), %cl
movl $0x1, %esi
xorl %eax, %eax
testb $0x1, %cl
cmovnel %eax, %esi
callq 0x27fa0
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movb %al, 0x55(%rsp)
testb $0x1, 0x3f0a0(%rip)     # 0x65be0
je 0x26b56
movq 0x10(%rsp), %rdi
callq 0x28460
movb $0x1, 0x67(%rsp)
jmp 0x26e2d
testb $0x1, 0x3f0b8(%rip)     # 0x65c15
je 0x26b70
movl 0x3f0a7(%rip), %edi     # 0x65c0c
callq 0x38870
movl %eax, 0xc(%rsp)
jmp 0x26b78
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x26b78
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %eax
movl %eax, 0x1b4(%rdi)
movb $0x0, 0x54(%rsp)
callq 0x33330
movq %rax, %rdi
callq 0x18d20
movq %rax, 0x48(%rsp)
callq 0x19240
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x1c0(%rax)
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
testb $0x1, 0x57(%rsp)
je 0x26bd3
movl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x26bdd
movl 0x3f037(%rip), %eax     # 0x65c10
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
setl %al
andb $0x1, %al
movb %al, 0x43(%rsp)
movl $0x0, 0x3c(%rsp)
movb $0x1, %al
testb $0x1, 0x43(%rsp)
movb %al, 0x7(%rsp)
jne 0x26c17
movl 0x3c(%rsp), %eax
cmpl 0x44(%rsp), %eax
setne %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x26c24
jmp 0x26e0d
movq 0x10(%rsp), %rdi
callq 0x388c0
callq 0x19240
movq %rax, 0x30(%rsp)
testb $0x1, 0x55(%rsp)
je 0x26c6f
testb $0x1, 0x3efcf(%rip)     # 0x65c15
je 0x26c6f
movq 0x10(%rsp), %rdi
callq 0x388e0
movq %rax, %rdi
movq 0x10(%rsp), %rax
movl 0x1b4(%rax), %esi
callq 0x38900
movq 0x10(%rsp), %rdi
callq 0x28650
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movl 0x3c(%rsp), %edx
movq (%rdi), %rax
callq *0x18(%rax)
testb $0x1, 0x55(%rsp)
je 0x26d8c
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%rsp), %rdi
addq $0xa0, %rdi
leaq 0x1a97(%rip), %rsi      # 0x28750
callq 0x381e0
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x28(%rax)
callq 0x1e740
testb $0x1, %al
jne 0x26d22
movl $0x0, 0x2c(%rsp)
movq 0x10(%rsp), %rdi
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
callq 0x18e60
movl %eax, %ecx
movl (%rsp), %eax
cmpl %ecx, %eax
jge 0x26d20
movq 0x10(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x37420
movq %rax, %rdi
callq 0x1f810
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x26ce3
jmp 0x26d22
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x58(%rax)
movq 0x10(%rsp), %rsi
addq $0xa0, %rsi
leaq 0x20(%rsp), %rdi
callq 0x38990
movq 0x10(%rsp), %rsi
addq $0xa0, %rsi
leaq 0x18(%rsp), %rdi
callq 0x389e0
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x19fd(%rip), %rdx      # 0x28770
callq 0x38920
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x60(%rax)
callq 0x19240
movq %rax, %rcx
movq 0x10(%rsp), %rax
subq 0x30(%rsp), %rcx
movq %rcx, 0x1c8(%rax)
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movl 0x3c(%rsp), %edx
movq (%rdi), %rax
callq *0x68(%rax)
movq 0x10(%rsp), %rdi
callq 0x37320
testb $0x1, %al
jne 0x26dcb
movb $0x1, 0x54(%rsp)
movq 0x10(%rsp), %rdi
callq 0x28790
testb $0x1, 0x3ee39(%rip)     # 0x65c15
je 0x26dfb
movq 0x10(%rsp), %rax
movl 0x1b4(%rax), %edi
callq 0x38a30
movl %eax, %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x1b4(%rax)
jmp 0x26dfd
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x26bfb
movq 0x10(%rsp), %rax
movq 0x48(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
callq *0x70(%rax)
movb 0x54(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x67(%rsp)
movb 0x67(%rsp), %al
andb $0x1, %al
addq $0x68, %rsp
retq
nopl (%rax,%rax)