// File: /workspace/github_cpp_makefile_star2_O2/Tarstingo[P]rarcrack/main.cpp
// Function: main
int main()
{
    int fd=open("rar.rar",O_RDONLY);
    if(fd<=0)
    {
        perror("can not open file");
        return 1;
    }
    getPara(fd,salt,iv,s);
    close(fd);
    printf("salt\033[31m\n");
    prtvector(salt);
    printf("\033[miv\033[31m\n");
    prtvector(iv);
    printf("\033[ms\033[31m\n");
    prtvector(s);
    printf("\033[m");


    printf("Now We start cracking...\n");

    muchar key[20];

    struct timespec startime,nowtime,tmptime;
    clock_gettime(CLOCK_REALTIME,&startime);
    nowtime.tv_nsec=startime.tv_nsec;
    nowtime.tv_sec=startime.tv_sec;
    cout<<"time "<<startime.tv_sec<<":"<<startime.tv_nsec<<endl;
    unsigned int long numkeys=0;
    ifstream fkey;
    fkey.open("keyfile");
    while(1)
    {
        numkeys++;
        if(numkeys%5==0)
        {
            tmptime.tv_nsec=nowtime.tv_nsec;
            tmptime.tv_sec=nowtime.tv_sec;
            clock_gettime(CLOCK_REALTIME,&nowtime);
            if(tmptime.tv_nsec>nowtime.tv_nsec)
            {
                cout<<"test 5 keys,costs "<<nowtime.tv_sec-tmptime.tv_sec-1<<"seconds and "<<1000000000-tmptime.tv_nsec+nowtime.tv_nsec<<"nanoseconds"<<endl;
            }
            else
            {
                cout<<"test 5 keys,costs "<<nowtime.tv_sec-tmptime.tv_sec<<"seconds and "<<nowtime.tv_nsec-tmptime.tv_nsec<<"nanoseconds"<<endl;
            }
        }
        fkey>>key;
        if(fkey.fail())
        {
            cout<<"The key is not in the file"<<endl;
            break;
        }
        else if(testKey(salt,s,iv,key)==1)
        {
            cout<<"Key founded;"<<endl;
            cout<<"We have tested "<<numkeys<<" keys"<<endl;
            cout<<key<<endl;
            break;
        }
    }
    fkey.close();

    clock_gettime(CLOCK_REALTIME,&nowtime);
    if(startime.tv_nsec>nowtime.tv_nsec)
    {
        cout<<"it costs "<<nowtime.tv_sec-startime.tv_sec-1<<"seconds and "<<1000000000-startime.tv_nsec+nowtime.tv_nsec<<"nanoseconds"<<endl;
    }
    else
    {
        cout<<"it costs "<<nowtime.tv_sec-startime.tv_sec<<"seconds and "<<nowtime.tv_nsec-startime.tv_nsec<<"nanoseconds"<<endl;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
leaq 0x103d(%rip), %rdi      # 0x4090
xorl %esi, %esi
xorl %eax, %eax
callq 0x2100
testl %eax, %eax
jle 0x34a8
movl %eax, %ebx
leaq 0x30db(%rip), %r14      # 0x6148
leaq 0x30ec(%rip), %rdx      # 0x6160
leaq 0x30fd(%rip), %rcx      # 0x6178
movl %eax, %edi
movq %r14, %rsi
callq 0x25d0
movl %ebx, %edi
callq 0x2230
leaq 0x109b(%rip), %rdi      # 0x412e
callq 0x21e0
leaq -0xe8(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b54
movq %rbx, %rdi
callq 0x2b06
leaq -0xe8(%rbp), %rdi
callq 0x2bea
leaq 0x1073(%rip), %rdi      # 0x4138
callq 0x21e0
leaq 0x308f(%rip), %rsi      # 0x6160
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2b54
movq %rbx, %rdi
callq 0x2b06
leaq -0xd0(%rbp), %rdi
callq 0x2bea
leaq 0x1048(%rip), %rdi      # 0x4143
callq 0x21e0
leaq 0x3071(%rip), %rsi      # 0x6178
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2b54
movq %rbx, %rdi
callq 0x2b06
leaq -0xb8(%rbp), %rdi
callq 0x2bea
leaq 0xf41(%rip), %rdi       # 0x4072
xorl %eax, %eax
callq 0x2030
leaq 0x100e(%rip), %rdi      # 0x414d
callq 0x21e0
leaq -0x50(%rbp), %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2140
movups (%rbx), %xmm0
movups %xmm0, -0x38(%rbp)
movq 0x2e78(%rip), %rdi      # 0x5fd8
leaq 0xf43(%rip), %rsi       # 0x40aa
callq 0x2160
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0xf32(%rip), %rsi       # 0x40b0
movq %rax, %rdi
callq 0x2160
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x20c0
leaq -0x308(%rbp), %rbx
movq %rbx, %rdi
callq 0x2190
leaq 0xf02(%rip), %rsi       # 0x40b2
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x20e0
pushq $0x1
popq %r15
xorl %ebx, %ebx
leaq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x100(%rbp), %r14
movq %r15, %rax
xorl %edx, %edx
pushq $0x5
popq %rcx
divq %rcx
leaq (%rax,%rax,4), %rax
decq %rax
movq %rbx, -0x58(%rbp)
cmpq %rbx, %rax
jne 0x32a3
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %r12
xorl %edi, %edi
leaq -0x38(%rbp), %rsi
callq 0x2140
cmpq -0x30(%rbp), %r12
jle 0x324c
movq 0x2dc9(%rip), %rdi      # 0x5fd8
leaq 0xea4(%rip), %rsi       # 0x40ba
callq 0x2160
notq %r13
addq -0x38(%rbp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x2150
movq %rax, %rdi
leaq 0xe96(%rip), %rsi       # 0x40cd
callq 0x2160
movq -0x30(%rbp), %rsi
subq %r12, %rsi
addq $0x3b9aca00, %rsi       # imm = 0x3B9ACA00
jmp 0x3284
movq 0x2d85(%rip), %rdi      # 0x5fd8
leaq 0xe60(%rip), %rsi       # 0x40ba
callq 0x2160
movq -0x38(%rbp), %rsi
subq %r13, %rsi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
leaq 0xe55(%rip), %rsi       # 0x40cd
callq 0x2160
movq -0x30(%rbp), %rsi
subq %r12, %rsi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
leaq 0xe44(%rip), %rsi       # 0x40da
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq -0x308(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3538
movq -0x308(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2e8(%rbp,%rax)
jne 0x33a2
leaq -0xa0(%rbp), %rdi
leaq 0x2e6e(%rip), %rsi      # 0x6148
callq 0x2b54
leaq -0x88(%rbp), %rdi
leaq 0x2e8b(%rip), %rsi      # 0x6178
callq 0x2b54
movq %r14, %rdi
leaq 0x2e64(%rip), %rsi      # 0x6160
callq 0x2b54
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
leaq -0x88(%rbp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
leaq -0x70(%rbp), %rcx
callq 0x298e
movl %eax, %r13d
movq %r14, %rdi
callq 0x2bea
movq %rbx, %rdi
callq 0x2bea
movq %r12, %rdi
callq 0x2bea
incq %r15
movq -0x58(%rbp), %rbx
incq %rbx
cmpl $0x1, %r13d
jne 0x31d0
movq 0x2c81(%rip), %rdi      # 0x5fd8
leaq 0xda3(%rip), %rsi       # 0x4101
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq 0x2c66(%rip), %rdi      # 0x5fd8
leaq 0xd95(%rip), %rsi       # 0x410e
callq 0x2160
movq %rax, %rdi
movq %rbx, %rsi
callq 0x20f0
leaq 0xd8e(%rip), %rsi       # 0x411e
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
jmp 0x33ad
leaq 0xd3d(%rip), %rbx       # 0x40e6
movq %rbx, -0x40(%rbp)
movq 0x2c24(%rip), %rdi      # 0x5fd8
movq -0x40(%rbp), %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq -0x308(%rbp), %rdi
callq 0x2040
leaq -0x38(%rbp), %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2140
movq -0x48(%rbp), %rax
cmpq 0x8(%rbx), %rax
jle 0x342f
movq 0x2be8(%rip), %rdi      # 0x5fd8
leaq 0xd2d(%rip), %rsi       # 0x4124
callq 0x2160
movq -0x50(%rbp), %rsi
notq %rsi
addq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0xcb7(%rip), %rsi       # 0x40cd
movq %rax, %rdi
callq 0x2160
movq -0x30(%rbp), %rsi
subq -0x48(%rbp), %rsi
addq $0x3b9aca00, %rsi       # imm = 0x3B9ACA00
jmp 0x3469
movq 0x2ba2(%rip), %rdi      # 0x5fd8
leaq 0xce7(%rip), %rsi       # 0x4124
callq 0x2160
movq -0x38(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0xc74(%rip), %rsi       # 0x40cd
movq %rax, %rdi
callq 0x2160
movq -0x30(%rbp), %rsi
subq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0xc62(%rip), %rsi       # 0x40da
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq -0x308(%rbp), %rdi
callq 0x2050
xorl %eax, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbe9(%rip), %rdi       # 0x4098
callq 0x2120
pushq $0x1
popq %rax
jmp 0x3496
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x34db
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x34db
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x2bea
jmp 0x3526
jmp 0x3517
movq %rax, %rbx
jmp 0x3509
movq %rax, %rbx
jmp 0x34fd
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x2bea
leaq -0x88(%rbp), %rdi
callq 0x2bea
leaq -0xa0(%rbp), %rdi
callq 0x2bea
jmp 0x351a
movq %rax, %rbx
leaq -0x308(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2220