// File: /workspace/github_cpp_makefile_star2_O3/ndsol[P]git-mine/git-mine.cpp
// Function: main
int main(int argc, char ** argv) {
  if (argc != 3 && argc != 1) {
    // This utility must be called from a post-commit hook
    // with $GIT_TOPLEVEL as the only argument.
    fprintf(stderr, "Usage: %s [ atime_hint ctime_hint ]\n",
            argv[0]);
    return 1;
  }
  long long atime_hint = 0;
  long long ctime_hint = 0;
  if (argc == 3) {
    int n;
    if (sscanf(argv[1], "%lld%n", &atime_hint, &n) != 1 ||
        (int)strlen(argv[1]) != n) {
      fprintf(stderr, "Invalid atime_hint: \"%s\"\n", argv[2]);
      return 1;
    }
    if (sscanf(argv[2], "%lld%n", &ctime_hint, &n) != 1 ||
        (int)strlen(argv[2]) != n) {
      fprintf(stderr, "Invalid ctime_hint: \"%s\"\n", argv[2]);
      return 1;
    }
  }

  MineBoss boss;
  boss.atime_hint = atime_hint;
  boss.ctime_hint = ctime_hint;
  {
    FILE* f = stdin;
    CommitReader reader(argv[0]);
    if (reader.read_from(f, &boss.orig)) {
      return 1;
    }
    Sha1Hash sha;
    Blake2Hash b2h;
    if (boss.orig.hash(sha, b2h)) {
      return 1;
    }
    char shabuf[1024];
    if (sha.dump(shabuf, sizeof(shabuf))) {
      return 1;
    }
    fprintf(stderr, "Signing commit: %s\n", shabuf);
  }

  boss.start();
  for (size_t i = 90;;) {
    if (boss.printProgressAt1Hz()) break;
    i--;
    i++;
    if (!i) {
      fprintf(stderr, "\ntimed out\n");
      break;
    }
  }
  if (boss.getSearchDone()) {
    boss.commitMatch();
  }
  boss.stop();
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
movq %rsi, %r14
movl %edi, %eax
andl $-0x3, %eax
cmpl $0x1, %eax
jne 0x551d
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
cmpl $0x3, %edi
jne 0x539a
movq 0x8(%r14), %rdi
leaq 0x5d37(%rip), %rsi      # 0xb05d
leaq 0x10(%rsp), %rdx
leaq 0x260(%rsp), %rcx
xorl %eax, %eax
callq 0x3210
cmpl $0x1, %eax
jne 0x5527
movq 0x8(%r14), %rdi
callq 0x3100
cmpl %eax, 0x260(%rsp)
jne 0x5527
movq 0x10(%r14), %rdi
leaq 0x5cf9(%rip), %rsi      # 0xb05d
leaq 0x8(%rsp), %rdx
leaq 0x260(%rsp), %rcx
xorl %eax, %eax
callq 0x3210
movq 0x10(%r14), %rbx
cmpl $0x1, %eax
jne 0x5531
movq %rbx, %rdi
callq 0x3100
cmpl %eax, 0x260(%rsp)
jne 0x5531
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rax
movups %xmm0, -0x28(%rax)
xorl %r15d, %r15d
movq %r15, -0x18(%rax)
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x198(%rsp), %rbx
movq %r15, -0x8(%rbx)
movups %xmm0, -0x18(%rbx)
movups %xmm0, -0x28(%rbx)
movups %xmm0, -0x38(%rbx)
movq %rbx, %rdi
callq 0x3330
movw $0x0, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
movq %r15, 0x48(%rbx)
movq 0x10(%rsp), %rax
movq %rax, -0x48(%rbx)
movq 0x8(%rsp), %rax
movq %rax, -0x40(%rbx)
movq 0x9b44(%rip), %rax      # 0xefc8
movq (%rax), %rsi
movq (%r14), %rax
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x20(%rsp), %rdx
callq 0x5602
testl %eax, %eax
jne 0x54e9
xorl %eax, %eax
leaq 0x1e8(%rsp), %rsi
movb %al, 0x74(%rsi)
leaq 0x668(%rsp), %rdx
movb %al, 0x40(%rdx)
leaq 0x20(%rsp), %rdi
callq 0x58a4
testl %eax, %eax
jne 0x54e9
leaq 0x260(%rsp), %rdi
leaq 0x1e8(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
movl $0x14, %ecx
callq 0x9bb4
testl %eax, %eax
je 0x5553
movl $0x1, %ebp
leaq 0x1d0(%rsp), %rdi
callq 0x7ed6
movq %rbx, %rdi
callq 0x34a0
leaq 0x20(%rsp), %rdi
callq 0x5f6e
movl %ebp, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x34f0
jmp 0x554c
movq %r14, %rdi
callq 0x350e
jmp 0x554c
movq 0x9aa0(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x5b3c(%rip), %rsi      # 0xb07e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3340
movl $0x1, %ebp
jmp 0x550d
movq 0x9a7e(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x5b34(%rip), %rsi      # 0xb098
leaq 0x260(%rsp), %rdx
xorl %eax, %eax
callq 0x3340
leaq 0x20(%rsp), %rdi
callq 0x5986
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x5c3c
testl %eax, %eax
je 0x5582
leaq 0x170(%rsp), %rax
leaq 0x260(%rsp), %rdi
movq %rax, (%rdi)
movb $0x0, 0x8(%rdi)
callq 0x6d1e
leaq 0x260(%rsp), %rdi
movb $0x1, 0x8(%rdi)
movb 0x1c9(%rsp), %bpl
callq 0x6d08
cmpb $0x1, %bpl
jne 0x55d3
leaq 0x20(%rsp), %rdi
callq 0x5e3e
xorl %ebp, %ebp
leaq 0x20(%rsp), %rdi
callq 0x5e9a
jmp 0x54ee
jmp 0x55ec
jmp 0x55ec
jmp 0x55ec
jmp 0x55ec
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5f48
movq %rbx, %rdi
callq 0x3480
nop