// File: /workspace/github_cpp_makefile_star2_O1/bowenfan96[P]icl-mcs-enigma/enigma.cpp
// Function: Enigma::encryptor(char)
char Enigma::encryptor(char letter) 
{
    // check input letter is upper case letter
    if(!isupper(letter)) {
        std::cerr << letter << " is not a valid input character (input characters must be upper case letters A-Z)!" << "\n";
        throw INVALID_INPUT_CHARACTER;
    }
    
    int input = letter - 'A';
    
    // send signal through Plugboard
    input = pb->mapper(input);
    
    // send signal through rotors, right to left
    if(num_rotors > 0) {
        turn_rotors();
        
        // use reverse iterator for right to left signal flow
        for(auto rot = vec_rotors.rbegin(); rot != vec_rotors.rend(); ++rot) {
            input = rot->mapper(input);
        }
    }
    
    // send signal through reflector
    input = rf->mapper(input);
    
    // reflect signal through rotors, left to right
    if(num_rotors > 0) {
        for(auto rot = vec_rotors.begin(); rot != vec_rotors.end(); ++rot) {
            input = rot->rf_mapper(input);
        }
    }
    
    // reflect signal through Plugboard
    input = pb->mapper(input);
    
    // cast int to corresponding letter
    char letter_out = (char)('A' + input);
    
    return letter_out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movl %esi, %edi
callq 0x2120
testl %eax, %eax
je 0x46c2
addl $-0x41, %r14d
movq 0x38(%rbx), %rdi
movl %r14d, %esi
callq 0x2df8
movl %eax, %r14d
cmpl $0x0, (%rbx)
jle 0x45fd
movq %rbx, %rdi
callq 0x4712
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
cmpq %rax, %rcx
je 0x45fd
movl -0x8(%rcx), %esi
addl %esi, %r14d
movslq %r14d, %rdx
imulq $0x4ec4ec4f, %rdx, %rdi # imm = 0x4EC4EC4F
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x23, %rdi
addl %r8d, %edi
leal (%rdi,%rdi,4), %r8d
leal (%r8,%r8,4), %r8d
addl %edi, %r8d
subl %r8d, %edx
movslq %edx, %rdx
movl -0xf0(%rcx,%rdx,4), %edi
leaq -0xf0(%rcx), %rdx
subl %esi, %edi
movslq %edi, %rcx
imulq $0x4ec4ec4f, %rcx, %rsi # imm = 0x4EC4EC4F
movq %rsi, %rdi
shrq $0x3f, %rdi
sarq $0x23, %rsi
addl %edi, %esi
leal (%rsi,%rsi,4), %edi
leal (%rdi,%rdi,4), %edi
addl %esi, %edi
movl %ecx, %esi
subl %edi, %esi
negl %edi
testl %esi, %esi
leal 0x1a(%rcx,%rdi), %r14d
cmovnsl %esi, %r14d
movq %rdx, %rcx
cmpq %rax, %rdx
jne 0x4586
movq 0x40(%rbx), %r15
leaq -0x1c(%rbp), %rdx
movl %r14d, (%rdx)
movq (%r15), %r14
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x4c98
subq %r14, %rax
movq 0x18(%r15), %rcx
shlq $0x1e, %rax
sarq $0x1e, %rax
movl (%rcx,%rax), %esi
cmpl $0x0, (%rbx)
jle 0x46ac
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
cmpq %rcx, %rax
je 0x46ac
movl 0xe8(%rax), %edx
addl %edx, %esi
movslq %esi, %rsi
imulq $0x4ec4ec4f, %rsi, %rdi # imm = 0x4EC4EC4F
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x23, %rdi
addl %r8d, %edi
leal (%rdi,%rdi,4), %r8d
leal (%r8,%r8,4), %r8d
addl %edi, %r8d
subl %r8d, %esi
movslq %esi, %rsi
movl 0x68(%rax,%rsi,4), %esi
subl %edx, %esi
movslq %esi, %rdx
imulq $0x4ec4ec4f, %rdx, %rsi # imm = 0x4EC4EC4F
movq %rsi, %rdi
shrq $0x3f, %rdi
sarq $0x23, %rsi
addl %edi, %esi
leal (%rsi,%rsi,4), %edi
leal (%rdi,%rdi,4), %edi
addl %esi, %edi
movl %edx, %r8d
subl %edi, %r8d
negl %edi
testl %r8d, %r8d
leal 0x1a(%rdx,%rdi), %esi
cmovnsl %r8d, %esi
addq $0xf0, %rax
jmp 0x4636
movq 0x38(%rbx), %rdi
callq 0x2df8
addb $0x41, %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movsbl %r14b, %esi
movq 0x4923(%rip), %rdi      # 0x8ff0
callq 0x21e0
leaq 0x1d17(%rip), %rsi      # 0x63f0
movq %rax, %rdi
callq 0x21a0
leaq 0x197c(%rip), %rsi      # 0x6064
movq %rax, %rdi
callq 0x21a0
movl $0x4, %edi
callq 0x20c0
movl $0x2, (%rax)
movq 0x48a9(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2290
nop