// File: kobanium[P]Ray/src/mcts/UctRating.cpp
// Function: InputBTFMParameter(char const*, fm_t*, int)
static void
InputBTFMParameter( const char *filename, fm_t params[], const int n )
{
  FILE *fp;

#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 (int i = 0; i < n; i++) {
    if (fscanf_s(fp, "%le", &params[i].w) == EOF) {
      std::cerr << "Read Error : " << filename << std::endl;
      exit(1);
    }
    for (int j = 0; j < BTFM_DIMENSION; j++) {
      if (fscanf_s(fp, "%le", &params[i].v[j]) == 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 (int i = 0; i < n; i++) {
    if (fscanf(fp, "%le", &params[i].w) == EOF) {
      std::cerr << "Read Error : " << filename << std::endl;
      exit(1);
    }
    for (int j = 0; j < BTFM_DIMENSION; j++) {
      if (fscanf(fp, "%le", &params[i].v[j]) == 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)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x2685d(%rip), %rsi     # 0xad52b
callq 0x7680
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x86d25
movq 0x6030b(%rip), %rdi     # 0xe6ff0
leaq 0x26414(%rip), %rsi     # 0xad100
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
leaq 0x253f4(%rip), %rsi     # 0xac0fb
callq 0x7530
movq %rax, %rdi
movq 0x60252(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x86e2d
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x24(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdx
leaq 0x283cb(%rip), %rsi     # 0xaf11d
movb $0x0, %al
callq 0x7a00
cmpl $-0x1, %eax
jne 0x86d96
movq 0x6028b(%rip), %rdi     # 0xe6ff0
leaq 0x263a6(%rip), %rsi     # 0xad112
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
movq 0x601e1(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
movl $0x0, -0x28(%rbp)
cmpl $0x5, -0x28(%rbp)
jge 0x86e1d
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x24(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdx
addq $0x8, %rdx
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
leaq 0x28351(%rip), %rsi     # 0xaf11d
movb $0x0, %al
callq 0x7a00
cmpl $-0x1, %eax
jne 0x86e10
movq 0x60211(%rip), %rdi     # 0xe6ff0
leaq 0x2632c(%rip), %rsi     # 0xad112
callq 0x7530
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x7530
movq %rax, %rdi
movq 0x60167(%rip), %rsi     # 0xe6f68
callq 0x75b0
movl $0x1, %edi
callq 0x76a0
jmp 0x86e12
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x86d9d
jmp 0x86e1f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x86d2c
movq -0x20(%rbp), %rdi
callq 0x7540
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)