// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2840, %rsp           # imm = 0x2840
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x2010(%rbp), %rdi
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x1050
leaq -0x2410(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x1050
leaq -0x2810(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x1050
cmpl $0x1, -0x8(%rbp)
jle 0x18fe
cmpl $0x2, -0x8(%rbp)
jle 0x1918
leaq 0x7b0(%rip), %rdi       # 0x20b5
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x1b27
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq %rax, -0x2820(%rbp)
cmpq $0x400, -0x2820(%rbp) # imm = 0x400
jb 0x1953
leaq 0x798(%rip), %rdi       # 0x20d8
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x1b27
leaq -0x2810(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x2820(%rbp), %rdx
callq 0x1070
leaq 0x78c(%rip), %rdi       # 0x2101
movb $0x0, %al
callq 0x1040
movl $0x0, -0x2814(%rbp)
movslq -0x2814(%rbp), %rax
cmpq -0x2820(%rbp), %rax
jae 0x19c4
movslq -0x2814(%rbp), %rax
movsbl -0x2810(%rbp,%rax), %esi
leaq 0x761(%rip), %rdi       # 0x210d
movb $0x0, %al
callq 0x1040
movl -0x2814(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2814(%rbp)
jmp 0x1986
leaq 0x74e(%rip), %rdi       # 0x2119
movb $0x0, %al
callq 0x1040
leaq -0x2840(%rbp), %rdi
callq 0x11a0
leaq -0x2010(%rbp), %rdi
leaq -0x2810(%rbp), %rsi
movq -0x2820(%rbp), %r8
movq -0x2840(%rbp), %rdx
movq -0x2838(%rbp), %rcx
callq 0x1320
leaq 0x704(%rip), %rdi       # 0x2111
movb $0x0, %al
callq 0x1040
movl $0x0, -0x2814(%rbp)
movslq -0x2814(%rbp), %rax
cmpq -0x2820(%rbp), %rax
jae 0x1a5c
movslq -0x2814(%rbp), %rax
movq -0x2010(%rbp,%rax,8), %rsi
leaq 0x6d7(%rip), %rdi       # 0x211b
movb $0x0, %al
callq 0x1040
movl -0x2814(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2814(%rbp)
jmp 0x1a1e
leaq 0x6b6(%rip), %rdi       # 0x2119
movb $0x0, %al
callq 0x1040
leaq -0x2410(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
movq -0x2820(%rbp), %r8
movq -0x2830(%rbp), %rdx
movq -0x2828(%rbp), %rcx
callq 0x13c0
leaq 0x688(%rip), %rdi       # 0x2121
movb $0x0, %al
callq 0x1040
movl $0x0, -0x2814(%rbp)
movslq -0x2814(%rbp), %rax
cmpq -0x2820(%rbp), %rax
jae 0x1ae8
movslq -0x2814(%rbp), %rax
movzbl -0x2410(%rbp,%rax), %esi
leaq 0x63d(%rip), %rdi       # 0x210d
movb $0x0, %al
callq 0x1040
movl -0x2814(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2814(%rbp)
jmp 0x1aaa
leaq 0x62a(%rip), %rdi       # 0x2119
movb $0x0, %al
callq 0x1040
leaq -0x2810(%rbp), %rsi
leaq 0x629(%rip), %rdi       # 0x212d
movb $0x0, %al
callq 0x1040
leaq -0x2410(%rbp), %rsi
leaq 0x626(%rip), %rdi       # 0x213f
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2840, %rsp           # imm = 0x2840
popq %rbp
retq