// File: /workspace/github_cpp_makefile_star2_O2/yuroitaki[P]enigma_machine/config.cpp
// Function: Config::check_rf_file()
void Config::check_rf_file(){
  ifstream input;
  vector<int>buffer_vec;
  int len = 0;
  int buffer;
  char charac;
  int count = 0;
  input.open(reflector_file);

  while((count<26)&&(input>>buffer)){

    input.get(charac);
    if(!isspace(charac)){
      cerr << "Non-numeric character in reflector file: reflector.rf" <<endl;
      throw NON_NUMERIC_CHARACTER;
    } 
    if((buffer<0)||(buffer>25)){
      cerr << "Invalid index in reflector file: reflector.rf" <<endl;
      throw INVALID_INDEX;
    }
    buffer_vec.push_back(buffer);
    len = buffer_vec.size();
    
    for (int i=0;i<len-1;i++){
      if(buffer_vec[i]==buffer_vec[len-1]){
	if((i%2==0)&&(len-1-i==1))
	  cerr <<"Invalid connection of reflector contact "<< buffer_vec[i] << " as it is being connected to itself" << endl;
	else
	  cerr << "Invalid connection of reflector contact "<< buffer_vec[i] << " as it is being connected to more than one other contact" << endl;
	throw INVALID_REFLECTOR_MAPPING;
      }
    }count++;
  }
  if((count==26)&&(input>>charac)){
    cerr << "Exceeded the maximum";
    throw INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS;
  }
  if((input.fail())&&(!input.eof())){
    cerr << "Non-numeric character in reflector file: reflector.rf" <<endl;
    throw NON_NUMERIC_CHARACTER;
  }
  if(count!=26){
    if(count%2!=0)
      cerr << "Incorrect (odd)"; 
    else
      cerr << "Insufficient";
    throw INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS;
  }
  input.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x2140
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq 0x20(%rbx), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x20d0
xorl %r13d, %r13d
leaq 0x30(%rsp), %rbx
leaq 0xc(%rsp), %r14
leaq 0xb(%rsp), %r15
leaq 0x10(%rsp), %r12
cmpl $0x1a, %r13d
je 0x2fd6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3000
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2170
movsbl 0xb(%rsp), %edi
callq 0x2030
testl %eax, %eax
je 0x3101
cmpl $0x1a, 0xc(%rsp)
jae 0x3120
movq %r12, %rdi
movq %r14, %rsi
callq 0x3760
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
subq %rcx, %rax
shrq $0x2, %rax
leal -0x1(%rax), %edx
movslq %edx, %rdx
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
xorl %ebp, %ebp
cmpq %rbp, %rsi
je 0x2fce
movl (%rcx,%rbp,4), %edi
cmpl (%rcx,%rdx,4), %edi
je 0x306f
incq %rbp
jmp 0x2fb8
incl %r13d
jmp 0x2f3b
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3159
leaq 0x1383(%rip), %rsi      # 0x4381
jmp 0x3016
testb $0x1, %r13b
leaq 0x1376(%rip), %rax      # 0x4381
leaq 0x135f(%rip), %rsi      # 0x4371
cmoveq %rax, %rsi
movq 0x30(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x50(%rsp,%rax), %eax
testb $0x5, %al
setne %cl
testb $0x2, %al
sete %al
testb %al, %cl
jne 0x3101
cmpl $0x1a, %r13d
jne 0x3160
leaq 0x30(%rsp), %rdi
callq 0x2040
leaq 0x10(%rsp), %rdi
callq 0x2966
leaq 0x30(%rsp), %rdi
callq 0x2050
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %bpl
jne 0x30a8
addl $-0x2, %eax
cmpl %ebp, %eax
jne 0x30a8
movq 0x3f6d(%rip), %rdi      # 0x6ff0
leaq 0x12be(%rip), %rsi      # 0x4348
callq 0x2110
movq 0x10(%rsp), %rcx
movl (%rcx,%rbp,4), %esi
movq %rax, %rdi
callq 0x21c0
leaq 0x11c2(%rip), %rsi      # 0x4268
jmp 0x30d2
movq 0x3f41(%rip), %rdi      # 0x6ff0
leaq 0x1292(%rip), %rsi      # 0x4348
callq 0x2110
movq 0x10(%rsp), %rcx
movl (%rcx,%rbp,4), %esi
movq %rax, %rdi
callq 0x21c0
leaq 0x11ba(%rip), %rsi      # 0x428c
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x4
popq %rdi
callq 0x20a0
movl $0x9, (%rax)
movq 0x3eb9(%rip), %rsi      # 0x6fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x3ee8(%rip), %rdi      # 0x6ff0
leaq 0x11d5(%rip), %rsi      # 0x42e4
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x4
jmp 0x313d
movq 0x3ec9(%rip), %rdi      # 0x6ff0
leaq 0x11ec(%rip), %rsi      # 0x431a
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x3
popq %rbx
pushq $0x4
popq %rdi
callq 0x20a0
movl %ebx, (%rax)
movq 0x3e61(%rip), %rsi      # 0x6fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
leaq 0x1165(%rip), %rsi      # 0x42c5
movq 0x3e89(%rip), %rdi      # 0x6ff0
callq 0x2110
pushq $0xa
jmp 0x313d
jmp 0x3174
jmp 0x3174
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2966
leaq 0x30(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21d0
nop