// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2d8, %rsp            # imm = 0x2D8
leaq 0xca9(%rip), %rdi       # 0x4090
xorl %esi, %esi
xorl %eax, %eax
callq 0x20f0
testl %eax, %eax
jle 0x3ad3
movl %eax, %ebx
leaq 0x2d4f(%rip), %r14      # 0x6150
leaq 0x2d60(%rip), %rdx      # 0x6168
leaq 0x2d71(%rip), %rcx      # 0x6180
movl %eax, %edi
movq %r14, %rsi
callq 0x26d3
movl %ebx, %edi
callq 0x2240
leaq 0xd07(%rip), %rdi       # 0x412e
callq 0x21e0
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ee8
movq %rbx, %rdi
callq 0x2e8e
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x3461
movq -0xc8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xcd0(%rip), %rdi       # 0x4138
callq 0x21e0
leaq 0x2cf4(%rip), %rsi      # 0x6168
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2ee8
movq %rbx, %rdi
callq 0x2e8e
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x34a6
movq -0xb0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xc96(%rip), %rdi       # 0x4143
callq 0x21e0
leaq 0x2cc7(%rip), %rsi      # 0x6180
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2ee8
movq %rbx, %rdi
callq 0x2e8e
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x34eb
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xb80(%rip), %rdi       # 0x4072
xorl %eax, %eax
callq 0x2040
leaq 0xc4d(%rip), %rdi       # 0x414d
callq 0x21e0
leaq -0x48(%rbp), %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2130
movups (%rbx), %xmm0
movups %xmm0, -0x38(%rbp)
movq 0x2ab7(%rip), %r14      # 0x5fd8
leaq 0xb82(%rip), %rsi       # 0x40aa
movl $0x5, %edx
movq %r14, %rdi
callq 0x2190
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2140
movq %rax, %r14
leaq 0xb66(%rip), %rsi       # 0x40b0
movl $0x1, %r15d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2190
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2140
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0x2f8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2180
leaq 0xb09(%rip), %rsi       # 0x40b2
movq %rbx, %rdi
movl $0x8, %edx
callq 0x20c0
xorl %r14d, %r14d
leaq -0x90(%rbp), %rbx
movq %r15, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
shrq $0x2, %rdx
leaq (%rdx,%rdx,4), %rax
decq %rax
cmpq %r14, %rax
jne 0x371a
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %r13
xorl %edi, %edi
leaq -0x38(%rbp), %rsi
callq 0x2130
cmpq -0x30(%rbp), %r13
jle 0x368a
movl $0x12, %edx
movq 0x29cb(%rip), %rdi      # 0x5fd8
leaq 0xaa6(%rip), %rsi       # 0x40ba
callq 0x2190
notq %r12
addq -0x38(%rbp), %r12
movq 0x29b1(%rip), %rdi      # 0x5fd8
movq %r12, %rsi
callq 0x2140
movq %rax, %r12
movl $0xc, %edx
movq %rax, %rdi
leaq 0xa8c(%rip), %rsi       # 0x40cd
callq 0x2190
movq -0x30(%rbp), %rsi
subq %r13, %rsi
addq $0x3b9aca00, %rsi       # imm = 0x3B9ACA00
movq %r12, %rdi
callq 0x2140
movq %rax, %r12
movl $0xb, %edx
movq %rax, %rdi
leaq 0xa6c(%rip), %rsi       # 0x40da
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
jmp 0x3707
movl $0x12, %edx
movq 0x2942(%rip), %rdi      # 0x5fd8
leaq 0xa1d(%rip), %rsi       # 0x40ba
callq 0x2190
movq -0x38(%rbp), %rsi
subq %r12, %rsi
movq 0x2928(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %r12
movl $0xc, %edx
movq %rax, %rdi
leaq 0xa06(%rip), %rsi       # 0x40cd
callq 0x2190
movq -0x30(%rbp), %rsi
subq %r13, %rsi
movq %r12, %rdi
callq 0x2140
movq %rax, %r12
movl $0xb, %edx
movq %rax, %rdi
leaq 0x9ed(%rip), %rsi       # 0x40da
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x2e8(%rbp,%rax), %r12
movl $0x14, %edx
leaq -0x2f8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2220
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2d8(%rbp,%rax)
jne 0x377a
addq $-0x15, %r12
cmpq $-0x15, %r12
ja 0x377a
movq -0x210(%rbp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x3830
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2d8(%rbp,%rax)
jne 0x3865
leaq -0x78(%rbp), %rdi
leaq 0x29b2(%rip), %rsi      # 0x6150
callq 0x2ee8
leaq -0x60(%rbp), %rdi
leaq 0x29d2(%rip), %rsi      # 0x6180
callq 0x2ee8
movq %rbx, %rdi
leaq 0x29ab(%rip), %rsi      # 0x6168
callq 0x2ee8
leaq -0x78(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %rbx, %rdx
leaq -0xf0(%rbp), %rcx
callq 0x2bc2
movl %eax, %r12d
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x37f4
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3809
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x381e
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
incq %r15
incq %r14
cmpl $0x1, %r12d
jne 0x35c0
jmp 0x3876
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x377a
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x2f8, %rdi           # imm = 0xFD08
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x2210
jmp 0x377a
movl $0x1a, %edx
leaq 0x875(%rip), %rsi       # 0x40e6
jmp 0x3936
movq 0x275b(%rip), %rbx      # 0x5fd8
leaq 0x87d(%rip), %rsi       # 0x4101
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2190
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x2729(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0x2715(%rip), %rdi      # 0x5fd8
leaq 0x844(%rip), %rsi       # 0x410e
movl $0xf, %edx
callq 0x2190
movq 0x26fd(%rip), %rdi      # 0x5fd8
movq %r14, %rsi
callq 0x20d0
movq %rax, %rbx
leaq 0x831(%rip), %rsi       # 0x411e
movl $0x5, %edx
movq %rax, %rdi
callq 0x2190
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2090
movq %rax, %rdx
movq %rbx, %rsi
movq 0x269b(%rip), %rbx      # 0x5fd8
movq %rbx, %rdi
callq 0x2190
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x2675(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0x2f8(%rbp), %rdi
callq 0x2050
leaq -0x38(%rbp), %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2130
movq -0x40(%rbp), %rax
cmpq 0x8(%rbx), %rax
jle 0x3a22
movq 0x2639(%rip), %rdi      # 0x5fd8
leaq 0x77e(%rip), %rsi       # 0x4124
movl $0x9, %edx
callq 0x2190
movq -0x48(%rbp), %rsi
notq %rsi
addq -0x38(%rbp), %rsi
movq 0x2616(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %rbx
leaq 0x6fc(%rip), %rsi       # 0x40cd
movl $0xc, %edx
movq %rax, %rdi
callq 0x2190
movq -0x30(%rbp), %rsi
subq -0x40(%rbp), %rsi
addq $0x3b9aca00, %rsi       # imm = 0x3B9ACA00
movq %rbx, %rdi
callq 0x2140
movq %rax, %rbx
leaq 0x6db(%rip), %rsi       # 0x40da
movl $0xb, %edx
movq %rax, %rdi
callq 0x2190
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
jmp 0x3aa0
movq 0x25af(%rip), %rdi      # 0x5fd8
leaq 0x6f4(%rip), %rsi       # 0x4124
movl $0x9, %edx
callq 0x2190
movq -0x38(%rbp), %rsi
subq -0x48(%rbp), %rsi
movq 0x258f(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %rbx
leaq 0x675(%rip), %rsi       # 0x40cd
movl $0xc, %edx
movq %rax, %rdi
callq 0x2190
movq -0x30(%rbp), %rsi
subq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x2140
movq %rax, %rbx
leaq 0x65b(%rip), %rsi       # 0x40da
movl $0xb, %edx
movq %rax, %rdi
callq 0x2190
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0x2f8(%rbp), %rdi
callq 0x2060
xorl %eax, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5be(%rip), %rdi       # 0x4098
callq 0x2110
movl $0x1, %eax
jmp 0x3ac1
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x3ba0
movq -0x98(%rbp), %rsi
jmp 0x3b34
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x3ba0
movq -0xb0(%rbp), %rsi
jmp 0x3b34
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x3ba0
movq -0xc8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3ba0
movq %rax, %rbx
jmp 0x3b78
movq %rax, %rbx
jmp 0x3b63
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3b63
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3b78
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x3b94
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3b94
jmp 0x3b91
movq %rax, %rbx
leaq -0x2f8(%rbp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2230