// File: /workspace/github_cpp_makefile_star2_O1/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 0x2638
leaq 0x8(%rsp), %rdi
callq 0x29f4
leaq 0x8(%rsp), %rdi
callq 0x27b4
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 0x27b4
jmp 0x24ac
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x262e
movq %rbx, %rdi
callq 0x2070
movl (%rax), %ebx
leal -0x1(%rbx), %eax
cmpl $0xa, %eax
ja 0x25f8
leaq 0x2b31(%rip), %rcx      # 0x5004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebp, %ebp
callq 0x21a0
testb %bpl, %bpl
jne 0x2487
jmp 0x2489
movq 0x5aff(%rip), %rdi      # 0x7ff0
leaq 0x2c0e(%rip), %rsi      # 0x5106
movl $0x35, %edx
callq 0x2140
movq 0x5ae7(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0xa, %ebx
jmp 0x24dc
movq 0x5ad4(%rip), %rdi      # 0x7ff0
leaq 0x2bad(%rip), %rsi      # 0x50d0
movl $0x35, %edx
callq 0x2140
movq 0x5abc(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0x6, %ebx
jmp 0x24dc
movq 0x5aa9(%rip), %rdi      # 0x7ff0
leaq 0x2ae2(%rip), %rsi      # 0x5030
movl $0x4c, %edx
callq 0x2140
movq 0x5a91(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0x1, %ebx
jmp 0x24dc
movq 0x5a7b(%rip), %rdi      # 0x7ff0
leaq 0x2b01(%rip), %rsi      # 0x507d
movl $0x52, %edx
callq 0x2140
movq 0x5a63(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0x2, %ebx
jmp 0x24dc
movq 0x5a4d(%rip), %rdi      # 0x7ff0
leaq 0x2f0a(%rip), %rsi      # 0x54b4
movl $0x22, %edx
callq 0x2140
movq 0x5a35(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0x8, %ebx
jmp 0x24dc
movq 0x5a1f(%rip), %rdi      # 0x7ff0
leaq 0x2b64(%rip), %rsi      # 0x513c
movl $0x57, %edx
callq 0x2140
movq 0x5a07(%rip), %rdi      # 0x7ff0
callq 0x2080
movl $0xb, %ebx
jmp 0x24dc
movq 0x59f1(%rip), %rdi      # 0x7ff0
leaq 0x2b8e(%rip), %rsi      # 0x5194
movl $0xd, %edx
callq 0x2140
movq 0x59d9(%rip), %rdi      # 0x7ff0
callq 0x2080
movb $0x1, %bpl
xorl %ebx, %ebx
jmp 0x24de
movq %rax, %rbx
callq 0x21a0
movq %rbx, %rdi
callq 0x21d0
nop