// File: /workspace/github_cpp_makefile_star2_O1/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 0x49aed
leaq 0x14972(%rip), %rsi     # 0x5e483
movq %rdi, 0x8(%rsp)
callq 0x64e0
testq %rax, %rax
je 0x49c27
movq %rax, %r12
leaq 0x16423(%rip), %rsi     # 0x5ff51
leaq 0x4(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %rax, %rdi
xorl %eax, %eax
callq 0x67b0
cmpl $-0x1, %eax
je 0x49bde
leaq 0x163f6(%rip), %r13     # 0x5ff4d
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 0x67b0
cmpl $-0x1, %eax
je 0x49bf5
addq $0x8, %rbp
cmpq $0x30, %rbp
jne 0x49b92
incq %rbx
movq %r12, %rdi
leaq 0x16392(%rip), %rsi     # 0x5ff51
leaq 0x4(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %eax, %eax
callq 0x67b0
addq $0x30, %r15
cmpl $-0x1, %eax
jne 0x49b5e
movq %r12, %rdi
callq 0x6400
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b3ec(%rip), %rdi     # 0x74fe8
leaq 0x14467(%rip), %rsi     # 0x5e06a
callq 0x63f0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63f0
movq %rax, %rdi
callq 0x61a0
movl $0x1, %edi
callq 0x64f0
movq 0x2b3ba(%rip), %rdi     # 0x74fe8
leaq 0x14423(%rip), %rsi     # 0x5e058
callq 0x63f0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63f0
leaq 0x134ad(%rip), %rsi     # 0x5d0fb
movq %rax, %rdi
jmp 0x49c10
nop