// File: /workspace/github_cpp_makefile_star2_O1/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 0x353a
movq %r14, %rdi
leaq 0xb(%rsp), %rsi
callq 0x2170
movsbl 0xb(%rsp), %edi
callq 0x2030
testl %eax, %eax
je 0x376f
movl 0x4c(%rsp), %eax
cmpl $0x1a, %eax
jae 0x37bf
cmpl $0x19, %ebp
ja 0x3489
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x34a2
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x34af
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x34e8
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x34f5
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0x3ca2
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %r13
subq %rax, %r13
shrq $0x2, %r13
cmpl $0x2, %r13d
jl 0x352a
decl %r13d
movslq %r13d, %r12
movl (%rax,%r12,4), %ecx
movl %r12d, %edx
xorl %ebx, %ebx
cmpl %ecx, (%rax,%rbx,4)
je 0x35dc
incq %rbx
cmpq %rbx, %rdx
jne 0x34d5
jmp 0x352a
leaq 0x30(%rsp), %rdi
movq %r15, %rdx
callq 0x3ca2
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl $0x2, %ecx
jl 0x352a
movslq %ecx, %rbx
decl %ecx
movl -0x4(%rax,%rbx,4), %edx
decq %rbx
xorl %esi, %esi
cmpl %edx, (%rax,%rsi,4)
je 0x36de
incq %rsi
cmpq %rsi, %rcx
jne 0x3519
incl %ebp
cmpl $0x34, %ebp
jne 0x3422
movl $0x34, %ebp
cmpl $0x34, %ebp
jne 0x3560
leaq 0x50(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x38bc
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 0x382a
cmpl $0x1a, %ebp
jbe 0x3870
leaq 0x50(%rsp), %rdi
callq 0x2040
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x35a9
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x35c0
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 0x4a0d(%rip), %rdi      # 0x7ff0
leaq 0x1dde(%rip), %rsi      # 0x53c8
movl $0x19, %edx
callq 0x2140
movq 0x49f5(%rip), %rdi      # 0x7ff0
movl %r13d, %esi
callq 0x21c0
movq %rax, %r14
leaq 0x1dd5(%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 0x1db9(%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 0x1d9b(%rip), %rsi      # 0x53f8
movl $0x21, %edx
movq %rax, %rdi
callq 0x2140
movq %r14, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rbx
leaq 0x1d9c(%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 0x1d05(%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 0x48e1(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
jmp 0x376f
movq 0x490b(%rip), %rdi      # 0x7ff0
leaq 0x1d34(%rip), %rsi      # 0x5420
movl $0x1a, %edx
callq 0x2140
movq 0x30(%rsp), %rax
movl (%rax,%rbx,4), %esi
movq 0x48eb(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1d07(%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 0x1c6f(%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 0x484b(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x487a(%rip), %rdi      # 0x7ff0
leaq 0x1c11(%rip), %rsi      # 0x538e
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x485c(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1c05(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movl $0x4, %ebp
movq %rbx, %rdi
callq 0x2080
jmp 0x380d
movq 0x482a(%rip), %rdi      # 0x7ff0
leaq 0x1be9(%rip), %rsi      # 0x53b6
movl $0x11, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x480c(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1bb5(%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 0x4790(%rip), %rsi      # 0x7fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21b0
movq 0x47bf(%rip), %rdi      # 0x7ff0
leaq 0x1b56(%rip), %rsi      # 0x538e
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x47a1(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1b4a(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x37b0
jne 0x38ff
movq 0x4773(%rip), %rdi      # 0x7ff0
leaq 0x1c00(%rip), %rsi      # 0x5484
movl $0x1a, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x4755(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1afe(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x3940
movq 0x472d(%rip), %rdi      # 0x7ff0
leaq 0x1b71(%rip), %rsi      # 0x543b
movl $0x2e, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x470f(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1ab8(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
jmp 0x3940
movq 0x46ea(%rip), %rdi      # 0x7ff0
leaq 0x1b5d(%rip), %rsi      # 0x546a
movl $0x19, %edx
callq 0x2140
movl 0xc(%rsp), %esi
incl %esi
movq 0x46cc(%rip), %rdi      # 0x7ff0
callq 0x21c0
movq %rax, %rbx
leaq 0x1a75(%rip), %rsi      # 0x53a8
movl $0xd, %edx
movq %rax, %rdi
callq 0x2140
movl $0x7, %ebp
movq %rbx, %rdi
callq 0x2080
jmp 0x380d
jmp 0x3958
jmp 0x3958
jmp 0x3958
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3972
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3989
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2120
leaq 0x50(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21d0
nop