| 3844 | } |
| 3845 | |
| 3846 | int bsgs_searchbinary(struct bsgs_xvalue *buffer,char *data,int64_t array_length,uint64_t *r_value) { |
| 3847 | int64_t min,max,half,current; |
| 3848 | int r = 0,rcmp; |
| 3849 | min = 0; |
| 3850 | current = 0; |
| 3851 | max = array_length; |
| 3852 | half = array_length; |
| 3853 | while(!r && half >= 1) { |
| 3854 | half = (max - min)/2; |
| 3855 | rcmp = memcmp(data+16,buffer[current+half].value,BSGS_XVALUE_RAM); |
| 3856 | if(rcmp == 0) { |
| 3857 | *r_value = buffer[current+half].index; |
| 3858 | r = 1; |
| 3859 | } |
| 3860 | else { |
| 3861 | if(rcmp < 0) { |
| 3862 | max = (max-half); |
| 3863 | } |
| 3864 | else { |
| 3865 | min = (min+half); |
| 3866 | } |
| 3867 | current = min; |
| 3868 | } |
| 3869 | } |
| 3870 | return r; |
| 3871 | } |
| 3872 | |
| 3873 | #if defined(_WIN64) && !defined(__CYGWIN__) |
| 3874 | DWORD WINAPI thread_process_bsgs(LPVOID vargp) { |