// File: /workspace/github_cpp_makefile_star2_O2/yuroitaki[P]enigma_machine/config.cpp
// Function: Config::check_rot_file(char const*, int)
void Config::check_rot_file(const char* rot_file,int rotor_id){
  ifstream input;
  vector<int>buffer1_vec;
  vector<int>buffer2_vec;
  int len1 = 0;
  int len2 = 0;
  int buffer;
  char charac;
  int count = 0;
  
  input.open(rot_file);

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

    input.get(charac);
    if(!isspace(charac)){
      cerr << "Non-numeric character in "<< rotor_id+1 << "th rotor file" << endl; 
      throw NON_NUMERIC_CHARACTER;
    }
    if((buffer<0)||(buffer>25)){
      cerr << "Invalid index in "<< rotor_id+1 << "th rotor file" << endl;
      throw INVALID_INDEX;
    }
    if(count < 26){                    //to check if the rotor mapping is valid
      buffer1_vec.push_back(buffer);
      len1 = buffer1_vec.size();
      
      for (int i=0;i<len1-1;i++){
	if(buffer1_vec[i]==buffer1_vec[len1-1]){
	  cerr <<"Invalid mapping of input "<< len1-1 <<" to output "<<buffer1_vec[len1-1]<<  " (output " <<buffer1_vec[len1-1] << " is already mapped to from input " << i <<") in "<< rotor_id+1 << "th rotor file" << endl;
	  throw INVALID_ROTOR_MAPPING;
	}
      }
    }else{                             //to check if the notch position is valid
      buffer2_vec.push_back(buffer);
      len2 = buffer2_vec.size();
      
      for (int i=0;i<len2-1;i++){
	if(buffer2_vec[i]==buffer2_vec[len2-1]){
	  cerr <<"Repeated placing of notch "<< buffer2_vec[len2-1] << " in " << rotor_id+1 << "th rotor file" << endl;
	  throw INVALID_ROTOR_MAPPING;
	}
      }
    }
    count++;
  }
  if((count==52)&&(input>>charac)){
    cerr << "Exceeded maximum number of notches allowed in "<< rotor_id+1 << "th rotor file" << endl;
    throw INVALID_ROTOR_MAPPING;
  }
  if((input.fail())&&(!input.eof())){
    cerr << "Non-numeric character in "<< rotor_id+1 << "th rotor file" << endl;
    throw NON_NUMERIC_CHARACTER;
  }
  if(count<27){
    if(count<26)
      cerr << "Not all inputs mapped in "<< rotor_id+1 << "th rotor file" << endl;
    else
      cerr << "Missing notch position in "<< rotor_id+1 << "th rotor file" << endl;
    throw INVALID_ROTOR_MAPPING;
  }
  input.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %edx, 0x8(%rsp)
movq %rsi, %rbx
leaq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x2140
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
pushq $0x8
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20d0
xorl %ebp, %ebp
leaq 0x50(%rsp), %r14
leaq 0xc(%rsp), %r15
cmpl $0x34, %ebp
je 0x32da
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x32fb
movq %r14, %rdi
leaq 0x7(%rsp), %rsi
callq 0x2170
movsbl 0x7(%rsp), %edi
callq 0x2030
testl %eax, %eax
je 0x349f
cmpl $0x1a, 0xc(%rsp)
jae 0x34db
cmpl $0x19, %ebp
ja 0x328a
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x3760
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %r13
subq %rax, %r13
shrq $0x2, %r13
decl %r13d
movslq %r13d, %r12
testl %r12d, %r12d
movl $0x0, %ecx
cmovgl %r13d, %ecx
xorl %ebx, %ebx
cmpq %rbx, %rcx
je 0x32d3
movl (%rax,%rbx,4), %edx
cmpl (%rax,%r12,4), %edx
je 0x335d
incq %rbx
jmp 0x3273
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x3760
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
decl %ecx
movslq %ecx, %rbx
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
shlq $0x2, %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x32d3
movl (%rax,%rdx), %esi
addq $0x4, %rdx
cmpl (%rax,%rbx,4), %esi
jne 0x32bd
jmp 0x3429
incl %ebp
jmp 0x31ec
leaq 0x50(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3545
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x70(%rsp,%rax), %eax
testb $0x5, %al
setne %cl
testb $0x2, %al
sete %al
testb %al, %cl
jne 0x349f
cmpl $0x1a, %ebp
jbe 0x3531
leaq 0x50(%rsp), %rdi
callq 0x2040
leaq 0x30(%rsp), %rdi
callq 0x2966
leaq 0x10(%rsp), %rdi
callq 0x2966
leaq 0x50(%rsp), %rdi
callq 0x2050
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3c8c(%rip), %rdi      # 0x6ff0
leaq 0x105d(%rip), %rsi      # 0x43c8
callq 0x2110
movq %rax, %rdi
movl %r13d, %esi
callq 0x21c0
leaq 0x1060(%rip), %rsi      # 0x43e2
movq %rax, %rdi
callq 0x2110
movq 0x10(%rsp), %rcx
movl (%rcx,%r12,4), %esi
movq %rax, %rdi
callq 0x21c0
leaq 0x104c(%rip), %rsi      # 0x43ee
movq %rax, %rdi
callq 0x2110
movq 0x10(%rsp), %rcx
movl (%rcx,%r12,4), %esi
movq %rax, %rdi
callq 0x21c0
leaq 0x1036(%rip), %rsi      # 0x43f8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
movl %ebx, %esi
callq 0x21c0
leaq 0x103f(%rip), %rsi      # 0x441a
movq %rax, %rdi
callq 0x2110
movl 0x8(%rsp), %esi
incl %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xfb0(%rip), %rsi       # 0x43a8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x4
popq %rdi
callq 0x20a0
movl $0x7, (%rax)
movq 0x3b93(%rip), %rsi      # 0x6fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
jmp 0x349f
movq 0x3bc0(%rip), %rdi      # 0x6ff0
leaq 0xfe9(%rip), %rsi       # 0x4420
callq 0x2110
movq 0x30(%rsp), %rcx
movl (%rcx,%rbx,4), %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xfc8(%rip), %rsi       # 0x441b
movq %rax, %rdi
callq 0x2110
movl 0x8(%rsp), %esi
incl %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xf38(%rip), %rsi       # 0x43a8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x4
popq %rdi
callq 0x20a0
movl $0x7, (%rax)
movq 0x3b1b(%rip), %rsi      # 0x6fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x3b4a(%rip), %rdi      # 0x6ff0
leaq 0xee1(%rip), %rsi       # 0x438e
callq 0x2110
movl 0x8(%rsp), %esi
incl %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xee1(%rip), %rsi       # 0x43a8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x4
jmp 0x3515
movq 0x3b0e(%rip), %rdi      # 0x6ff0
leaq 0xecd(%rip), %rsi       # 0x43b6
callq 0x2110
movl 0x8(%rsp), %esi
incl %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xea5(%rip), %rsi       # 0x43a8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x3
popq %rbx
pushq $0x4
popq %rdi
callq 0x20a0
movl %ebx, (%rax)
movq 0x3a89(%rip), %rsi      # 0x6fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
leaq 0xf4c(%rip), %rax       # 0x4484
leaq 0xf2b(%rip), %rsi       # 0x446a
cmoveq %rax, %rsi
jmp 0x354c
leaq 0xeef(%rip), %rsi       # 0x443b
movq 0x3a9d(%rip), %rdi      # 0x6ff0
callq 0x2110
movl 0x8(%rsp), %esi
incl %esi
movq %rax, %rdi
callq 0x21c0
leaq 0xe3b(%rip), %rsi       # 0x43a8
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x7
jmp 0x3515
jmp 0x3587
jmp 0x3587
jmp 0x3587
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2966
leaq 0x10(%rsp), %rdi
callq 0x2966
leaq 0x50(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21d0