// File: /workspace/github_cpp_makefile_star2_O3/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, 0xc(%rsp)
movq %rsi, %rbx
leaq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x2130
xorl %ebp, %ebp
movq %rbp, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rbp, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x20c0
leaq 0x50(%rsp), %r14
leaq 0x4c(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x20b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x34a3
movq %r14, %rdi
leaq 0xb(%rsp), %rsi
callq 0x2170
movsbl 0xb(%rsp), %edi
callq 0x2030
testl %eax, %eax
je 0x36b2
movl 0x4c(%rsp), %eax
cmpl $0x1a, %eax
jae 0x3702
cmpl $0x19, %ebp
ja 0x33d5
movq 0x18(%rsp), %r13
cmpq 0x20(%rsp), %r13
je 0x33ee
movl %eax, (%r13)
addq $0x4, %r13
movq %r13, 0x18(%rsp)
jmp 0x3403
movq 0x38(%rsp), %rbx
cmpq 0x40(%rsp), %rbx
je 0x3434
movl %eax, (%rbx)
addq $0x4, %rbx
movq %rbx, 0x38(%rsp)
jmp 0x3449
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3be0
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rax
subq %rax, %r13
shrq $0x2, %r13
cmpl $0x2, %r13d
jl 0x3472
decl %r13d
movl %r13d, %r12d
movl (%rax,%r12,4), %ecx
xorl %ebx, %ebx
cmpl %ecx, (%rax,%rbx,4)
je 0x351f
incq %rbx
cmpq %rbx, %r12
jne 0x3421
jmp 0x3472
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3be0
movq 0x38(%rsp), %rbx
movq 0x30(%rsp), %rax
subq %rax, %rbx
shrq $0x2, %rbx
cmpl $0x2, %ebx
jl 0x3472
decl %ebx
movl (%rax,%rbx,4), %ecx
xorl %edx, %edx
cmpl %ecx, (%rax,%rdx,4)
je 0x3621
incq %rdx
cmpq %rdx, %rbx
jne 0x3461
incl %ebp
cmpl $0x34, %ebp
jne 0x336c
leaq 0x50(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl $0x34, %ebp
testb $0x5, 0x20(%rax,%rcx)
je 0x383e
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x70(%rsp,%rax), %eax
testb $0x5, %al
sete %cl
andl $0x2, %eax
shrl %eax
orb %cl, %al
je 0x376d
cmpl $0x1a, %ebp
jbe 0x37b3
leaq 0x50(%rsp), %rdi
callq 0x2040
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x34ec
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3503
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
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 0x4aca(%rip), %rdi      # 0x7ff0
leaq 0x1e9b(%rip), %rsi      # 0x53c8
movl $0x19, %edx
callq 0x2140
movq 0x4ab2(%rip), %rdi      # 0x7ff0
movl %r13d, %esi
callq 0x21c0
movq %rax, %r14
leaq 0x1e92(%rip), %rsi      # 0x53e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x2140
movq 0x10(%rsp), %rax
movl (%rax,%r12,4), %esi
movq %r14, %rdi
callq 0x21c0
movq %rax, %r14
leaq 0x1e76(%rip), %rsi      # 0x53ee
movl $0x9, %edx
movq %rax, %rdi
callq 0x2140
movq 0x10(%rsp), %rax
movl (%rax,%r12,4), %esi
movq %r14, %rdi
callq 0x21c0
movq %rax, %r14
leaq 0x1e58(%rip), %rsi      # 0x53f8
movl $0x21, %edx
movq %rax, %rdi
callq 0x2140
movq %r14, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rbx
leaq 0x1e59(%rip), %rsi      # 0x541a
movl $0x5, %edx
movq %rax, %rdi
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq %rbx, %rdi
callq 0x21c0
movq %rax, %rbx
leaq 0x1dc2(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x2080
movl $0x4, %edi
callq 0x2090
movl $0x7, (%rax)
movq 0x499e(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
jmp 0x36b2
movq 0x49c8(%rip), %rdi      # 0x7ff0
leaq 0x1df1(%rip), %rsi      # 0x5420
movl $0x1a, %edx
callq 0x2140
movq 0x30(%rsp), %rax
movl (%rax,%rbx,4), %esi
movq 0x49a8(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1dc4(%rip), %rsi      # 0x541b
movl $0x4, %edx
movq %rax, %rdi
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq %rbx, %rdi
callq 0x21c0
movq %rax, %rbx
leaq 0x1d2c(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x2080
movl $0x4, %edi
callq 0x2090
movl $0x7, (%rax)
movq 0x4908(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x4937(%rip), %rdi      # 0x7ff0
leaq 0x1cce(%rip), %rsi      # 0x538e
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x4919(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1cc2(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movl $0x4, %ebp
movq %rbx, %rdi
callq 0x2080
jmp 0x3750
movq 0x48e7(%rip), %rdi      # 0x7ff0
leaq 0x1ca6(%rip), %rsi      # 0x53b6
movl $0x11, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x48c9(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1c72(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movl $0x3, %ebp
movq %rbx, %rdi
callq 0x2080
movl $0x4, %edi
callq 0x2090
movl %ebp, (%rax)
movq 0x484d(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x487c(%rip), %rdi      # 0x7ff0
leaq 0x1c13(%rip), %rsi      # 0x538e
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x485e(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1c07(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x36f3
jne 0x37fb
movq 0x4834(%rip), %rdi      # 0x7ff0
leaq 0x1cc1(%rip), %rsi      # 0x5484
movl $0x1a, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x4816(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1bbf(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x387f
movq 0x47ee(%rip), %rdi      # 0x7ff0
leaq 0x1c61(%rip), %rsi      # 0x546a
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x47d0(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1b79(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x387f
movq 0x47ab(%rip), %rdi      # 0x7ff0
leaq 0x1bef(%rip), %rsi      # 0x543b
movl $0x2e, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x478d(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1b36(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movl $0x7, %ebp
movq %rbx, %rdi
callq 0x2080
jmp 0x3750
jmp 0x3897
jmp 0x3897
jmp 0x3897
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x38b1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x38c8
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
leaq 0x50(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21d0