// File: /workspace/github_c_makefile_star2_O3/dubeyalok7[P]crypto-algo/rsa/main.c
// Function: main
int main(int argc, char *argv[])
{
  long long emsg[MSG_LIMIT]={0};
  unsigned char dmsg[MSG_LIMIT] = {0};
  char msg[MSG_LIMIT]={'\0'};
  int i;
  size_t len;
  if((argc<=1)||(argc>2)){
    printf("rsa help:\n\
        ./rsa <message>\n");
    return 0;
  }
  len = strlen(argv[1]);
  if(len>=MSG_LIMIT){
    printf("Error: enter msg within limits of 1-1022");
    return 0;
  }
  memcpy(msg, argv[1], len);

  printf("Input msg: ");
  for(i=0; i<len;i++)
      printf("%x ",msg[i]);
  printf("\n");

  struct keygen_t key = keygen();
  encrypt(emsg, msg, key.pub ,len);
  printf("Cipher :\n");
  for(i=0; i<len;i++)
      printf("%llx ",emsg[i]);
  printf("\n");

  decrypt(dmsg, emsg, key.pri, len);
  printf("Decipher :\n");
  for(i=0; i<len;i++)
      printf("%x ",dmsg[i]);
  printf("\n");;

  printf("original msg: %s\n", msg);
  printf("decrypt  msg: %s\n", dmsg);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2828, %rsp           # imm = 0x2828
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x820(%rsp), %rdi
movl $0x2000, %edx           # imm = 0x2000
xorl %esi, %esi
callq 0x1070
leaq 0x420(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x1070
leaq 0x20(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x1070
cmpl $0x2, %ebp
jne 0x166f
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x1050
cmpq $0x400, %rax            # imm = 0x400
jb 0x1680
leaq 0xa2d(%rip), %rdi       # 0x2090
xorl %eax, %eax
callq 0x1060
jmp 0x1801
leaq 0xa91(%rip), %rdi       # 0x2107
callq 0x1040
jmp 0x1801
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x1090
leaq 0xa1f(%rip), %rdi       # 0x20b9
xorl %eax, %eax
callq 0x1060
testq %rbx, %rbx
je 0x172f
leaq 0xa14(%rip), %r14       # 0x20c5
xorl %r15d, %r15d
movsbl 0x20(%rsp,%r15), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
incq %r15
cmpq %r15, %rbx
jne 0x16b4
movl $0xa, %edi
callq 0x1030
movq %rsp, %r14
movq %r14, %rdi
callq 0x11bc
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0x820(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %r8
callq 0x12d4
leaq 0x9ef(%rip), %rdi       # 0x20f3
callq 0x1040
leaq 0x9b9(%rip), %r14       # 0x20c9
xorl %r15d, %r15d
movq 0x820(%rsp,%r15,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
incq %r15
cmpq %r15, %rbx
jne 0x1713
jmp 0x176c
movl $0xa, %edi
callq 0x1030
movq %rsp, %r14
movq %r14, %rdi
callq 0x11bc
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0x820(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %r8
callq 0x12d4
leaq 0x98c(%rip), %rdi       # 0x20f3
callq 0x1040
movl $0xa, %edi
callq 0x1030
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
leaq 0x420(%rsp), %rdi
leaq 0x820(%rsp), %rsi
movq %rbx, %r8
callq 0x133c
leaq 0x95d(%rip), %rdi       # 0x20fc
callq 0x1040
testq %rbx, %rbx
je 0x17ce
leaq 0x915(%rip), %r14       # 0x20c5
xorl %r15d, %r15d
movzbl 0x420(%rsp,%r15), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
incq %r15
cmpq %r15, %rbx
jne 0x17b3
movl $0xa, %edi
callq 0x1030
leaq 0x8f0(%rip), %rdi       # 0x20cf
leaq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x1060
leaq 0x8ef(%rip), %rdi       # 0x20e1
leaq 0x420(%rsp), %rsi
xorl %eax, %eax
callq 0x1060
xorl %eax, %eax
addq $0x2828, %rsp           # imm = 0x2828
popq %rbx
popq %r14
popq %r15
popq %rbp
retq