// File: /workspace/github_cpp_makefile_star2_O3/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 0xcc1(%rip), %rdi       # 0x4090
xorl %esi, %esi
xorl %eax, %eax
callq 0x20f0
testl %eax, %eax
jle 0x3abb
movl %eax, %ebx
leaq 0x2d67(%rip), %r14      # 0x6150
leaq 0x2d78(%rip), %rdx      # 0x6168
leaq 0x2d89(%rip), %rcx      # 0x6180
movl %eax, %edi
movq %r14, %rsi
callq 0x26d3
movl %ebx, %edi
callq 0x2240
leaq 0xd1f(%rip), %rdi       # 0x412e
callq 0x21e0
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ef4
movq %rbx, %rdi
callq 0x2e9a
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x3449
movq -0xc8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xce8(%rip), %rdi       # 0x4138
callq 0x21e0
leaq 0x2d0c(%rip), %rsi      # 0x6168
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2ef4
movq %rbx, %rdi
callq 0x2e9a
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x348e
movq -0xb0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xcae(%rip), %rdi       # 0x4143
callq 0x21e0
leaq 0x2cdf(%rip), %rsi      # 0x6180
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2ef4
movq %rbx, %rdi
callq 0x2e9a
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x34d3
movq -0x98(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xb98(%rip), %rdi       # 0x4072
xorl %eax, %eax
callq 0x2040
leaq 0xc65(%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 0x2acf(%rip), %r14      # 0x5fd8
leaq 0xb9a(%rip), %rsi       # 0x40aa
movl $0x5, %edx
movq %r14, %rdi
callq 0x2190
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2140
movq %rax, %r14
leaq 0xb7e(%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 0xb21(%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 0x3702
movq -0x38(%rbp), %r12
movq -0x30(%rbp), %r13
xorl %edi, %edi
leaq -0x38(%rbp), %rsi
callq 0x2130
cmpq -0x30(%rbp), %r13
jle 0x3672
movl $0x12, %edx
movq 0x29e3(%rip), %rdi      # 0x5fd8
leaq 0xabe(%rip), %rsi       # 0x40ba
callq 0x2190
notq %r12
addq -0x38(%rbp), %r12
movq 0x29c9(%rip), %rdi      # 0x5fd8
movq %r12, %rsi
callq 0x2140
movq %rax, %r12
movl $0xc, %edx
movq %rax, %rdi
leaq 0xaa4(%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 0xa84(%rip), %rsi       # 0x40da
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
jmp 0x36ef
movl $0x12, %edx
movq 0x295a(%rip), %rdi      # 0x5fd8
leaq 0xa35(%rip), %rsi       # 0x40ba
callq 0x2190
movq -0x38(%rbp), %rsi
subq %r12, %rsi
movq 0x2940(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %r12
movl $0xc, %edx
movq %rax, %rdi
leaq 0xa1e(%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 0xa05(%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), %rcx
movq -0x18(%rcx), %rax
cmpl $0x0, -0x2d8(%rbp,%rax)
jne 0x3762
addq $-0x15, %r12
cmpq $-0x15, %r12
ja 0x3762
movq -0x210(%rbp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x3811
movq -0x18(%rcx), %rax
testb $0x5, -0x2d8(%rbp,%rax)
jne 0x384d
leaq -0x78(%rbp), %rdi
leaq 0x29d1(%rip), %rsi      # 0x6150
callq 0x2ef4
leaq -0x60(%rbp), %rdi
leaq 0x29f1(%rip), %rsi      # 0x6180
callq 0x2ef4
movq %rbx, %rdi
leaq 0x29ca(%rip), %rsi      # 0x6168
callq 0x2ef4
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 0x37d5
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x37ea
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x37ff
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
incq %r15
incq %r14
cmpl $0x1, %r12d
jne 0x35a8
jmp 0x385e
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x2f8(%rbp), %rcx
cmpl $-0x1, %eax
jne 0x3762
movq -0x18(%rcx), %rax
leaq (%rax,%rbp), %rdi
addq $-0x2f8, %rdi           # imm = 0xFD08
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x2210
movq -0x2f8(%rbp), %rcx
jmp 0x3762
movl $0x1a, %edx
leaq 0x88d(%rip), %rsi       # 0x40e6
jmp 0x391e
movq 0x2773(%rip), %rbx      # 0x5fd8
leaq 0x895(%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 0x2741(%rip), %rdi      # 0x5fd8
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0x272d(%rip), %rdi      # 0x5fd8
leaq 0x85c(%rip), %rsi       # 0x410e
movl $0xf, %edx
callq 0x2190
movq 0x2715(%rip), %rdi      # 0x5fd8
movq %r14, %rsi
callq 0x20d0
movq %rax, %rbx
leaq 0x849(%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 0x26b3(%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 0x268d(%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 0x3a0a
movq 0x2651(%rip), %rdi      # 0x5fd8
leaq 0x796(%rip), %rsi       # 0x4124
movl $0x9, %edx
callq 0x2190
movq -0x48(%rbp), %rsi
notq %rsi
addq -0x38(%rbp), %rsi
movq 0x262e(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %rbx
leaq 0x714(%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 0x6f3(%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 0x3a88
movq 0x25c7(%rip), %rdi      # 0x5fd8
leaq 0x70c(%rip), %rsi       # 0x4124
movl $0x9, %edx
callq 0x2190
movq -0x38(%rbp), %rsi
subq -0x48(%rbp), %rsi
movq 0x25a7(%rip), %rdi      # 0x5fd8
callq 0x2140
movq %rax, %rbx
leaq 0x68d(%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 0x673(%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 0x5d6(%rip), %rdi       # 0x4098
callq 0x2110
movl $0x1, %eax
jmp 0x3aa9
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x3b88
movq -0x98(%rbp), %rsi
jmp 0x3b1c
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x3b88
movq -0xb0(%rbp), %rsi
jmp 0x3b1c
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0x3b88
movq -0xc8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3b88
movq %rax, %rbx
jmp 0x3b60
movq %rax, %rbx
jmp 0x3b4b
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3b4b
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3b60
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x3b7c
movq -0x68(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x3b7c
jmp 0x3b79
movq %rax, %rbx
leaq -0x2f8(%rbp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2230