// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: maptest_main
bool
maptest_main(int argc, char ** argv, int(*test_func)(const int, char ** const))
{
  if (argc < 4) {
    return false;
  }
  // perf
  char * const perf = getenv("MAP_TEST_PERF");
  if (perf && (strcmp(perf, "y") == 0)) {
    debug_perf_start();
  }

  if (strcmp(argv[1], "-") != 0) {
    const int fd1 = open(argv[1], O_CREAT | O_WRONLY | O_TRUNC, 00644);
    if (fd1 >= 0) {
      dup2(fd1, 1);
      close(fd1);
    }
  }

  if (strcmp(argv[2], "-") != 0) {
    const int fd2 = open(argv[2], O_CREAT | O_WRONLY | O_TRUNC, 00644);
    if (fd2 >= 0) {
      dup2(fd2, 2);
      close(fd2);
    }
  }
  // record args
  for (int i = 0; i < argc; i++) {
    fprintf(stderr, " %s", argv[i]);
  }
  fprintf(stderr, "\n");
  fflush(stderr);

  argc -= 3;
  argv += 3;

  while (argc > 0) {
    if (strcmp(argv[0], "api") != 0) {
      fprintf(stderr, "%s need `api' keyword to start benchmark\n", __func__);
      return false;
    }
    const int consume = test_func(argc, argv);
    if (consume < 0) {
      return false;
    }
    debug_assert(consume <= argc);
    argc -= consume;
    argv += consume;
  }
  debug_perf_stop();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x4, %edi
jge 0x104e6
xorl %ebx, %ebx
jmp 0x10621
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
leaq 0x21db(%rip), %rdi      # 0x126d1
callq 0x6030
testq %rax, %rax
je 0x10510
cmpb $0x79, (%rax)
jne 0x10510
cmpb $0x0, 0x1(%rax)
jne 0x10510
callq 0x7106
movq 0x8(%r14), %rdi
cmpb $0x2d, (%rdi)
jne 0x1051f
cmpb $0x0, 0x1(%rdi)
je 0x10549
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x6470
testl %eax, %eax
js 0x10549
movl %eax, %r12d
pushq $0x1
popq %rsi
movl %eax, %edi
callq 0x61a0
movl %r12d, %edi
callq 0x6220
movq 0x10(%r14), %rdi
cmpb $0x2d, (%rdi)
jne 0x10558
cmpb $0x0, 0x1(%rdi)
je 0x10582
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x6470
testl %eax, %eax
js 0x10582
movl %eax, %r12d
pushq $0x2
popq %rsi
movl %eax, %edi
callq 0x61a0
movl %r12d, %edi
callq 0x6220
movl %r15d, %eax
movq 0x8a6c(%rip), %r13      # 0x18ff8
xorl %r12d, %r12d
movq %rbx, -0x30(%rbp)
movq (%r13), %rsi
cmpq %r12, %rax
je 0x105c0
movq (%r14,%r12,8), %rdx
movq %rsi, %rdi
leaq 0x2135(%rip), %rsi      # 0x126df
movq %rax, %rbx
xorl %eax, %eax
callq 0x6300
movq %rbx, %rax
movq -0x30(%rbp), %rbx
incq %r12
jmp 0x10593
pushq $0xa
popq %rdi
callq 0x6270
movq (%r13), %rdi
callq 0x63b0
addl $-0x3, %r15d
addq $0x18, %r14
leaq 0x1f38(%rip), %r12      # 0x12518
testl %r15d, %r15d
jle 0x1061a
movq (%r14), %rdi
movq %r12, %rsi
callq 0x62f0
testl %eax, %eax
jne 0x10632
movl %r15d, %edi
movq %r14, %rsi
callq *%rbx
testl %eax, %eax
js 0x104df
movl %eax, %r13d
subl %eax, %r15d
jae 0x10611
callq 0x6e43
movl %r13d, %eax
leaq (%r14,%rax,8), %r14
jmp 0x105e0
callq 0x721b
movb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x89bf(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x20a0(%rip), %rsi      # 0x126e3
leaq 0x20c3(%rip), %rdx      # 0x1270d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x6300
jmp 0x10621