// File: /workspace/github_cpp_makefile_star2_O3/kobanium[P]Ray/src/mcts/UctRating.cpp
// Function: InputLargePattern(char const*, fm_t*, index_hash_t*)
static void 
InputLargePattern( const char *filename, fm_t params[], index_hash_t pat_index[] )
{
  FILE *fp;
  int index, idx = 0;
  unsigned long long hash;
  double weight;

  for (int i = 0; i < HASH_MAX; i++) {
    pat_index[i].hash = 0;
    pat_index[i].index = -1;
  }

#if defined (_WIN32)
  errno_t err = fopen_s(&fp, filename, "r");
  if (err != 0) {
    std::cerr << "can not open -" << filename << "-" << std::endl;
    exit(1);
  }
  while (fscanf_s(fp, "%d%llu%le", &index, &hash, &weight) != EOF) {
    pat_index[index].hash = hash;
    pat_index[index].index = idx;
    params[idx].w = weight;
    for (int i = 0; i < BTFM_DIMENSION; i++) {
      if (fscanf_s(fp, "%le", &params[idx].v[i]) == EOF) {
        std::cerr << "Read Error : " << filename << std::endl;
        exit(1);
      }
    }
    idx++;
  }
#else
  fp = fopen(filename, "r");
  if (fp == NULL) {
    std::cerr << "can not open -" << filename << "-" << std::endl;
    exit(1);
  }
  while (fscanf(fp, "%d%llu%le", &index, &hash, &weight) != EOF) {
    pat_index[index].hash = hash;
    pat_index[index].index = idx;
    params[idx].w = weight;
    for (int i = 0; i < BTFM_DIMENSION; i++) {
      if (fscanf(fp, "%le", &params[idx].v[i]) == EOF) {
        std::cerr << "Read Error : " << filename << std::endl;
        exit(1);
      }
    }
    idx++;
  }
#endif
  fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, 0x10(%rsp)
xorl %eax, %eax
movq $0x0, (%r14,%rax)
movl $0xffffffff, 0x8(%r14,%rax) # imm = 0xFFFFFFFF
addq $0x10, %rax
cmpq $0x1000000, %rax        # imm = 0x1000000
jne 0x49d5c
leaq 0x14703(%rip), %rsi     # 0x5e483
movq %rdi, 0x8(%rsp)
callq 0x64d0
testq %rax, %rax
je 0x49e96
movq %rax, %r12
leaq 0x16284(%rip), %rsi     # 0x60021
leaq 0x4(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %rax, %rdi
xorl %eax, %eax
callq 0x67a0
cmpl $-0x1, %eax
je 0x49e4d
leaq 0x16257(%rip), %r13     # 0x6001d
movq 0x10(%rsp), %r15
xorl %ebx, %ebx
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movq %rax, (%r14,%rcx)
movl %ebx, 0x8(%r14,%rcx)
movsd 0x18(%rsp), %xmm0
leaq (%rbx,%rbx,2), %rax
shlq $0x4, %rax
movq 0x10(%rsp), %rcx
movsd %xmm0, (%rcx,%rax)
movl $0x8, %ebp
leaq (%r15,%rbp), %rdx
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x67a0
cmpl $-0x1, %eax
je 0x49e64
addq $0x8, %rbp
cmpq $0x30, %rbp
jne 0x49e01
incq %rbx
movq %r12, %rdi
leaq 0x161f3(%rip), %rsi     # 0x60021
leaq 0x4(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %eax, %eax
callq 0x67a0
addq $0x30, %r15
cmpl $-0x1, %eax
jne 0x49dcd
movq %r12, %rdi
callq 0x63f0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c17d(%rip), %rdi     # 0x75fe8
leaq 0x141f8(%rip), %rsi     # 0x5e06a
callq 0x63e0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63e0
movq %rax, %rdi
callq 0x6190
movl $0x1, %edi
callq 0x64e0
movq 0x2c14b(%rip), %rdi     # 0x75fe8
leaq 0x141b4(%rip), %rsi     # 0x5e058
callq 0x63e0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63e0
leaq 0x1323e(%rip), %rsi     # 0x5d0fb
movq %rax, %rdi
jmp 0x49e7f