// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
movq %rsi, %rbx
movl %edi, %eax
andl $-0x3, %eax
cmpl $0x1, %eax
jne 0x379b
andq $0x0, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
cmpl $0x3, %edi
jne 0x36f7
movq 0x8(%rbx), %rdi
leaq 0x69da(%rip), %rsi      # 0xa05d
leaq 0x10(%rsp), %rdx
leaq 0x260(%rsp), %rcx
xorl %eax, %eax
callq 0x3230
cmpl $0x1, %eax
jne 0x37b1
movq 0x8(%rbx), %rdi
callq 0x3100
cmpl %eax, 0x260(%rsp)
jne 0x37b1
movq 0x10(%rbx), %rdi
leaq 0x699c(%rip), %rsi      # 0xa05d
leaq 0x8(%rsp), %rdx
leaq 0x260(%rsp), %rcx
xorl %eax, %eax
callq 0x3230
movq 0x10(%rbx), %r14
cmpl $0x1, %eax
jne 0x37c8
movq %r14, %rdi
callq 0x3100
cmpl %eax, 0x260(%rsp)
jne 0x37c8
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x386a
movq 0x10(%rsp), %rax
movq %rax, 0x130(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0x138(%r14)
movq 0xb8a5(%rip), %rax      # 0xefc8
movq (%rax), %rsi
movq (%rbx), %rax
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movq %r14, %rdx
callq 0x38bc
testl %eax, %eax
jne 0x3781
xorl %eax, %eax
leaq 0x1e8(%rsp), %rsi
movb %al, 0x74(%rsi)
leaq 0x668(%rsp), %rdx
movb %al, 0x40(%rdx)
leaq 0x20(%rsp), %rdi
callq 0x3b5e
testl %eax, %eax
jne 0x3781
leaq 0x1e8(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x3c08
testl %eax, %eax
je 0x37e8
pushq $0x1
popq %rbx
leaq 0x20(%rsp), %rdi
callq 0x42a0
movl %ebx, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r14
retq
movq 0xb836(%rip), %rax      # 0xefd8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x6889(%rip), %rsi      # 0xa038
jmp 0x37dc
movq 0xb820(%rip), %rax      # 0xefd8
movq (%rax), %rdi
movq 0x10(%rbx), %rdx
leaq 0x689e(%rip), %rsi      # 0xa064
jmp 0x37dc
movq 0xb809(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x68a5(%rip), %rsi      # 0xa07e
movq %r14, %rdx
xorl %eax, %eax
callq 0x33a0
pushq $0x1
popq %rbx
jmp 0x378e
movq 0xb7e9(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x689f(%rip), %rsi      # 0xa098
leaq 0x260(%rsp), %rdx
xorl %eax, %eax
callq 0x33a0
leaq 0x20(%rsp), %rdi
callq 0x3c1c
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x3f28
testl %eax, %eax
je 0x3817
leaq 0x20(%rsp), %rdi
callq 0x4138
testb %al, %al
je 0x383b
leaq 0x20(%rsp), %rdi
callq 0x416e
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0x41f0
jmp 0x3784
jmp 0x3854
jmp 0x3854
jmp 0x3854
jmp 0x3854
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x42a0
movq %rbx, %rdi
callq 0x34b0
nop