// File: /workspace/github_cpp_makefile_star2_O3/bowenfan96[P]icl-mcs-enigma/enigma.cpp
// Function: Enigma::Reflector::Reflector(char const*)
Enigma::Reflector::Reflector(const char* rf_filename) 
{
    std::ifstream rf_file;
    rf_file.open(rf_filename);
    
    if(rf_file.is_open()) {
        
        std::string index;
        int rf_num;
        int i = 0;
        size_t sz;
        
        while(std::getline(rf_file, index, ' ')) {
            
            index.erase(std::remove_if(index.begin(), index.end(), ::isspace), index.end());
            
            if(!index.empty()) {
                if(is_numeric(index)) {
                    if(is_valid(index)) {
                        rf_num = std::stoi(index, &sz);
                        if(i % 2 == 0) {
                            map_from.push_back(rf_num);
                        }
                        else {
                            map_to.push_back(rf_num);
                        }
                        i++;
                    }
                    else {
                        std::cerr << "Index in reflector file " << rf_filename << " does not correspond to an alphabet letter" << "\n";
                        throw INVALID_INDEX;
                    }
                }
                else {
                    std::cerr << "Non-numeric character in reflector file " << rf_filename << "\n";
                    throw NON_NUMERIC_CHARACTER;
                }
            }
        }
        
        // check reflector is not empty or contain only 1 parameter
        if(map_from.size() == 0 || map_to.size() == 0) {
            std::cerr << "Insufficient number of mappings in reflector file: " << rf_filename << "\n";
            throw INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS;
        }
        
        // check correct config (1 to 1 mapping, no value to itself)
        if(!is_one_to_one(map_from, map_to)) {
            std::cerr << "Malformed contact points (not linked 1 to 1) in reflector file " << rf_filename << "\n";
            throw INVALID_REFLECTOR_MAPPING;
        }
        
        // check exactly 13 pairings
        if(map_from.size() != map_to.size()) {
            std::cerr << "Incorrect (odd) number of parameters in reflector file " << rf_filename << "\n";
            throw INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS;
        }
            
        if(map_from.size() < 13 || map_to.size() < 13) {
            std::cerr << "Insufficient number of mappings in reflector file: " << rf_filename << "\n";
            throw INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS;
        }
        
        // mirror the mapping vectors
        std::vector<int> swap = map_from;
        map_from.insert(map_from.end(), map_to.begin(), map_to.end());
        map_to.insert(map_to.end(), swap.begin(), swap.end());
    }
    
    // check if file open failed
    else {
        std::cerr << "Reflector file " << rf_filename << " supplied cannot be opened" << "\n";
        throw ERROR_OPENING_CONFIGURATION_FILE;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, %r12
movq %rdi, %r13
leaq 0x18(%rdi), %rax
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
leaq -0x2a0(%rbp), %rdi
movq %r13, -0x30(%rbp)
callq 0x21c0
leaq -0x2a0(%rbp), %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x2100
leaq -0x228(%rbp), %rdi
callq 0x2050
testb %al, %al
je 0x3a08
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x20(%r13), %rax
movq %rax, -0x48(%rbp)
leaq 0x8(%r13), %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0x50(%rbp)
movq %r12, -0x38(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x20, %edx
callq 0x22c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x38c6
movq -0x78(%rbp), %r12
movq -0x70(%rbp), %rax
leaq (%r12,%rax), %rbx
movq %rax, %r13
sarq $0x2, %r13
movq %r12, %r15
testq %r13, %r13
jle 0x372e
andq $-0x4, %rax
movq %rax, %r15
addq %r12, %r15
incq %r13
leaq 0x3(%r12), %r14
movsbl -0x3(%r14), %edi
callq 0x2040
testl %eax, %eax
jne 0x3770
movsbl -0x2(%r14), %edi
callq 0x2040
testl %eax, %eax
jne 0x3776
movsbl -0x1(%r14), %edi
callq 0x2040
testl %eax, %eax
jne 0x377c
movsbl (%r14), %edi
callq 0x2040
testl %eax, %eax
jne 0x377f
decq %r13
addq $0x4, %r14
cmpq $0x1, %r13
jg 0x36ea
movq %rbx, %rax
subq %r15, %rax
cmpq $0x1, %rax
je 0x3785
cmpq $0x2, %rax
movq -0x30(%rbp), %r13
je 0x375e
cmpq $0x3, %rax
jne 0x37d3
movsbl (%r15), %edi
callq 0x2040
testl %eax, %eax
jne 0x3798
incq %r15
movsbl (%r15), %edi
callq 0x2040
testl %eax, %eax
jne 0x3798
incq %r15
jmp 0x3789
addq $-0x3, %r14
jmp 0x377f
addq $-0x2, %r14
jmp 0x377f
decq %r14
movq -0x30(%rbp), %r13
jmp 0x379b
movq -0x30(%rbp), %r13
movsbl (%r15), %edi
callq 0x2040
testl %eax, %eax
cmoveq %rbx, %r15
movq %r15, %r14
cmpq %rbx, %r14
sete %al
leaq 0x1(%r14), %r15
cmpq %rbx, %r15
sete %cl
orb %al, %cl
jne 0x37d6
movb (%r15), %r12b
movsbl %r12b, %edi
callq 0x2040
testl %eax, %eax
jne 0x37c5
movb %r12b, (%r14)
incq %r14
incq %r15
cmpq %rbx, %r15
jne 0x37af
movq -0x78(%rbp), %r12
jmp 0x37d6
movq %rbx, %r14
movq %r14, %rax
subq %r12, %rax
movq %rax, -0x70(%rbp)
movb $0x0, (%r14)
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x3696
movq -0x78(%rbp), %rcx
xorl %edx, %edx
movsbl (%rcx,%rdx), %esi
addl $-0x30, %esi
cmpl $0xa, %esi
jae 0x39aa
incq %rdx
cmpq %rdx, %rax
jne 0x37f7
leaq -0x78(%rbp), %rdi
callq 0x2b96
testb %al, %al
je 0x3b0e
movq -0x78(%rbp), %r14
callq 0x2030
movq %rax, %r15
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r14, %rdi
leaq -0x90(%rbp), %rsi
movl $0xa, %edx
callq 0x2210
cmpq %r14, -0x90(%rbp)
je 0x3b6b
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x3b77
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x3b77
testl %ecx, %ecx
jne 0x3874
movl %ebx, (%r15)
movl %eax, -0x54(%rbp)
testb $0x1, -0x50(%rbp)
jne 0x389c
movq 0x8(%r13), %rsi
movq %r13, %rdi
movq -0x98(%rbp), %rcx
cmpq 0x10(%r13), %rsi
je 0x38ae
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rcx)
jmp 0x38b7
movq 0x20(%r13), %rsi
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rcx
cmpq 0x28(%r13), %rsi
jne 0x3891
leaq -0x54(%rbp), %rdx
callq 0x499e
movq -0x50(%rbp), %rax
incl %eax
movq %rax, -0x50(%rbp)
jmp 0x3696
movq 0x8(%r13), %rax
movl $0x33, %r12d
leaq 0x2973(%rip), %r15      # 0x624a
cmpq (%r13), %rax
movq -0x40(%rbp), %rsi
je 0x3ace
movq -0x48(%rbp), %rax
movq (%rax), %rax
cmpq (%rsi), %rax
je 0x3ace
movq %r13, %rdi
callq 0x2c24
testb %al, %al
je 0x3a7b
movq 0x8(%r13), %rax
subq (%r13), %rax
movq 0x20(%r13), %rcx
subq 0x18(%r13), %rcx
cmpq %rcx, %rax
jne 0x3ac1
cmpq $0x34, %rax
jb 0x3ace
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x47e6
movq 0x8(%r13), %rsi
movq 0x18(%r13), %rdx
movq 0x20(%r13), %rcx
movq %r13, %rdi
callq 0x4ad6
movq -0x48(%rbp), %rax
movq (%rax), %rsi
movq -0x90(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0x40(%rbp), %rdi
callq 0x4ad6
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x397a
callq 0x2180
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x398c
callq 0x2180
leaq -0x2a0(%rbp), %rdi
callq 0x2060
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x563f(%rip), %rdi      # 0x8ff0
leaq 0x2869(%rip), %rsi      # 0x6221
movl $0x28, %edx
callq 0x21d0
movq 0x5627(%rip), %rdi      # 0x8ff0
movq -0x38(%rbp), %rsi
callq 0x21a0
movl $0x4, %ebx
leaq 0x2686(%rip), %rsi      # 0x6064
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movl $0x4, %edi
callq 0x20c0
movl %ebx, (%rax)
movq 0x55b2(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2290
movq 0x55e1(%rip), %rdi      # 0x8ff0
leaq 0x28e0(%rip), %rsi      # 0x62f6
movl $0xf, %edx
callq 0x21d0
movq 0x55c9(%rip), %rdi      # 0x8ff0
movq %r12, %rsi
callq 0x21a0
movq %rax, %r15
leaq 0x26d8(%rip), %rsi      # 0x6111
movl $0x1a, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x2617(%rip), %rsi      # 0x6064
movl $0x1, %edx
movq %r15, %rdi
callq 0x21d0
movl $0x4, %edi
callq 0x20c0
movl $0xb, (%rax)
movq 0x553f(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2290
movq 0x556e(%rip), %rdi      # 0x8ff0
leaq 0x27f5(%rip), %rsi      # 0x627e
movl $0x3f, %edx
callq 0x21d0
movq 0x5556(%rip), %rdi      # 0x8ff0
movq -0x38(%rbp), %rsi
callq 0x21a0
movl $0x9, %ebx
leaq 0x25b5(%rip), %rsi      # 0x6064
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
jmp 0x39eb
movl $0x37, %r12d
leaq 0x27f0(%rip), %r15      # 0x62be
movq 0x551b(%rip), %rdi      # 0x8ff0
movq %r15, %rsi
movq %r12, %rdx
callq 0x21d0
movq 0x5509(%rip), %rdi      # 0x8ff0
movq -0x38(%rbp), %rsi
callq 0x21a0
movl $0xa, %ebx
leaq 0x2568(%rip), %rsi      # 0x6064
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
jmp 0x39eb
movq 0x54db(%rip), %rdi      # 0x8ff0
leaq 0x26ec(%rip), %rsi      # 0x6208
movl $0x18, %edx
callq 0x21d0
movq 0x54c3(%rip), %rdi      # 0x8ff0
movq -0x38(%rbp), %rsi
callq 0x21a0
movq %rax, %r15
leaq 0x24f9(%rip), %rsi      # 0x6039
movl $0x2a, %edx
movq %rax, %rdi
callq 0x21d0
movl $0x3, %ebx
leaq 0x250b(%rip), %rsi      # 0x6064
movl $0x1, %edx
movq %r15, %rdi
callq 0x21d0
jmp 0x39eb
leaq 0x28d1(%rip), %rdi      # 0x6443
callq 0x20f0
leaq 0x28c5(%rip), %rdi      # 0x6443
callq 0x2220
jmp 0x3b85
movq %rax, %r12
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3bbc
callq 0x2180
jmp 0x3bbc
jmp 0x3bb9
movq %rax, %r12
jmp 0x3bda
jmp 0x3bb9
movq %rax, %r12
cmpl $0x0, (%r15)
jne 0x3bbc
movl %ebx, (%r15)
jmp 0x3bbc
movq %rax, %r12
jmp 0x3bce
jmp 0x3bb9
movq %rax, %r12
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x3bce
callq 0x2180
leaq -0x2a0(%rbp), %rdi
callq 0x2060
movq -0x40(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3beb
callq 0x2180
movq -0x30(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3bfc
callq 0x2180
movq %r12, %rdi
callq 0x22b0