// File: Tarstingo[P]rarcrack/crackrar.cpp
// Function: Bsha1(std::vector<unsigned char, std::allocator<unsigned char>>, unsigned char*)
void Bsha1(std::vector<muchar> M,muchar *B)
{
    timespec tmptime,nowtime;
    clock_gettime(CLOCK_REALTIME,&tmptime);

    SHA_CTX ctx;
    SHA1_Init(&ctx);
    for(int i=0;i<0x40000;i++)
    {
        muchar tmp[M.size()+3];
        for(unsigned int j=0;j<M.size();j++)
        {
            tmp[j]=M[j];
        }
        tmp[M.size()]=(i&0x0000ff);
        tmp[M.size()+1]=((i&0x00ff00)>>8);
        tmp[M.size()+2]=((i&0x0f0000)>>16);
        SHA1_Update(&ctx,tmp,M.size()+3);
    }
    SHA1_Final(B,&ctx);

    clock_gettime(CLOCK_REALTIME,&nowtime);
    printf("\033[31mBsha1\033[m\n");
    if(tmptime.tv_nsec>nowtime.tv_nsec)
    {
        cout<<"0s   "<<1000000000-nowtime.tv_nsec+tmptime.tv_nsec<<" ns"<<endl;
    }
    else
    {
        cout<<"0s   "<<nowtime.tv_nsec-tmptime.tv_nsec<<" ns"<<endl;
    }

    cout<<tmptime.tv_sec<<" "<<tmptime.tv_nsec<<endl;
    cout<<nowtime.tv_sec<<" "<<nowtime.tv_nsec<<endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %edi, %edi
leaq -0x20(%rbp), %rsi
callq 0x2150
leaq -0x90(%rbp), %rdi
callq 0x2120
movl $0x0, -0x94(%rbp)
cmpl $0x40000, -0x94(%rbp)   # imm = 0x40000
jge 0x2bf2
movq -0xb8(%rbp), %rdi
callq 0x34f0
movq %rax, %rdx
movq %rdx, %rax
addq $0x3, %rax
movq %rsp, %rcx
movq %rcx, -0xa0(%rbp)
addq $0x12, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xc0(%rbp)
movq %rcx, %rsp
movq %rax, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %eax
movq %rax, -0xc8(%rbp)
callq 0x34f0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b16
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %eax
movl %eax, %esi
callq 0x3510
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movb (%rcx), %dl
movl -0xac(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x2ab4
movq -0xb8(%rbp), %rdi
movl -0x94(%rbp), %eax
andl $0xff, %eax
movb %al, -0xcb(%rbp)
callq 0x34f0
movb -0xcb(%rbp), %dl
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movb %dl, (%rax,%rcx)
movl -0x94(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movb %al, -0xca(%rbp)
callq 0x34f0
movb -0xca(%rbp), %dl
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movb %dl, 0x1(%rax,%rcx)
movl -0x94(%rbp), %eax
andl $0xf0000, %eax          # imm = 0xF0000
sarl $0x10, %eax
movb %al, -0xc9(%rbp)
callq 0x34f0
movb -0xc9(%rbp), %dl
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movb %dl, 0x2(%rax,%rcx)
callq 0x34f0
movq -0xc0(%rbp), %rsi
movq %rax, %rdx
addq $0x3, %rdx
leaq -0x90(%rbp), %rdi
callq 0x2080
movq -0xa0(%rbp), %rax
movq %rax, %rsp
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x2a5b
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x2220
xorl %edi, %edi
leaq -0x30(%rbp), %rsi
callq 0x2150
leaq 0x341f(%rip), %rdi      # 0x6033
movb $0x0, %al
callq 0x2040
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jle 0x2c6d
movq 0x63ac(%rip), %rdi      # 0x8fd8
leaq 0x33e5(%rip), %rsi      # 0x6018
callq 0x2160
movq %rax, %rdi
movl $0x3b9aca00, %esi       # imm = 0x3B9ACA00
subq -0x28(%rbp), %rsi
addq -0x18(%rbp), %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x33c7(%rip), %rsi      # 0x601e
callq 0x2160
movq %rax, %rdi
movq 0x6362(%rip), %rsi      # 0x8fc8
callq 0x21a0
jmp 0x2cae
movq 0x6364(%rip), %rdi      # 0x8fd8
leaq 0x339d(%rip), %rsi      # 0x6018
callq 0x2160
movq %rax, %rdi
movq -0x28(%rbp), %rsi
subq -0x18(%rbp), %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x3384(%rip), %rsi      # 0x601e
callq 0x2160
movq %rax, %rdi
movq 0x631f(%rip), %rsi      # 0x8fc8
callq 0x21a0
movq -0x20(%rbp), %rsi
movq 0x631f(%rip), %rdi      # 0x8fd8
callq 0x2250
movq %rax, %rdi
leaq 0x3354(%rip), %rsi      # 0x601c
callq 0x2160
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x2250
movq %rax, %rdi
movq 0x62e5(%rip), %rsi      # 0x8fc8
callq 0x21a0
movq -0x30(%rbp), %rsi
movq 0x62e5(%rip), %rdi      # 0x8fd8
callq 0x2250
movq %rax, %rdi
leaq 0x331a(%rip), %rsi      # 0x601c
callq 0x2160
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2250
movq %rax, %rdi
movq 0x62ab(%rip), %rsi      # 0x8fc8
callq 0x21a0
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)