// File: /workspace/github_c_makefile_star2_O3/orangeduck[P]mpc/tests/ptest.c
// Function: pt_run
int pt_run(void) {

  int i;
  double total;
  test_t test;

  puts("");
  puts("    +-------------------------------------------+");
  puts("    | ptest          MicroTesting Magic for C   |");
  puts("    |                                           |");
  puts("    | http://github.com/orangeduck/ptest        |");
  puts("    |                                           |");
  puts("    | Daniel Holden (contact@theorangeduck.com) |");
  puts("    +-------------------------------------------+");

  signal(SIGFPE,  ptest_signal);
  signal(SIGILL,  ptest_signal);
  signal(SIGSEGV, ptest_signal);

  start = clock();
  strcpy(current_suite, "");

  for(i = 0; i < num_tests; i++) {

    test = tests[i];

    /* Check for transition to a new suite */
    if (strcmp(test.suite, current_suite)) {

      /* Don't increment any counter for first entrance */
      if (strcmp(current_suite, "")) {
        if (suite_passing) {
          num_suites_passes++;
        } else {
          num_suites_fails++;
        }
      }

      suite_passing = 1;
      strcpy(current_suite, test.suite);
      printf("\n\n  ===== %s =====\n\n", current_suite);
    }

    /* Run Test */

    test_passing = 1;
    strcpy(assert_err, "");
    strcpy(assert_err_buff, "");
    assert_err_num = 0;
    printf("    | %s ... ", test.name);
    fflush(stdout);

    test.func();

    suite_passing = suite_passing && test_passing;

    if (test_passing) {
      num_tests_passes++;
      pt_color(GREEN);
      puts("Passed!");
      pt_color(DEFAULT);
    } else {
      num_tests_fails++;
      pt_color(RED);
      printf("Failed! \n\n%s\n", assert_err);
      pt_color(DEFAULT);
    }

  }

  if (suite_passing) {
    num_suites_passes++;
  } else {
    num_suites_fails++;
  }

  end = clock();

  puts("");
  puts("  +---------------------------------------------------+");
  puts("  |                      Summary                      |");
  puts("  +---------++------------+-------------+-------------+");

  printf("  | Suites  ||");
  pt_color(YELLOW);  printf(" Total %4d ",  num_suites);
  pt_color(DEFAULT); putchar('|');
  pt_color(GREEN);   printf(" Passed %4d ", num_suites_passes);
  pt_color(DEFAULT); putchar('|');
  pt_color(RED);     printf(" Failed %4d ", num_suites_fails);
  pt_color(DEFAULT); puts("|");

  printf("  | Tests   ||");
  pt_color(YELLOW);  printf(" Total %4d ",  num_tests);
  pt_color(DEFAULT); putchar('|');
  pt_color(GREEN);   printf(" Passed %4d ", num_tests_passes);
  pt_color(DEFAULT); putchar('|');
  pt_color(RED);     printf(" Failed %4d ", num_tests_fails);
  pt_color(DEFAULT); puts("|");

  printf("  | Asserts ||");
  pt_color(YELLOW);  printf(" Total %4d ",  num_asserts);
  pt_color(DEFAULT); putchar('|');
  pt_color(GREEN);   printf(" Passed %4d ", num_assert_passes);
  pt_color(DEFAULT); putchar('|');
  pt_color(RED);     printf(" Failed %4d ", num_assert_fails);
  pt_color(DEFAULT); puts("|");

  puts("  +---------++------------+-------------+-------------+");
  puts("");

  total = (double)(end - start) / CLOCKS_PER_SEC;

  printf("      Total Running Time: %0.3fs\n\n", total);

  if (num_suites_fails > 0) { return 1; } else { return 0; }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movl $0xa, %edi
callq 0x1030
leaq 0xcd17(%rip), %rbx      # 0x10fad
movq %rbx, %rdi
callq 0x1070
leaq 0xcd3a(%rip), %rdi      # 0x10fdf
callq 0x1070
leaq 0xcd60(%rip), %r14      # 0x11011
movq %r14, %rdi
callq 0x1070
leaq 0xcd83(%rip), %rdi      # 0x11043
callq 0x1070
movq %r14, %rdi
callq 0x1070
leaq 0xcda1(%rip), %rdi      # 0x11075
callq 0x1070
movq %rbx, %rdi
callq 0x1070
leaq 0x4b1(%rip), %rbx       # 0x4799
movl $0x8, %edi
movq %rbx, %rsi
callq 0x1140
movl $0x4, %edi
movq %rbx, %rsi
callq 0x1140
movl $0xb, %edi
movq %rbx, %rsi
callq 0x1140
callq 0x1090
movq %rax, 0x218f0d(%rip)    # 0x21d228
movb $0x0, 0x218f0e(%rip)    # 0x21d230
cmpl $0x0, 0x14eeb(%rip)     # 0x19214
jle 0x44a1
leaq 0x208(%rsp), %rbx
leaq 0x14ee2(%rip), %r14     # 0x19220
xorl %ebp, %ebp
leaq 0x218ee9(%rip), %r13    # 0x21d230
leaq 0xdfee(%rip), %r15      # 0x1233c
xorl %r12d, %r12d
movl $0x408, %edx            # imm = 0x408
movq %rsp, %rdi
movq %r14, %rsi
callq 0x1180
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1130
testl %eax, %eax
je 0x43ba
cmpb $0x0, 0x218eb9(%rip)    # 0x21d230
je 0x4394
cmpl $0x0, 0x2190b0(%rip)    # 0x21d430
leaq 0x2190ad(%rip), %rax    # 0x21d434
leaq 0x2190aa(%rip), %rcx    # 0x21d438
cmoveq %rcx, %rax
incl (%rax)
movl $0x1, 0x219092(%rip)    # 0x21d430
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1060
leaq 0xccf7(%rip), %rdi      # 0x110a7
movq %r13, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x1, 0x13e30(%rip)     # 0x181f4
movb %bpl, 0x14645(%rip)     # 0x18a10
movb %bpl, 0x13e2e(%rip)     # 0x18200
movl $0x0, 0x14624(%rip)     # 0x18a00
leaq 0xccd9(%rip), %rdi      # 0x110bc
leaq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x10d0
movq 0x13bea(%rip), %rax     # 0x17fe0
movq (%rax), %rdi
callq 0x11a0
callq *(%rsp)
cmpl $0x0, 0x219028(%rip)    # 0x21d430
setne %al
movl 0x13de3(%rip), %ecx     # 0x181f4
testl %ecx, %ecx
setne %dl
andb %al, %dl
movzbl %dl, %eax
movl %eax, 0x21900f(%rip)    # 0x21d430
testl %ecx, %ecx
je 0x444a
incl 0x219011(%rip)          # 0x21d43c
movq %r15, %rdi
leaq 0xce4d(%rip), %rsi      # 0x11282
xorl %eax, %eax
callq 0x10d0
leaq 0xcc87(%rip), %rdi      # 0x110ca
callq 0x1070
jmp 0x4476
incl 0x218ff0(%rip)          # 0x21d440
movq %r15, %rdi
leaq 0xce34(%rip), %rsi      # 0x1128e
xorl %eax, %eax
callq 0x10d0
leaq 0xcc6a(%rip), %rdi      # 0x110d2
leaq 0x145a1(%rip), %rsi     # 0x18a10
xorl %eax, %eax
callq 0x10d0
movq %r15, %rdi
leaq 0xce26(%rip), %rsi      # 0x112a6
xorl %eax, %eax
callq 0x10d0
incq %r12
movslq 0x14d83(%rip), %rax     # 0x19214
addq $0x408, %r14            # imm = 0x408
cmpq %rax, %r12
jl 0x4351
cmpl $0x0, 0x218f88(%rip)    # 0x21d430
leaq 0x218f89(%rip), %rax    # 0x21d438
leaq 0x218f7e(%rip), %rcx    # 0x21d434
cmoveq %rax, %rcx
incl (%rcx)
callq 0x1090
movq %rax, 0x218f80(%rip)    # 0x21d448
movl $0xa, %edi
callq 0x1030
leaq 0xcc07(%rip), %rdi      # 0x110e0
callq 0x1070
leaq 0xcc33(%rip), %rdi      # 0x11118
callq 0x1070
leaq 0xcc5f(%rip), %rdi      # 0x11150
callq 0x1070
leaq 0xcc8b(%rip), %rdi      # 0x11188
xorl %eax, %eax
callq 0x10d0
leaq 0xde31(%rip), %r14      # 0x1233c
leaq 0xcd88(%rip), %rsi      # 0x1129a
movq %r14, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x218cfe(%rip), %esi    # 0x21d220
leaq 0xcc6e(%rip), %rdi      # 0x11197
xorl %eax, %eax
callq 0x10d0
leaq 0xcd6f(%rip), %r15      # 0x112a6
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
leaq 0xcd2d(%rip), %rsi      # 0x11282
movq %r14, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x218ecf(%rip), %esi    # 0x21d434
leaq 0xcc37(%rip), %rbp      # 0x111a3
movq %rbp, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
leaq 0xccfa(%rip), %rbx      # 0x1128e
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
movl 0x218e91(%rip), %esi    # 0x21d438
leaq 0xcc02(%rip), %r12      # 0x111b0
movq %r12, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
leaq 0xca75(%rip), %r13      # 0x11041
movq %r13, %rdi
callq 0x1070
leaq 0xcbe2(%rip), %rdi      # 0x111bd
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
leaq 0xccae(%rip), %rsi      # 0x1129a
xorl %eax, %eax
callq 0x10d0
movl 0x14c1b(%rip), %esi     # 0x19214
leaq 0xcb97(%rip), %rdi      # 0x11197
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
movq %r14, %rdi
leaq 0xcc5a(%rip), %rsi      # 0x11282
xorl %eax, %eax
callq 0x10d0
movl 0x218e07(%rip), %esi    # 0x21d43c
movq %rbp, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
movl 0x218dd7(%rip), %esi    # 0x21d440
movq %r12, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movq %r13, %rdi
callq 0x1070
leaq 0xcb3d(%rip), %rdi      # 0x111cc
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
leaq 0xcbfa(%rip), %rsi      # 0x1129a
xorl %eax, %eax
callq 0x10d0
movl 0x13b43(%rip), %esi     # 0x181f0
leaq 0xcae3(%rip), %rdi      # 0x11197
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
movq %r14, %rdi
leaq 0xcba6(%rip), %rsi      # 0x11282
xorl %eax, %eax
callq 0x10d0
movl 0x13b0f(%rip), %esi     # 0x181f8
movq %rbp, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl $0x7c, %edi
callq 0x1030
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
movl 0x14af3(%rip), %esi     # 0x19210
movq %r12, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movq %r13, %rdi
callq 0x1070
leaq 0xca0d(%rip), %rdi      # 0x11150
callq 0x1070
movl $0xa, %edi
callq 0x1030
movq 0x218cef(%rip), %rax    # 0x21d448
subq 0x218ac8(%rip), %rax    # 0x21d228
cvtsi2sd %rax, %xmm0
divsd 0xc773(%rip), %xmm0     # 0x10ee0
leaq 0xca67(%rip), %rdi      # 0x111db
movb $0x1, %al
callq 0x10d0
xorl %eax, %eax
cmpl $0x0, 0x218cb4(%rip)    # 0x21d438
setg %al
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq