// File: /workspace/github_cpp_makefile_star2_O2/yuroitaki[P]enigma_machine/main.cpp
// Function: main
int main(int argc, char** argv){

  try{
    
  /*Construct the components of enigma and store the configuration info in each component after file checks */
    Enigma enigma_machine(argc,argv);

  /*Pass in the message from input for encryption/decryption and print the result on the output stream */
    enigma_machine.run();
  }

  catch(int err_code){
    switch(err_code){
    case INSUFFICIENT_NUMBER_OF_PARAMETERS:
      cerr <<  "usage: enigma plugboard-file reflector-file (<rotor-file>* rotor-positions)?" << endl;
      return 1;
    case INVALID_INPUT_CHARACTER:
      cerr << " is not a valid input character (input characters must be upper case letters A-Z)!" << endl;
      return 2;
    case INVALID_INDEX:
      return 3;
    case NON_NUMERIC_CHARACTER:
      return 4;
    case IMPOSSIBLE_PLUGBOARD_CONFIGURATION:
      return 5;
    case INCORRECT_NUMBER_OF_PLUGBOARD_PARAMETERS:
      cerr << " number of parameters in plugboard file: plugboard.pb"<<endl;
      return 6;
    case INVALID_ROTOR_MAPPING:
      return 7;
    case NO_ROTOR_STARTING_POSITION:
      cerr << " in rotor position file: rotor.pos" << endl;
      return 8;
    case INVALID_REFLECTOR_MAPPING:
      return 9;
    case INCORRECT_NUMBER_OF_REFLECTOR_PARAMETERS:
      cerr << " number of parameters in reflector file: reflector.rf" <<endl;
      return 10;
    case ERROR_OPENING_CONFIGURATION_FILE:
      cerr << " cannot be opened correctly or it's empty (null or contains only white space character)" << endl;
      return 11;
    default: cerr << "Unknown error" << endl;     
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rdx
movl %edi, %esi
leaq 0x8(%rsp), %rdi
callq 0x2530
leaq 0x8(%rsp), %rdi
callq 0x282e
leaq 0x8(%rsp), %rdi
callq 0x2680
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rdx, %r14
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2680
jmp 0x23fc
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x2527
movq %rbx, %rdi
callq 0x2080
movl (%rax), %ebx
leal -0x1(%rbx), %eax
cmpl $0xa, %eax
ja 0x24fd
leaq 0x1be1(%rip), %rcx      # 0x4004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x4bbd(%rip), %rdi      # 0x6ff0
leaq 0x1bf6(%rip), %rsi      # 0x4030
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x1
jmp 0x24e7
movq 0x4b9b(%rip), %rdi      # 0x6ff0
leaq 0x1caa(%rip), %rsi      # 0x4106
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0xa
jmp 0x24e7
movq 0x4b7c(%rip), %rdi      # 0x6ff0
leaq 0x1c55(%rip), %rsi      # 0x40d0
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x6
jmp 0x24e7
movq 0x4b5d(%rip), %rdi      # 0x6ff0
leaq 0x1be3(%rip), %rsi      # 0x407d
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x2
jmp 0x24e7
movq 0x4b3e(%rip), %rdi      # 0x6ff0
leaq 0x1ffb(%rip), %rsi      # 0x44b4
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0x8
jmp 0x24e7
movq 0x4b1f(%rip), %rdi      # 0x6ff0
leaq 0x1c64(%rip), %rsi      # 0x413c
callq 0x2110
movq %rax, %rdi
callq 0x2090
pushq $0xb
popq %rbx
xorl %ebp, %ebp
callq 0x21a0
testb %bpl, %bpl
jne 0x23d7
jmp 0x23d9
movq 0x4aec(%rip), %rdi      # 0x6ff0
leaq 0x1c89(%rip), %rsi      # 0x4194
callq 0x2110
movq %rax, %rdi
callq 0x2090
movb $0x1, %bpl
xorl %ebx, %ebx
jmp 0x24ea
movq %rax, %rbx
callq 0x21a0
movq %rbx, %rdi
callq 0x21d0
nop