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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x266d0(%rip), %rsi     # 0xad52b
callq 0x7680
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x86eb2
movq 0x6017e(%rip), %rdi     # 0xe6ff0
leaq 0x26287(%rip), %rsi     # 0xad100
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
leaq 0x25267(%rip), %rsi     # 0xac0fb
callq 0x7530
movq %rax, %rdi
movq 0x600c5(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
movl $0x0, -0x24(%rbp)
cmpl $0x10000, -0x24(%rbp)   # imm = 0x10000
jae 0x86fc6
movq -0x18(%rbp), %rdi
leaq 0x2824c(%rip), %rsi     # 0xaf11d
leaq -0x20(%rbp), %rdx
movb $0x0, %al
callq 0x7a00
cmpl $-0x1, %eax
jne 0x86f19
movq 0x60108(%rip), %rdi     # 0xe6ff0
leaq 0x26223(%rip), %rsi     # 0xad112
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
movq 0x6005e(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movl $0x0, -0x28(%rbp)
cmpl $0x5, -0x28(%rbp)
jge 0x86fb6
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rdx
addq $0x8, %rdx
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
leaq 0x281b8(%rip), %rsi     # 0xaf11d
movb $0x0, %al
callq 0x7a00
cmpl $-0x1, %eax
jne 0x86fa9
movq 0x60078(%rip), %rdi     # 0xe6ff0
leaq 0x26193(%rip), %rsi     # 0xad112
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
movq 0x5ffce(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
jmp 0x86fab
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x86f37
jmp 0x86fb8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x86eb9
movq -0x18(%rbp), %rdi
callq 0x7540
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)