// File: /workspace/github_c_makefile_star2_O0/dubeyalok7[P]crypto-algo/des/feistal_algo/main.c
// Function: main
int main(int argc, char *argv[])
{
  FILE *infile, *outfile;
  char *key;
  int op;
  if((argc==2)&&(!strcmp(argv[1],"-g"))){
    generateKey();
    return 0;
  }

  if((argc < 5)){
    help();
    return 0;
  }

  for(int i=1; i< argc ; i+=2){
    if(!strcmp(argv[i],"-i")){
      printf("Input file: %s\n", argv[i+1]);
      infile = fopen(argv[i+1],"r");
      if(!infile){
        printf("Error: in-valid file name\n");
        help();
        return 0;
      }
    }
    else if(!strcmp(argv[i],"-o")){
      printf("Output File: %s\n",argv[i+1]);
      outfile = fopen(argv[i+1],"w+");
    }
    else if(!strcmp(argv[i],"-e")|| !strcmp(argv[i],"-d")){
      if(argv[i][1] =='e'){
        printf("Encrypting the file...\n");
        op = ENCRYPT;
      }else if(argv[i][1] =='d'){
        op = DECRYPT;
        printf("Decrypting the file...\n");
      }else{
        help();
        return 0;
      }
    }
  }
  fesital(infile, outfile, op);
  fclose(infile);
  fclose(outfile);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x1836
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x9e8(%rip), %rsi       # 0x2203
callq 0x10a0
cmpl $0x0, %eax
jne 0x1836
callq 0x1720
movl $0x0, -0x4(%rbp)
jmp 0x1a31
cmpl $0x5, -0x8(%rbp)
jge 0x184f
movb $0x0, %al
callq 0x1220
movl $0x0, -0x4(%rbp)
jmp 0x1a31
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1a08
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x991(%rip), %rsi       # 0x2206
callq 0x10a0
cmpl $0x0, %eax
jne 0x18ec
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x972(%rip), %rdi       # 0x2209
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x963(%rip), %rsi       # 0x2219
callq 0x10e0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x18e7
leaq 0x94e(%rip), %rdi       # 0x221b
movb $0x0, %al
callq 0x1070
movb $0x0, %al
callq 0x1220
movl $0x0, -0x4(%rbp)
jmp 0x1a31
jmp 0x19f8
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x937(%rip), %rsi       # 0x2236
callq 0x10a0
cmpl $0x0, %eax
jne 0x194e
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x918(%rip), %rdi       # 0x2239
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x90a(%rip), %rsi       # 0x224a
callq 0x10e0
movq %rax, -0x20(%rbp)
jmp 0x19f6
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x8ec(%rip), %rsi       # 0x224d
callq 0x10a0
cmpl $0x0, %eax
je 0x1988
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x8d2(%rip), %rsi       # 0x2250
callq 0x10a0
cmpl $0x0, %eax
jne 0x19f4
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x65, %eax
jne 0x19b4
leaq 0x8af(%rip), %rdi       # 0x2253
movb $0x0, %al
callq 0x1070
movl $0x0, -0x2c(%rbp)
jmp 0x19f2
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x64, %eax
jne 0x19e0
movl $0x1, -0x2c(%rbp)
leaq 0x894(%rip), %rdi       # 0x226b
movb $0x0, %al
callq 0x1070
jmp 0x19f0
movb $0x0, %al
callq 0x1220
movl $0x0, -0x4(%rbp)
jmp 0x1a31
jmp 0x19f2
jmp 0x19f4
jmp 0x19f6
jmp 0x19f8
jmp 0x19fa
movl -0x30(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x30(%rbp)
jmp 0x1856
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x1260
movq -0x18(%rbp), %rdi
callq 0x1050
movq -0x20(%rbp), %rdi
callq 0x1050
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq