// File: /workspace/github_cpp_makefile_star2_O2/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
cmpq $0x1000000, %rax        # imm = 0x1000000
je 0x324fe
andq $0x0, (%r14,%rax)
orl $-0x1, 0x8(%r14,%rax)
addq $0x10, %rax
jmp 0x324e5
leaq 0x12f9e(%rip), %rsi     # 0x454a3
movq %rdi, 0x8(%rsp)
callq 0x64a0
testq %rax, %rax
je 0x325f1
movq %rax, %r12
leaq 0x14aab(%rip), %rbp     # 0x46fcd
movq 0x10(%rsp), %r15
xorl %r13d, %r13d
movq %r12, %rdi
leaq 0x14a9d(%rip), %rsi     # 0x46fd1
leaq 0x4(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %eax, %eax
callq 0x6780
cmpl $-0x1, %eax
je 0x325aa
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
shlq $0x4, %rcx
movq %rax, (%r14,%rcx)
movl %r13d, 0x8(%r14,%rcx)
movsd 0x18(%rsp), %xmm0
imulq $0x30, %r13, %rax
movq 0x10(%rsp), %rcx
movsd %xmm0, (%rcx,%rax)
pushq $0x8
popq %rdx
leaq 0x8(%rdx), %rbx
cmpq $0x38, %rbx
je 0x325a1
addq %r15, %rdx
movq %r12, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6780
movq %rbx, %rdx
cmpl $-0x1, %eax
jne 0x3257d
jmp 0x325c1
incq %r13
addq $0x30, %r15
jmp 0x3252a
movq %r12, %rdi
callq 0x63d0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ea28(%rip), %rdi     # 0x60ff0
leaq 0x12abb(%rip), %rsi     # 0x4508a
callq 0x63c0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63c0
movq %rax, %rdi
callq 0x6190
pushq $0x1
popq %rdi
callq 0x64b0
movq 0x2e9f8(%rip), %rdi     # 0x60ff0
leaq 0x12a79(%rip), %rsi     # 0x45078
callq 0x63c0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x63c0
leaq 0x11ae3(%rip), %rsi     # 0x440fb
movq %rax, %rdi
jmp 0x325dc
nop