redrust/
hyperloglog.rs

1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4extern "C" {
5    pub type RedisModuleCommand;
6    pub type clusterSlotToKeyMapping;
7    pub type clusterState;
8    static mut server: redisServer;
9    static mut shared: sharedObjectsStruct;
10    fn addReplyBulkCBuffer(c: *mut client, p: *const libc::c_void, len: size_t);
11    fn addReply(c: *mut client, obj: *mut robj);
12    fn sdsnewlen(init: *const libc::c_void, initlen: size_t) -> sds;
13    fn sdsempty() -> sds;
14    fn sdsfree(s: sds);
15    fn sdscatprintf(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
16    fn sdstrim(s: sds, cset: *const libc::c_char) -> sds;
17    fn sdsMakeRoomFor(s: sds, addlen: size_t) -> sds;
18    fn sdsIncrLen(s: sds, incr: ssize_t);
19    fn rand() -> libc::c_int;
20    fn memcpy(
21        _: *mut libc::c_void,
22        _: *const libc::c_void,
23        _: libc::c_ulong,
24    ) -> *mut libc::c_void;
25    fn memmove(
26        _: *mut libc::c_void,
27        _: *const libc::c_void,
28        _: libc::c_ulong,
29    ) -> *mut libc::c_void;
30    fn memset(
31        _: *mut libc::c_void,
32        _: libc::c_int,
33        _: libc::c_ulong,
34    ) -> *mut libc::c_void;
35    fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
36    fn addReplyError(c: *mut client, err: *const libc::c_char);
37    fn addReplyStatus(c: *mut client, status: *const libc::c_char);
38    fn addReplyLongLong(c: *mut client, ll: libc::c_longlong);
39    fn addReplyArrayLen(c: *mut client, length: libc::c_long);
40    fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
41    fn decrRefCount(o: *mut robj);
42    fn createObject(type_0: libc::c_int, ptr: *mut libc::c_void) -> *mut robj;
43    fn stringObjectLen(o: *mut robj) -> size_t;
44    fn checkType(c: *mut client, o: *mut robj, type_0: libc::c_int) -> libc::c_int;
45    fn notifyKeyspaceEvent(
46        type_0: libc::c_int,
47        event: *mut libc::c_char,
48        key: *mut robj,
49        dbid: libc::c_int,
50    );
51    fn lookupKeyRead(db: *mut redisDb, key: *mut robj) -> *mut robj;
52    fn lookupKeyWrite(db: *mut redisDb, key: *mut robj) -> *mut robj;
53    fn dbAdd(db: *mut redisDb, key: *mut robj, val: *mut robj);
54    fn dbUnshareStringValue(db: *mut redisDb, key: *mut robj, o: *mut robj) -> *mut robj;
55    fn signalModifiedKey(c: *mut client, db: *mut redisDb, key: *mut robj);
56    fn _serverPanic(
57        file: *const libc::c_char,
58        line: libc::c_int,
59        msg: *const libc::c_char,
60        _: ...
61    );
62    fn _serverAssert(
63        estr: *const libc::c_char,
64        file: *const libc::c_char,
65        line: libc::c_int,
66    );
67    fn pow(_: libc::c_double, _: libc::c_double) -> libc::c_double;
68    fn sqrt(_: libc::c_double) -> libc::c_double;
69    fn ceil(_: libc::c_double) -> libc::c_double;
70    fn llroundl(_: f64) -> libc::c_longlong;
71}
72pub type __uint8_t = libc::c_uchar;
73pub type __int16_t = libc::c_short;
74pub type __uint16_t = libc::c_ushort;
75pub type __int32_t = libc::c_int;
76pub type __uint32_t = libc::c_uint;
77pub type __int64_t = libc::c_long;
78pub type __uint64_t = libc::c_ulong;
79pub type __uint_least64_t = __uint64_t;
80pub type __mode_t = libc::c_uint;
81pub type __off64_t = libc::c_long;
82pub type __pid_t = libc::c_int;
83pub type __time_t = libc::c_long;
84pub type __ssize_t = libc::c_long;
85pub type __sig_atomic_t = libc::c_int;
86pub type size_t = libc::c_ulong;
87#[derive(Copy, Clone)]
88#[repr(C)]
89pub struct iovec {
90    pub iov_base: *mut libc::c_void,
91    pub iov_len: size_t,
92}
93pub type mode_t = __mode_t;
94pub type off_t = __off64_t;
95pub type pid_t = __pid_t;
96pub type ssize_t = __ssize_t;
97pub type time_t = __time_t;
98pub type int16_t = __int16_t;
99pub type int32_t = __int32_t;
100pub type int64_t = __int64_t;
101pub type pthread_t = libc::c_ulong;
102pub type uint8_t = __uint8_t;
103pub type uint16_t = __uint16_t;
104pub type uint32_t = __uint32_t;
105pub type uint64_t = __uint64_t;
106pub type uint_least64_t = __uint_least64_t;
107pub type sds = *mut libc::c_char;
108#[derive(Copy, Clone)]
109#[repr(C, packed)]
110pub struct sdshdr8 {
111    pub len: uint8_t,
112    pub alloc: uint8_t,
113    pub flags: libc::c_uchar,
114    pub buf: [libc::c_char; 0],
115}
116#[derive(Copy, Clone)]
117#[repr(C, packed)]
118pub struct sdshdr16 {
119    pub len: uint16_t,
120    pub alloc: uint16_t,
121    pub flags: libc::c_uchar,
122    pub buf: [libc::c_char; 0],
123}
124#[derive(Copy, Clone)]
125#[repr(C, packed)]
126pub struct sdshdr32 {
127    pub len: uint32_t,
128    pub alloc: uint32_t,
129    pub flags: libc::c_uchar,
130    pub buf: [libc::c_char; 0],
131}
132#[derive(Copy, Clone)]
133#[repr(C, packed)]
134pub struct sdshdr64 {
135    pub len: uint64_t,
136    pub alloc: uint64_t,
137    pub flags: libc::c_uchar,
138    pub buf: [libc::c_char; 0],
139}
140#[derive(Copy, Clone)]
141#[repr(C)]
142pub struct aeEventLoop {
143    pub maxfd: libc::c_int,
144    pub setsize: libc::c_int,
145    pub timeEventNextId: libc::c_longlong,
146    pub events: *mut aeFileEvent,
147    pub fired: *mut aeFiredEvent,
148    pub timeEventHead: *mut aeTimeEvent,
149    pub stop: libc::c_int,
150    pub apidata: *mut libc::c_void,
151    pub beforesleep: Option::<aeBeforeSleepProc>,
152    pub aftersleep: Option::<aeBeforeSleepProc>,
153    pub flags: libc::c_int,
154}
155pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
156#[derive(Copy, Clone)]
157#[repr(C)]
158pub struct aeTimeEvent {
159    pub id: libc::c_longlong,
160    pub when: monotime,
161    pub timeProc: Option::<aeTimeProc>,
162    pub finalizerProc: Option::<aeEventFinalizerProc>,
163    pub clientData: *mut libc::c_void,
164    pub prev: *mut aeTimeEvent,
165    pub next: *mut aeTimeEvent,
166    pub refcount: libc::c_int,
167}
168pub type aeEventFinalizerProc = unsafe extern "C" fn(
169    *mut aeEventLoop,
170    *mut libc::c_void,
171) -> ();
172pub type aeTimeProc = unsafe extern "C" fn(
173    *mut aeEventLoop,
174    libc::c_longlong,
175    *mut libc::c_void,
176) -> libc::c_int;
177pub type monotime = uint64_t;
178#[derive(Copy, Clone)]
179#[repr(C)]
180pub struct aeFiredEvent {
181    pub fd: libc::c_int,
182    pub mask: libc::c_int,
183}
184#[derive(Copy, Clone)]
185#[repr(C)]
186pub struct aeFileEvent {
187    pub mask: libc::c_int,
188    pub rfileProc: Option::<aeFileProc>,
189    pub wfileProc: Option::<aeFileProc>,
190    pub clientData: *mut libc::c_void,
191}
192pub type aeFileProc = unsafe extern "C" fn(
193    *mut aeEventLoop,
194    libc::c_int,
195    *mut libc::c_void,
196    libc::c_int,
197) -> ();
198#[derive(Copy, Clone)]
199#[repr(C)]
200pub struct connection {
201    pub type_0: *mut ConnectionType,
202    pub state: ConnectionState,
203    pub flags: libc::c_short,
204    pub refs: libc::c_short,
205    pub last_errno: libc::c_int,
206    pub private_data: *mut libc::c_void,
207    pub conn_handler: ConnectionCallbackFunc,
208    pub write_handler: ConnectionCallbackFunc,
209    pub read_handler: ConnectionCallbackFunc,
210    pub fd: libc::c_int,
211}
212pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
213pub type ConnectionState = libc::c_uint;
214pub const CONN_STATE_ERROR: ConnectionState = 5;
215pub const CONN_STATE_CLOSED: ConnectionState = 4;
216pub const CONN_STATE_CONNECTED: ConnectionState = 3;
217pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
218pub const CONN_STATE_CONNECTING: ConnectionState = 1;
219pub const CONN_STATE_NONE: ConnectionState = 0;
220#[derive(Copy, Clone)]
221#[repr(C)]
222pub struct ConnectionType {
223    pub ae_handler: Option::<
224        unsafe extern "C" fn(
225            *mut aeEventLoop,
226            libc::c_int,
227            *mut libc::c_void,
228            libc::c_int,
229        ) -> (),
230    >,
231    pub connect: Option::<
232        unsafe extern "C" fn(
233            *mut connection,
234            *const libc::c_char,
235            libc::c_int,
236            *const libc::c_char,
237            ConnectionCallbackFunc,
238        ) -> libc::c_int,
239    >,
240    pub write: Option::<
241        unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
242    >,
243    pub writev: Option::<
244        unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
245    >,
246    pub read: Option::<
247        unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
248    >,
249    pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
250    pub accept: Option::<
251        unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
252    >,
253    pub set_write_handler: Option::<
254        unsafe extern "C" fn(
255            *mut connection,
256            ConnectionCallbackFunc,
257            libc::c_int,
258        ) -> libc::c_int,
259    >,
260    pub set_read_handler: Option::<
261        unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
262    >,
263    pub get_last_error: Option::<
264        unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
265    >,
266    pub blocking_connect: Option::<
267        unsafe extern "C" fn(
268            *mut connection,
269            *const libc::c_char,
270            libc::c_int,
271            libc::c_longlong,
272        ) -> libc::c_int,
273    >,
274    pub sync_write: Option::<
275        unsafe extern "C" fn(
276            *mut connection,
277            *mut libc::c_char,
278            ssize_t,
279            libc::c_longlong,
280        ) -> ssize_t,
281    >,
282    pub sync_read: Option::<
283        unsafe extern "C" fn(
284            *mut connection,
285            *mut libc::c_char,
286            ssize_t,
287            libc::c_longlong,
288        ) -> ssize_t,
289    >,
290    pub sync_readline: Option::<
291        unsafe extern "C" fn(
292            *mut connection,
293            *mut libc::c_char,
294            ssize_t,
295            libc::c_longlong,
296        ) -> ssize_t,
297    >,
298    pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
299}
300#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
301#[repr(C)]
302pub struct redisObject {
303    #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
304    #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
305    #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
306    pub type_0_encoding_lru: [u8; 4],
307    pub refcount: libc::c_int,
308    pub ptr: *mut libc::c_void,
309}
310pub type atomic_int = libc::c_int;
311pub type atomic_uint = libc::c_uint;
312pub type atomic_llong = libc::c_longlong;
313pub type sig_atomic_t = __sig_atomic_t;
314#[derive(Copy, Clone)]
315#[repr(C)]
316pub struct hdr_histogram {
317    pub lowest_discernible_value: int64_t,
318    pub highest_trackable_value: int64_t,
319    pub unit_magnitude: int32_t,
320    pub significant_figures: int32_t,
321    pub sub_bucket_half_count_magnitude: int32_t,
322    pub sub_bucket_half_count: int32_t,
323    pub sub_bucket_mask: int64_t,
324    pub sub_bucket_count: int32_t,
325    pub bucket_count: int32_t,
326    pub min_value: int64_t,
327    pub max_value: int64_t,
328    pub normalizing_index_offset: int32_t,
329    pub conversion_ratio: libc::c_double,
330    pub counts_len: int32_t,
331    pub total_count: int64_t,
332    pub counts: *mut int64_t,
333}
334pub type mstime_t = libc::c_longlong;
335pub type ustime_t = libc::c_longlong;
336#[derive(Copy, Clone)]
337#[repr(C)]
338pub struct dictEntry {
339    pub key: *mut libc::c_void,
340    pub v: C2RustUnnamed,
341    pub next: *mut dictEntry,
342    pub metadata: [*mut libc::c_void; 0],
343}
344#[derive(Copy, Clone)]
345#[repr(C)]
346pub union C2RustUnnamed {
347    pub val: *mut libc::c_void,
348    pub u64_0: uint64_t,
349    pub s64: int64_t,
350    pub d: libc::c_double,
351}
352#[derive(Copy, Clone)]
353#[repr(C)]
354pub struct dict {
355    pub type_0: *mut dictType,
356    pub ht_table: [*mut *mut dictEntry; 2],
357    pub ht_used: [libc::c_ulong; 2],
358    pub rehashidx: libc::c_long,
359    pub pauserehash: int16_t,
360    pub ht_size_exp: [libc::c_schar; 2],
361}
362#[derive(Copy, Clone)]
363#[repr(C)]
364pub struct dictType {
365    pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
366    pub keyDup: Option::<
367        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
368    >,
369    pub valDup: Option::<
370        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
371    >,
372    pub keyCompare: Option::<
373        unsafe extern "C" fn(
374            *mut dict,
375            *const libc::c_void,
376            *const libc::c_void,
377        ) -> libc::c_int,
378    >,
379    pub keyDestructor: Option::<
380        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
381    >,
382    pub valDestructor: Option::<
383        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
384    >,
385    pub expandAllowed: Option::<
386        unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
387    >,
388    pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
389}
390#[derive(Copy, Clone)]
391#[repr(C)]
392pub struct listNode {
393    pub prev: *mut listNode,
394    pub next: *mut listNode,
395    pub value: *mut libc::c_void,
396}
397#[derive(Copy, Clone)]
398#[repr(C)]
399pub struct list {
400    pub head: *mut listNode,
401    pub tail: *mut listNode,
402    pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
403    pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
404    pub match_0: Option::<
405        unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
406    >,
407    pub len: libc::c_ulong,
408}
409#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
410#[repr(C)]
411pub struct raxNode {
412    #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
413    #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
414    #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
415    #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
416    pub iskey_isnull_iscompr_size: [u8; 4],
417    pub data: [libc::c_uchar; 0],
418}
419#[derive(Copy, Clone)]
420#[repr(C)]
421pub struct rax {
422    pub head: *mut raxNode,
423    pub numele: uint64_t,
424    pub numnodes: uint64_t,
425}
426pub type pause_type = libc::c_uint;
427pub const CLIENT_PAUSE_ALL: pause_type = 2;
428pub const CLIENT_PAUSE_WRITE: pause_type = 1;
429pub const CLIENT_PAUSE_OFF: pause_type = 0;
430#[derive(Copy, Clone)]
431#[repr(C)]
432pub struct pause_event {
433    pub type_0: pause_type,
434    pub end: mstime_t,
435}
436pub type robj = redisObject;
437pub type RedisModuleUserChangedFunc = Option::<
438    unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
439>;
440#[derive(Copy, Clone)]
441#[repr(C)]
442pub struct redisDb {
443    pub dict: *mut dict,
444    pub expires: *mut dict,
445    pub blocking_keys: *mut dict,
446    pub ready_keys: *mut dict,
447    pub watched_keys: *mut dict,
448    pub id: libc::c_int,
449    pub avg_ttl: libc::c_longlong,
450    pub expires_cursor: libc::c_ulong,
451    pub defrag_later: *mut list,
452    pub slots_to_keys: *mut clusterSlotToKeyMapping,
453}
454#[derive(Copy, Clone)]
455#[repr(C)]
456pub struct multiCmd {
457    pub argv: *mut *mut robj,
458    pub argv_len: libc::c_int,
459    pub argc: libc::c_int,
460    pub cmd: *mut redisCommand,
461}
462#[derive(Copy, Clone)]
463#[repr(C)]
464pub struct redisCommand {
465    pub declared_name: *const libc::c_char,
466    pub summary: *const libc::c_char,
467    pub complexity: *const libc::c_char,
468    pub since: *const libc::c_char,
469    pub doc_flags: libc::c_int,
470    pub replaced_by: *const libc::c_char,
471    pub deprecated_since: *const libc::c_char,
472    pub group: redisCommandGroup,
473    pub history: *mut commandHistory,
474    pub tips: *mut *const libc::c_char,
475    pub proc_0: Option::<redisCommandProc>,
476    pub arity: libc::c_int,
477    pub flags: uint64_t,
478    pub acl_categories: uint64_t,
479    pub key_specs_static: [keySpec; 4],
480    pub getkeys_proc: Option::<redisGetKeysProc>,
481    pub subcommands: *mut redisCommand,
482    pub args: *mut redisCommandArg,
483    pub microseconds: libc::c_longlong,
484    pub calls: libc::c_longlong,
485    pub rejected_calls: libc::c_longlong,
486    pub failed_calls: libc::c_longlong,
487    pub id: libc::c_int,
488    pub fullname: sds,
489    pub latency_histogram: *mut hdr_histogram,
490    pub key_specs: *mut keySpec,
491    pub legacy_range_key_spec: keySpec,
492    pub num_args: libc::c_int,
493    pub num_history: libc::c_int,
494    pub num_tips: libc::c_int,
495    pub key_specs_num: libc::c_int,
496    pub key_specs_max: libc::c_int,
497    pub subcommands_dict: *mut dict,
498    pub parent: *mut redisCommand,
499    pub module_cmd: *mut RedisModuleCommand,
500}
501#[derive(Copy, Clone)]
502#[repr(C)]
503pub struct keySpec {
504    pub notes: *const libc::c_char,
505    pub flags: uint64_t,
506    pub begin_search_type: kspec_bs_type,
507    pub bs: C2RustUnnamed_3,
508    pub find_keys_type: kspec_fk_type,
509    pub fk: C2RustUnnamed_0,
510}
511#[derive(Copy, Clone)]
512#[repr(C)]
513pub union C2RustUnnamed_0 {
514    pub range: C2RustUnnamed_2,
515    pub keynum: C2RustUnnamed_1,
516}
517#[derive(Copy, Clone)]
518#[repr(C)]
519pub struct C2RustUnnamed_1 {
520    pub keynumidx: libc::c_int,
521    pub firstkey: libc::c_int,
522    pub keystep: libc::c_int,
523}
524#[derive(Copy, Clone)]
525#[repr(C)]
526pub struct C2RustUnnamed_2 {
527    pub lastkey: libc::c_int,
528    pub keystep: libc::c_int,
529    pub limit: libc::c_int,
530}
531pub type kspec_fk_type = libc::c_uint;
532pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
533pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
534pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
535pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
536#[derive(Copy, Clone)]
537#[repr(C)]
538pub union C2RustUnnamed_3 {
539    pub index: C2RustUnnamed_5,
540    pub keyword: C2RustUnnamed_4,
541}
542#[derive(Copy, Clone)]
543#[repr(C)]
544pub struct C2RustUnnamed_4 {
545    pub keyword: *const libc::c_char,
546    pub startfrom: libc::c_int,
547}
548#[derive(Copy, Clone)]
549#[repr(C)]
550pub struct C2RustUnnamed_5 {
551    pub pos: libc::c_int,
552}
553pub type kspec_bs_type = libc::c_uint;
554pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
555pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
556pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
557pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
558#[derive(Copy, Clone)]
559#[repr(C)]
560pub struct redisCommandArg {
561    pub name: *const libc::c_char,
562    pub type_0: redisCommandArgType,
563    pub key_spec_index: libc::c_int,
564    pub token: *const libc::c_char,
565    pub summary: *const libc::c_char,
566    pub since: *const libc::c_char,
567    pub flags: libc::c_int,
568    pub deprecated_since: *const libc::c_char,
569    pub subargs: *mut redisCommandArg,
570    pub num_args: libc::c_int,
571}
572pub type redisCommandArgType = libc::c_uint;
573pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
574pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
575pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
576pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
577pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
578pub const ARG_TYPE_KEY: redisCommandArgType = 3;
579pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
580pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
581pub const ARG_TYPE_STRING: redisCommandArgType = 0;
582pub type redisGetKeysProc = unsafe extern "C" fn(
583    *mut redisCommand,
584    *mut *mut robj,
585    libc::c_int,
586    *mut getKeysResult,
587) -> libc::c_int;
588#[derive(Copy, Clone)]
589#[repr(C)]
590pub struct getKeysResult {
591    pub keysbuf: [keyReference; 256],
592    pub keys: *mut keyReference,
593    pub numkeys: libc::c_int,
594    pub size: libc::c_int,
595}
596#[derive(Copy, Clone)]
597#[repr(C)]
598pub struct keyReference {
599    pub pos: libc::c_int,
600    pub flags: libc::c_int,
601}
602pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
603#[derive(Copy, Clone)]
604#[repr(C)]
605pub struct client {
606    pub id: uint64_t,
607    pub flags: uint64_t,
608    pub conn: *mut connection,
609    pub resp: libc::c_int,
610    pub db: *mut redisDb,
611    pub name: *mut robj,
612    pub querybuf: sds,
613    pub qb_pos: size_t,
614    pub querybuf_peak: size_t,
615    pub argc: libc::c_int,
616    pub argv: *mut *mut robj,
617    pub argv_len: libc::c_int,
618    pub original_argc: libc::c_int,
619    pub original_argv: *mut *mut robj,
620    pub argv_len_sum: size_t,
621    pub cmd: *mut redisCommand,
622    pub lastcmd: *mut redisCommand,
623    pub realcmd: *mut redisCommand,
624    pub user: *mut user,
625    pub reqtype: libc::c_int,
626    pub multibulklen: libc::c_int,
627    pub bulklen: libc::c_long,
628    pub reply: *mut list,
629    pub reply_bytes: libc::c_ulonglong,
630    pub deferred_reply_errors: *mut list,
631    pub sentlen: size_t,
632    pub ctime: time_t,
633    pub duration: libc::c_long,
634    pub slot: libc::c_int,
635    pub cur_script: *mut dictEntry,
636    pub lastinteraction: time_t,
637    pub obuf_soft_limit_reached_time: time_t,
638    pub authenticated: libc::c_int,
639    pub replstate: libc::c_int,
640    pub repl_start_cmd_stream_on_ack: libc::c_int,
641    pub repldbfd: libc::c_int,
642    pub repldboff: off_t,
643    pub repldbsize: off_t,
644    pub replpreamble: sds,
645    pub read_reploff: libc::c_longlong,
646    pub reploff: libc::c_longlong,
647    pub repl_applied: libc::c_longlong,
648    pub repl_ack_off: libc::c_longlong,
649    pub repl_ack_time: libc::c_longlong,
650    pub repl_last_partial_write: libc::c_longlong,
651    pub psync_initial_offset: libc::c_longlong,
652    pub replid: [libc::c_char; 41],
653    pub slave_listening_port: libc::c_int,
654    pub slave_addr: *mut libc::c_char,
655    pub slave_capa: libc::c_int,
656    pub slave_req: libc::c_int,
657    pub mstate: multiState,
658    pub btype: libc::c_int,
659    pub bpop: blockingState,
660    pub woff: libc::c_longlong,
661    pub watched_keys: *mut list,
662    pub pubsub_channels: *mut dict,
663    pub pubsub_patterns: *mut list,
664    pub pubsubshard_channels: *mut dict,
665    pub peerid: sds,
666    pub sockname: sds,
667    pub client_list_node: *mut listNode,
668    pub postponed_list_node: *mut listNode,
669    pub pending_read_list_node: *mut listNode,
670    pub auth_callback: RedisModuleUserChangedFunc,
671    pub auth_callback_privdata: *mut libc::c_void,
672    pub auth_module: *mut libc::c_void,
673    pub client_tracking_redirection: uint64_t,
674    pub client_tracking_prefixes: *mut rax,
675    pub last_memory_usage: size_t,
676    pub last_memory_type: libc::c_int,
677    pub mem_usage_bucket_node: *mut listNode,
678    pub mem_usage_bucket: *mut clientMemUsageBucket,
679    pub ref_repl_buf_node: *mut listNode,
680    pub ref_block_pos: size_t,
681    pub buf_peak: size_t,
682    pub buf_peak_last_reset_time: mstime_t,
683    pub bufpos: libc::c_int,
684    pub buf_usable_size: size_t,
685    pub buf: *mut libc::c_char,
686}
687#[derive(Copy, Clone)]
688#[repr(C)]
689pub struct clientMemUsageBucket {
690    pub clients: *mut list,
691    pub mem_usage_sum: size_t,
692}
693#[derive(Copy, Clone)]
694#[repr(C)]
695pub struct blockingState {
696    pub count: libc::c_long,
697    pub timeout: mstime_t,
698    pub keys: *mut dict,
699    pub target: *mut robj,
700    pub blockpos: blockPos,
701    pub xread_count: size_t,
702    pub xread_group: *mut robj,
703    pub xread_consumer: *mut robj,
704    pub xread_group_noack: libc::c_int,
705    pub numreplicas: libc::c_int,
706    pub reploffset: libc::c_longlong,
707    pub module_blocked_handle: *mut libc::c_void,
708}
709#[derive(Copy, Clone)]
710#[repr(C)]
711pub struct blockPos {
712    pub wherefrom: libc::c_int,
713    pub whereto: libc::c_int,
714}
715#[derive(Copy, Clone)]
716#[repr(C)]
717pub struct multiState {
718    pub commands: *mut multiCmd,
719    pub count: libc::c_int,
720    pub cmd_flags: libc::c_int,
721    pub cmd_inv_flags: libc::c_int,
722    pub argv_len_sums: size_t,
723    pub alloc_count: libc::c_int,
724}
725#[derive(Copy, Clone)]
726#[repr(C)]
727pub struct user {
728    pub name: sds,
729    pub flags: uint32_t,
730    pub passwords: *mut list,
731    pub selectors: *mut list,
732    pub acl_string: *mut robj,
733}
734#[derive(Copy, Clone)]
735#[repr(C)]
736pub struct commandHistory {
737    pub since: *const libc::c_char,
738    pub changes: *const libc::c_char,
739}
740pub type redisCommandGroup = libc::c_uint;
741pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
742pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
743pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
744pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
745pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
746pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
747pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
748pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
749pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
750pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
751pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
752pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
753pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
754pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
755pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
756pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
757pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
758pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
759#[derive(Copy, Clone)]
760#[repr(C)]
761pub struct replBacklog {
762    pub ref_repl_buf_node: *mut listNode,
763    pub unindexed_count: size_t,
764    pub blocks_index: *mut rax,
765    pub histlen: libc::c_longlong,
766    pub offset: libc::c_longlong,
767}
768#[derive(Copy, Clone)]
769#[repr(C)]
770pub struct saveparam {
771    pub seconds: time_t,
772    pub changes: libc::c_int,
773}
774#[derive(Copy, Clone)]
775#[repr(C)]
776pub struct sentinelConfig {
777    pub pre_monitor_cfg: *mut list,
778    pub monitor_cfg: *mut list,
779    pub post_monitor_cfg: *mut list,
780}
781#[derive(Copy, Clone)]
782#[repr(C)]
783pub struct sharedObjectsStruct {
784    pub crlf: *mut robj,
785    pub ok: *mut robj,
786    pub err: *mut robj,
787    pub emptybulk: *mut robj,
788    pub czero: *mut robj,
789    pub cone: *mut robj,
790    pub pong: *mut robj,
791    pub space: *mut robj,
792    pub queued: *mut robj,
793    pub null: [*mut robj; 4],
794    pub nullarray: [*mut robj; 4],
795    pub emptymap: [*mut robj; 4],
796    pub emptyset: [*mut robj; 4],
797    pub emptyarray: *mut robj,
798    pub wrongtypeerr: *mut robj,
799    pub nokeyerr: *mut robj,
800    pub syntaxerr: *mut robj,
801    pub sameobjecterr: *mut robj,
802    pub outofrangeerr: *mut robj,
803    pub noscripterr: *mut robj,
804    pub loadingerr: *mut robj,
805    pub slowevalerr: *mut robj,
806    pub slowscripterr: *mut robj,
807    pub slowmoduleerr: *mut robj,
808    pub bgsaveerr: *mut robj,
809    pub masterdownerr: *mut robj,
810    pub roslaveerr: *mut robj,
811    pub execaborterr: *mut robj,
812    pub noautherr: *mut robj,
813    pub noreplicaserr: *mut robj,
814    pub busykeyerr: *mut robj,
815    pub oomerr: *mut robj,
816    pub plus: *mut robj,
817    pub messagebulk: *mut robj,
818    pub pmessagebulk: *mut robj,
819    pub subscribebulk: *mut robj,
820    pub unsubscribebulk: *mut robj,
821    pub psubscribebulk: *mut robj,
822    pub punsubscribebulk: *mut robj,
823    pub del: *mut robj,
824    pub unlink: *mut robj,
825    pub rpop: *mut robj,
826    pub lpop: *mut robj,
827    pub lpush: *mut robj,
828    pub rpoplpush: *mut robj,
829    pub lmove: *mut robj,
830    pub blmove: *mut robj,
831    pub zpopmin: *mut robj,
832    pub zpopmax: *mut robj,
833    pub emptyscan: *mut robj,
834    pub multi: *mut robj,
835    pub exec: *mut robj,
836    pub left: *mut robj,
837    pub right: *mut robj,
838    pub hset: *mut robj,
839    pub srem: *mut robj,
840    pub xgroup: *mut robj,
841    pub xclaim: *mut robj,
842    pub script: *mut robj,
843    pub replconf: *mut robj,
844    pub eval: *mut robj,
845    pub persist: *mut robj,
846    pub set: *mut robj,
847    pub pexpireat: *mut robj,
848    pub pexpire: *mut robj,
849    pub time: *mut robj,
850    pub pxat: *mut robj,
851    pub absttl: *mut robj,
852    pub retrycount: *mut robj,
853    pub force: *mut robj,
854    pub justid: *mut robj,
855    pub entriesread: *mut robj,
856    pub lastid: *mut robj,
857    pub ping: *mut robj,
858    pub setid: *mut robj,
859    pub keepttl: *mut robj,
860    pub load: *mut robj,
861    pub createconsumer: *mut robj,
862    pub getack: *mut robj,
863    pub special_asterick: *mut robj,
864    pub special_equals: *mut robj,
865    pub default_username: *mut robj,
866    pub redacted: *mut robj,
867    pub ssubscribebulk: *mut robj,
868    pub sunsubscribebulk: *mut robj,
869    pub smessagebulk: *mut robj,
870    pub select: [*mut robj; 10],
871    pub integers: [*mut robj; 10000],
872    pub mbulkhdr: [*mut robj; 32],
873    pub bulkhdr: [*mut robj; 32],
874    pub maphdr: [*mut robj; 32],
875    pub sethdr: [*mut robj; 32],
876    pub minstring: sds,
877    pub maxstring: sds,
878}
879#[derive(Copy, Clone)]
880#[repr(C)]
881pub struct clientBufferLimitsConfig {
882    pub hard_limit_bytes: libc::c_ulonglong,
883    pub soft_limit_bytes: libc::c_ulonglong,
884    pub soft_limit_seconds: time_t,
885}
886#[derive(Copy, Clone)]
887#[repr(C)]
888pub struct redisOp {
889    pub argv: *mut *mut robj,
890    pub argc: libc::c_int,
891    pub dbid: libc::c_int,
892    pub target: libc::c_int,
893}
894#[derive(Copy, Clone)]
895#[repr(C)]
896pub struct redisOpArray {
897    pub ops: *mut redisOp,
898    pub numops: libc::c_int,
899    pub capacity: libc::c_int,
900}
901#[derive(Copy, Clone)]
902#[repr(C)]
903pub struct malloc_stats {
904    pub zmalloc_used: size_t,
905    pub process_rss: size_t,
906    pub allocator_allocated: size_t,
907    pub allocator_active: size_t,
908    pub allocator_resident: size_t,
909}
910#[derive(Copy, Clone)]
911#[repr(C)]
912pub struct socketFds {
913    pub fd: [libc::c_int; 16],
914    pub count: libc::c_int,
915}
916#[derive(Copy, Clone)]
917#[repr(C)]
918pub struct redisTLSContextConfig {
919    pub cert_file: *mut libc::c_char,
920    pub key_file: *mut libc::c_char,
921    pub key_file_pass: *mut libc::c_char,
922    pub client_cert_file: *mut libc::c_char,
923    pub client_key_file: *mut libc::c_char,
924    pub client_key_file_pass: *mut libc::c_char,
925    pub dh_params_file: *mut libc::c_char,
926    pub ca_cert_file: *mut libc::c_char,
927    pub ca_cert_dir: *mut libc::c_char,
928    pub protocols: *mut libc::c_char,
929    pub ciphers: *mut libc::c_char,
930    pub ciphersuites: *mut libc::c_char,
931    pub prefer_server_ciphers: libc::c_int,
932    pub session_caching: libc::c_int,
933    pub session_cache_size: libc::c_int,
934    pub session_cache_timeout: libc::c_int,
935}
936pub type aof_file_type = libc::c_uint;
937pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
938pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
939pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
940#[derive(Copy, Clone)]
941#[repr(C)]
942pub struct aofInfo {
943    pub file_name: sds,
944    pub file_seq: libc::c_longlong,
945    pub file_type: aof_file_type,
946}
947#[derive(Copy, Clone)]
948#[repr(C)]
949pub struct aofManifest {
950    pub base_aof_info: *mut aofInfo,
951    pub incr_aof_list: *mut list,
952    pub history_aof_list: *mut list,
953    pub curr_base_file_seq: libc::c_longlong,
954    pub curr_incr_file_seq: libc::c_longlong,
955    pub dirty: libc::c_int,
956}
957#[derive(Copy, Clone)]
958#[repr(C)]
959pub struct redisServer {
960    pub pid: pid_t,
961    pub main_thread_id: pthread_t,
962    pub configfile: *mut libc::c_char,
963    pub executable: *mut libc::c_char,
964    pub exec_argv: *mut *mut libc::c_char,
965    pub dynamic_hz: libc::c_int,
966    pub config_hz: libc::c_int,
967    pub umask: mode_t,
968    pub hz: libc::c_int,
969    pub in_fork_child: libc::c_int,
970    pub db: *mut redisDb,
971    pub commands: *mut dict,
972    pub orig_commands: *mut dict,
973    pub el: *mut aeEventLoop,
974    pub errors: *mut rax,
975    pub lruclock: atomic_uint,
976    pub shutdown_asap: sig_atomic_t,
977    pub shutdown_mstime: mstime_t,
978    pub last_sig_received: libc::c_int,
979    pub shutdown_flags: libc::c_int,
980    pub activerehashing: libc::c_int,
981    pub active_defrag_running: libc::c_int,
982    pub pidfile: *mut libc::c_char,
983    pub arch_bits: libc::c_int,
984    pub cronloops: libc::c_int,
985    pub runid: [libc::c_char; 41],
986    pub sentinel_mode: libc::c_int,
987    pub initial_memory_usage: size_t,
988    pub always_show_logo: libc::c_int,
989    pub in_exec: libc::c_int,
990    pub busy_module_yield_flags: libc::c_int,
991    pub busy_module_yield_reply: *const libc::c_char,
992    pub core_propagates: libc::c_int,
993    pub propagate_no_multi: libc::c_int,
994    pub module_ctx_nesting: libc::c_int,
995    pub ignore_warnings: *mut libc::c_char,
996    pub client_pause_in_transaction: libc::c_int,
997    pub thp_enabled: libc::c_int,
998    pub page_size: size_t,
999    pub moduleapi: *mut dict,
1000    pub sharedapi: *mut dict,
1001    pub module_configs_queue: *mut dict,
1002    pub loadmodule_queue: *mut list,
1003    pub module_pipe: [libc::c_int; 2],
1004    pub child_pid: pid_t,
1005    pub child_type: libc::c_int,
1006    pub port: libc::c_int,
1007    pub tls_port: libc::c_int,
1008    pub tcp_backlog: libc::c_int,
1009    pub bindaddr: [*mut libc::c_char; 16],
1010    pub bindaddr_count: libc::c_int,
1011    pub bind_source_addr: *mut libc::c_char,
1012    pub unixsocket: *mut libc::c_char,
1013    pub unixsocketperm: libc::c_uint,
1014    pub ipfd: socketFds,
1015    pub tlsfd: socketFds,
1016    pub sofd: libc::c_int,
1017    pub socket_mark_id: uint32_t,
1018    pub cfd: socketFds,
1019    pub clients: *mut list,
1020    pub clients_to_close: *mut list,
1021    pub clients_pending_write: *mut list,
1022    pub clients_pending_read: *mut list,
1023    pub slaves: *mut list,
1024    pub monitors: *mut list,
1025    pub current_client: *mut client,
1026    pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1027    pub clients_timeout_table: *mut rax,
1028    pub fixed_time_expire: libc::c_long,
1029    pub in_nested_call: libc::c_int,
1030    pub clients_index: *mut rax,
1031    pub client_pause_type: pause_type,
1032    pub postponed_clients: *mut list,
1033    pub client_pause_end_time: mstime_t,
1034    pub client_pause_per_purpose: [*mut pause_event; 3],
1035    pub neterr: [libc::c_char; 256],
1036    pub migrate_cached_sockets: *mut dict,
1037    pub next_client_id: uint_least64_t,
1038    pub protected_mode: libc::c_int,
1039    pub io_threads_num: libc::c_int,
1040    pub io_threads_do_reads: libc::c_int,
1041    pub io_threads_active: libc::c_int,
1042    pub events_processed_while_blocked: libc::c_longlong,
1043    pub enable_protected_configs: libc::c_int,
1044    pub enable_debug_cmd: libc::c_int,
1045    pub enable_module_cmd: libc::c_int,
1046    pub loading: sig_atomic_t,
1047    pub async_loading: sig_atomic_t,
1048    pub loading_total_bytes: off_t,
1049    pub loading_rdb_used_mem: off_t,
1050    pub loading_loaded_bytes: off_t,
1051    pub loading_start_time: time_t,
1052    pub loading_process_events_interval_bytes: off_t,
1053    pub stat_starttime: time_t,
1054    pub stat_numcommands: libc::c_longlong,
1055    pub stat_numconnections: libc::c_longlong,
1056    pub stat_expiredkeys: libc::c_longlong,
1057    pub stat_expired_stale_perc: libc::c_double,
1058    pub stat_expired_time_cap_reached_count: libc::c_longlong,
1059    pub stat_expire_cycle_time_used: libc::c_longlong,
1060    pub stat_evictedkeys: libc::c_longlong,
1061    pub stat_evictedclients: libc::c_longlong,
1062    pub stat_total_eviction_exceeded_time: libc::c_longlong,
1063    pub stat_last_eviction_exceeded_time: monotime,
1064    pub stat_keyspace_hits: libc::c_longlong,
1065    pub stat_keyspace_misses: libc::c_longlong,
1066    pub stat_active_defrag_hits: libc::c_longlong,
1067    pub stat_active_defrag_misses: libc::c_longlong,
1068    pub stat_active_defrag_key_hits: libc::c_longlong,
1069    pub stat_active_defrag_key_misses: libc::c_longlong,
1070    pub stat_active_defrag_scanned: libc::c_longlong,
1071    pub stat_total_active_defrag_time: libc::c_longlong,
1072    pub stat_last_active_defrag_time: monotime,
1073    pub stat_peak_memory: size_t,
1074    pub stat_aof_rewrites: libc::c_longlong,
1075    pub stat_aofrw_consecutive_failures: libc::c_longlong,
1076    pub stat_rdb_saves: libc::c_longlong,
1077    pub stat_fork_time: libc::c_longlong,
1078    pub stat_fork_rate: libc::c_double,
1079    pub stat_total_forks: libc::c_longlong,
1080    pub stat_rejected_conn: libc::c_longlong,
1081    pub stat_sync_full: libc::c_longlong,
1082    pub stat_sync_partial_ok: libc::c_longlong,
1083    pub stat_sync_partial_err: libc::c_longlong,
1084    pub slowlog: *mut list,
1085    pub slowlog_entry_id: libc::c_longlong,
1086    pub slowlog_log_slower_than: libc::c_longlong,
1087    pub slowlog_max_len: libc::c_ulong,
1088    pub cron_malloc_stats: malloc_stats,
1089    pub stat_net_input_bytes: atomic_llong,
1090    pub stat_net_output_bytes: atomic_llong,
1091    pub stat_net_repl_input_bytes: atomic_llong,
1092    pub stat_net_repl_output_bytes: atomic_llong,
1093    pub stat_current_cow_peak: size_t,
1094    pub stat_current_cow_bytes: size_t,
1095    pub stat_current_cow_updated: monotime,
1096    pub stat_current_save_keys_processed: size_t,
1097    pub stat_current_save_keys_total: size_t,
1098    pub stat_rdb_cow_bytes: size_t,
1099    pub stat_aof_cow_bytes: size_t,
1100    pub stat_module_cow_bytes: size_t,
1101    pub stat_module_progress: libc::c_double,
1102    pub stat_clients_type_memory: [size_t; 4],
1103    pub stat_cluster_links_memory: size_t,
1104    pub stat_unexpected_error_replies: libc::c_longlong,
1105    pub stat_total_error_replies: libc::c_longlong,
1106    pub stat_dump_payload_sanitizations: libc::c_longlong,
1107    pub stat_io_reads_processed: libc::c_longlong,
1108    pub stat_io_writes_processed: libc::c_longlong,
1109    pub stat_total_reads_processed: atomic_llong,
1110    pub stat_total_writes_processed: atomic_llong,
1111    pub inst_metric: [C2RustUnnamed_6; 5],
1112    pub stat_reply_buffer_shrinks: libc::c_longlong,
1113    pub stat_reply_buffer_expands: libc::c_longlong,
1114    pub verbosity: libc::c_int,
1115    pub maxidletime: libc::c_int,
1116    pub tcpkeepalive: libc::c_int,
1117    pub active_expire_enabled: libc::c_int,
1118    pub active_expire_effort: libc::c_int,
1119    pub active_defrag_enabled: libc::c_int,
1120    pub sanitize_dump_payload: libc::c_int,
1121    pub skip_checksum_validation: libc::c_int,
1122    pub jemalloc_bg_thread: libc::c_int,
1123    pub active_defrag_ignore_bytes: size_t,
1124    pub active_defrag_threshold_lower: libc::c_int,
1125    pub active_defrag_threshold_upper: libc::c_int,
1126    pub active_defrag_cycle_min: libc::c_int,
1127    pub active_defrag_cycle_max: libc::c_int,
1128    pub active_defrag_max_scan_fields: libc::c_ulong,
1129    pub client_max_querybuf_len: size_t,
1130    pub dbnum: libc::c_int,
1131    pub supervised: libc::c_int,
1132    pub supervised_mode: libc::c_int,
1133    pub daemonize: libc::c_int,
1134    pub set_proc_title: libc::c_int,
1135    pub proc_title_template: *mut libc::c_char,
1136    pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1137    pub pause_cron: libc::c_int,
1138    pub latency_tracking_enabled: libc::c_int,
1139    pub latency_tracking_info_percentiles: *mut libc::c_double,
1140    pub latency_tracking_info_percentiles_len: libc::c_int,
1141    pub aof_enabled: libc::c_int,
1142    pub aof_state: libc::c_int,
1143    pub aof_fsync: libc::c_int,
1144    pub aof_filename: *mut libc::c_char,
1145    pub aof_dirname: *mut libc::c_char,
1146    pub aof_no_fsync_on_rewrite: libc::c_int,
1147    pub aof_rewrite_perc: libc::c_int,
1148    pub aof_rewrite_min_size: off_t,
1149    pub aof_rewrite_base_size: off_t,
1150    pub aof_current_size: off_t,
1151    pub aof_last_incr_size: off_t,
1152    pub aof_fsync_offset: off_t,
1153    pub aof_flush_sleep: libc::c_int,
1154    pub aof_rewrite_scheduled: libc::c_int,
1155    pub aof_buf: sds,
1156    pub aof_fd: libc::c_int,
1157    pub aof_selected_db: libc::c_int,
1158    pub aof_flush_postponed_start: time_t,
1159    pub aof_last_fsync: time_t,
1160    pub aof_rewrite_time_last: time_t,
1161    pub aof_rewrite_time_start: time_t,
1162    pub aof_cur_timestamp: time_t,
1163    pub aof_timestamp_enabled: libc::c_int,
1164    pub aof_lastbgrewrite_status: libc::c_int,
1165    pub aof_delayed_fsync: libc::c_ulong,
1166    pub aof_rewrite_incremental_fsync: libc::c_int,
1167    pub rdb_save_incremental_fsync: libc::c_int,
1168    pub aof_last_write_status: libc::c_int,
1169    pub aof_last_write_errno: libc::c_int,
1170    pub aof_load_truncated: libc::c_int,
1171    pub aof_use_rdb_preamble: libc::c_int,
1172    pub aof_bio_fsync_status: atomic_int,
1173    pub aof_bio_fsync_errno: atomic_int,
1174    pub aof_manifest: *mut aofManifest,
1175    pub aof_disable_auto_gc: libc::c_int,
1176    pub dirty: libc::c_longlong,
1177    pub dirty_before_bgsave: libc::c_longlong,
1178    pub rdb_last_load_keys_expired: libc::c_longlong,
1179    pub rdb_last_load_keys_loaded: libc::c_longlong,
1180    pub saveparams: *mut saveparam,
1181    pub saveparamslen: libc::c_int,
1182    pub rdb_filename: *mut libc::c_char,
1183    pub rdb_compression: libc::c_int,
1184    pub rdb_checksum: libc::c_int,
1185    pub rdb_del_sync_files: libc::c_int,
1186    pub lastsave: time_t,
1187    pub lastbgsave_try: time_t,
1188    pub rdb_save_time_last: time_t,
1189    pub rdb_save_time_start: time_t,
1190    pub rdb_bgsave_scheduled: libc::c_int,
1191    pub rdb_child_type: libc::c_int,
1192    pub lastbgsave_status: libc::c_int,
1193    pub stop_writes_on_bgsave_err: libc::c_int,
1194    pub rdb_pipe_read: libc::c_int,
1195    pub rdb_child_exit_pipe: libc::c_int,
1196    pub rdb_pipe_conns: *mut *mut connection,
1197    pub rdb_pipe_numconns: libc::c_int,
1198    pub rdb_pipe_numconns_writing: libc::c_int,
1199    pub rdb_pipe_buff: *mut libc::c_char,
1200    pub rdb_pipe_bufflen: libc::c_int,
1201    pub rdb_key_save_delay: libc::c_int,
1202    pub key_load_delay: libc::c_int,
1203    pub child_info_pipe: [libc::c_int; 2],
1204    pub child_info_nread: libc::c_int,
1205    pub also_propagate: redisOpArray,
1206    pub replication_allowed: libc::c_int,
1207    pub logfile: *mut libc::c_char,
1208    pub syslog_enabled: libc::c_int,
1209    pub syslog_ident: *mut libc::c_char,
1210    pub syslog_facility: libc::c_int,
1211    pub crashlog_enabled: libc::c_int,
1212    pub memcheck_enabled: libc::c_int,
1213    pub use_exit_on_panic: libc::c_int,
1214    pub shutdown_timeout: libc::c_int,
1215    pub shutdown_on_sigint: libc::c_int,
1216    pub shutdown_on_sigterm: libc::c_int,
1217    pub replid: [libc::c_char; 41],
1218    pub replid2: [libc::c_char; 41],
1219    pub master_repl_offset: libc::c_longlong,
1220    pub second_replid_offset: libc::c_longlong,
1221    pub slaveseldb: libc::c_int,
1222    pub repl_ping_slave_period: libc::c_int,
1223    pub repl_backlog: *mut replBacklog,
1224    pub repl_backlog_size: libc::c_longlong,
1225    pub repl_backlog_time_limit: time_t,
1226    pub repl_no_slaves_since: time_t,
1227    pub repl_min_slaves_to_write: libc::c_int,
1228    pub repl_min_slaves_max_lag: libc::c_int,
1229    pub repl_good_slaves_count: libc::c_int,
1230    pub repl_diskless_sync: libc::c_int,
1231    pub repl_diskless_load: libc::c_int,
1232    pub repl_diskless_sync_delay: libc::c_int,
1233    pub repl_diskless_sync_max_replicas: libc::c_int,
1234    pub repl_buffer_mem: size_t,
1235    pub repl_buffer_blocks: *mut list,
1236    pub masteruser: *mut libc::c_char,
1237    pub masterauth: sds,
1238    pub masterhost: *mut libc::c_char,
1239    pub masterport: libc::c_int,
1240    pub repl_timeout: libc::c_int,
1241    pub master: *mut client,
1242    pub cached_master: *mut client,
1243    pub repl_syncio_timeout: libc::c_int,
1244    pub repl_state: libc::c_int,
1245    pub repl_transfer_size: off_t,
1246    pub repl_transfer_read: off_t,
1247    pub repl_transfer_last_fsync_off: off_t,
1248    pub repl_transfer_s: *mut connection,
1249    pub repl_transfer_fd: libc::c_int,
1250    pub repl_transfer_tmpfile: *mut libc::c_char,
1251    pub repl_transfer_lastio: time_t,
1252    pub repl_serve_stale_data: libc::c_int,
1253    pub repl_slave_ro: libc::c_int,
1254    pub repl_slave_ignore_maxmemory: libc::c_int,
1255    pub repl_down_since: time_t,
1256    pub repl_disable_tcp_nodelay: libc::c_int,
1257    pub slave_priority: libc::c_int,
1258    pub replica_announced: libc::c_int,
1259    pub slave_announce_port: libc::c_int,
1260    pub slave_announce_ip: *mut libc::c_char,
1261    pub propagation_error_behavior: libc::c_int,
1262    pub repl_ignore_disk_write_error: libc::c_int,
1263    pub master_replid: [libc::c_char; 41],
1264    pub master_initial_offset: libc::c_longlong,
1265    pub repl_slave_lazy_flush: libc::c_int,
1266    pub clients_waiting_acks: *mut list,
1267    pub get_ack_from_slaves: libc::c_int,
1268    pub maxclients: libc::c_uint,
1269    pub maxmemory: libc::c_ulonglong,
1270    pub maxmemory_clients: ssize_t,
1271    pub maxmemory_policy: libc::c_int,
1272    pub maxmemory_samples: libc::c_int,
1273    pub maxmemory_eviction_tenacity: libc::c_int,
1274    pub lfu_log_factor: libc::c_int,
1275    pub lfu_decay_time: libc::c_int,
1276    pub proto_max_bulk_len: libc::c_longlong,
1277    pub oom_score_adj_values: [libc::c_int; 3],
1278    pub oom_score_adj: libc::c_int,
1279    pub disable_thp: libc::c_int,
1280    pub blocked_clients: libc::c_uint,
1281    pub blocked_clients_by_type: [libc::c_uint; 8],
1282    pub unblocked_clients: *mut list,
1283    pub ready_keys: *mut list,
1284    pub tracking_clients: libc::c_uint,
1285    pub tracking_table_max_keys: size_t,
1286    pub tracking_pending_keys: *mut list,
1287    pub sort_desc: libc::c_int,
1288    pub sort_alpha: libc::c_int,
1289    pub sort_bypattern: libc::c_int,
1290    pub sort_store: libc::c_int,
1291    pub hash_max_listpack_entries: size_t,
1292    pub hash_max_listpack_value: size_t,
1293    pub set_max_intset_entries: size_t,
1294    pub zset_max_listpack_entries: size_t,
1295    pub zset_max_listpack_value: size_t,
1296    pub hll_sparse_max_bytes: size_t,
1297    pub stream_node_max_bytes: size_t,
1298    pub stream_node_max_entries: libc::c_longlong,
1299    pub list_max_listpack_size: libc::c_int,
1300    pub list_compress_depth: libc::c_int,
1301    pub unixtime: atomic_int,
1302    pub timezone: time_t,
1303    pub daylight_active: libc::c_int,
1304    pub mstime: mstime_t,
1305    pub ustime: ustime_t,
1306    pub blocking_op_nesting: size_t,
1307    pub blocked_last_cron: libc::c_longlong,
1308    pub pubsub_channels: *mut dict,
1309    pub pubsub_patterns: *mut dict,
1310    pub notify_keyspace_events: libc::c_int,
1311    pub pubsubshard_channels: *mut dict,
1312    pub cluster_enabled: libc::c_int,
1313    pub cluster_port: libc::c_int,
1314    pub cluster_node_timeout: mstime_t,
1315    pub cluster_configfile: *mut libc::c_char,
1316    pub cluster: *mut clusterState,
1317    pub cluster_migration_barrier: libc::c_int,
1318    pub cluster_allow_replica_migration: libc::c_int,
1319    pub cluster_slave_validity_factor: libc::c_int,
1320    pub cluster_require_full_coverage: libc::c_int,
1321    pub cluster_slave_no_failover: libc::c_int,
1322    pub cluster_announce_ip: *mut libc::c_char,
1323    pub cluster_announce_hostname: *mut libc::c_char,
1324    pub cluster_preferred_endpoint_type: libc::c_int,
1325    pub cluster_announce_port: libc::c_int,
1326    pub cluster_announce_tls_port: libc::c_int,
1327    pub cluster_announce_bus_port: libc::c_int,
1328    pub cluster_module_flags: libc::c_int,
1329    pub cluster_allow_reads_when_down: libc::c_int,
1330    pub cluster_config_file_lock_fd: libc::c_int,
1331    pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1332    pub cluster_drop_packet_filter: libc::c_int,
1333    pub script_caller: *mut client,
1334    pub busy_reply_threshold: mstime_t,
1335    pub pre_command_oom_state: libc::c_int,
1336    pub script_disable_deny_script: libc::c_int,
1337    pub lazyfree_lazy_eviction: libc::c_int,
1338    pub lazyfree_lazy_expire: libc::c_int,
1339    pub lazyfree_lazy_server_del: libc::c_int,
1340    pub lazyfree_lazy_user_del: libc::c_int,
1341    pub lazyfree_lazy_user_flush: libc::c_int,
1342    pub latency_monitor_threshold: libc::c_longlong,
1343    pub latency_events: *mut dict,
1344    pub acl_filename: *mut libc::c_char,
1345    pub acllog_max_len: libc::c_ulong,
1346    pub requirepass: sds,
1347    pub acl_pubsub_default: libc::c_int,
1348    pub watchdog_period: libc::c_int,
1349    pub system_memory_size: size_t,
1350    pub tls_cluster: libc::c_int,
1351    pub tls_replication: libc::c_int,
1352    pub tls_auth_clients: libc::c_int,
1353    pub tls_ctx_config: redisTLSContextConfig,
1354    pub server_cpulist: *mut libc::c_char,
1355    pub bio_cpulist: *mut libc::c_char,
1356    pub aof_rewrite_cpulist: *mut libc::c_char,
1357    pub bgsave_cpulist: *mut libc::c_char,
1358    pub sentinel_config: *mut sentinelConfig,
1359    pub failover_end_time: mstime_t,
1360    pub force_failover: libc::c_int,
1361    pub target_replica_host: *mut libc::c_char,
1362    pub target_replica_port: libc::c_int,
1363    pub failover_state: libc::c_int,
1364    pub cluster_allow_pubsubshard_when_down: libc::c_int,
1365    pub reply_buffer_peak_reset_time: libc::c_long,
1366    pub reply_buffer_resizing_enabled: libc::c_int,
1367}
1368#[derive(Copy, Clone)]
1369#[repr(C)]
1370pub struct C2RustUnnamed_6 {
1371    pub last_sample_time: libc::c_longlong,
1372    pub last_sample_count: libc::c_longlong,
1373    pub samples: [libc::c_longlong; 16],
1374    pub idx: libc::c_int,
1375}
1376#[derive(Copy, Clone)]
1377#[repr(C)]
1378pub struct hllhdr {
1379    pub magic: [libc::c_char; 4],
1380    pub encoding: uint8_t,
1381    pub notused: [uint8_t; 3],
1382    pub card: [uint8_t; 8],
1383    pub registers: [uint8_t; 0],
1384}
1385#[inline]
1386unsafe extern "C" fn sdslen(s: sds) -> size_t {
1387    let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1388        as libc::c_uchar;
1389    match flags as libc::c_int & 7 as libc::c_int {
1390        0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
1391        1 => {
1392            return (*(s
1393                .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1394                as *mut sdshdr8))
1395                .len as size_t;
1396        }
1397        2 => {
1398            return (*(s
1399                .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
1400                as *mut sdshdr16))
1401                .len as size_t;
1402        }
1403        3 => {
1404            return (*(s
1405                .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
1406                as *mut sdshdr32))
1407                .len as size_t;
1408        }
1409        4 => {
1410            return (*(s
1411                .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
1412                as *mut sdshdr64))
1413                .len;
1414        }
1415        _ => {}
1416    }
1417    return 0 as libc::c_int as size_t;
1418}
1419static mut invalid_hll_err: *mut libc::c_char = b"-INVALIDOBJ Corrupted HLL object detected\0"
1420    as *const u8 as *const libc::c_char as *mut libc::c_char;
1421#[no_mangle]
1422pub unsafe extern "C" fn MurmurHash64A(
1423    mut key: *const libc::c_void,
1424    mut len: libc::c_int,
1425    mut seed: libc::c_uint,
1426) -> uint64_t {
1427    let m: uint64_t = 0xc6a4a7935bd1e995 as libc::c_ulong;
1428    let r: libc::c_int = 47 as libc::c_int;
1429    let mut h: uint64_t = seed as libc::c_ulong ^ (len as libc::c_ulong).wrapping_mul(m);
1430    let mut data: *const uint8_t = key as *const uint8_t;
1431    let mut end: *const uint8_t = data.offset((len - (len & 7 as libc::c_int)) as isize);
1432    while data != end {
1433        let mut k: uint64_t = 0;
1434        k = *(data as *mut uint64_t);
1435        k = (k as libc::c_ulong).wrapping_mul(m) as uint64_t as uint64_t;
1436        k ^= k >> r;
1437        k = (k as libc::c_ulong).wrapping_mul(m) as uint64_t as uint64_t;
1438        h ^= k;
1439        h = (h as libc::c_ulong).wrapping_mul(m) as uint64_t as uint64_t;
1440        data = data.offset(8 as libc::c_int as isize);
1441    }
1442    let mut current_block_16: u64;
1443    match len & 7 as libc::c_int {
1444        7 => {
1445            h
1446                ^= (*data.offset(6 as libc::c_int as isize) as uint64_t)
1447                    << 48 as libc::c_int;
1448            current_block_16 = 16156281075998952011;
1449        }
1450        6 => {
1451            current_block_16 = 16156281075998952011;
1452        }
1453        5 => {
1454            current_block_16 = 11813332777664204542;
1455        }
1456        4 => {
1457            current_block_16 = 3600228491966162135;
1458        }
1459        3 => {
1460            current_block_16 = 4519919386293895278;
1461        }
1462        2 => {
1463            current_block_16 = 13565725371418141234;
1464        }
1465        1 => {
1466            current_block_16 = 10324593184274379554;
1467        }
1468        _ => {
1469            current_block_16 = 4956146061682418353;
1470        }
1471    }
1472    match current_block_16 {
1473        16156281075998952011 => {
1474            h
1475                ^= (*data.offset(5 as libc::c_int as isize) as uint64_t)
1476                    << 40 as libc::c_int;
1477            current_block_16 = 11813332777664204542;
1478        }
1479        _ => {}
1480    }
1481    match current_block_16 {
1482        11813332777664204542 => {
1483            h
1484                ^= (*data.offset(4 as libc::c_int as isize) as uint64_t)
1485                    << 32 as libc::c_int;
1486            current_block_16 = 3600228491966162135;
1487        }
1488        _ => {}
1489    }
1490    match current_block_16 {
1491        3600228491966162135 => {
1492            h
1493                ^= (*data.offset(3 as libc::c_int as isize) as uint64_t)
1494                    << 24 as libc::c_int;
1495            current_block_16 = 4519919386293895278;
1496        }
1497        _ => {}
1498    }
1499    match current_block_16 {
1500        4519919386293895278 => {
1501            h
1502                ^= (*data.offset(2 as libc::c_int as isize) as uint64_t)
1503                    << 16 as libc::c_int;
1504            current_block_16 = 13565725371418141234;
1505        }
1506        _ => {}
1507    }
1508    match current_block_16 {
1509        13565725371418141234 => {
1510            h
1511                ^= (*data.offset(1 as libc::c_int as isize) as uint64_t)
1512                    << 8 as libc::c_int;
1513            current_block_16 = 10324593184274379554;
1514        }
1515        _ => {}
1516    }
1517    match current_block_16 {
1518        10324593184274379554 => {
1519            h ^= *data.offset(0 as libc::c_int as isize) as uint64_t;
1520            h = (h as libc::c_ulong).wrapping_mul(m) as uint64_t as uint64_t;
1521        }
1522        _ => {}
1523    }
1524    h ^= h >> r;
1525    h = (h as libc::c_ulong).wrapping_mul(m) as uint64_t as uint64_t;
1526    h ^= h >> r;
1527    return h;
1528}
1529#[no_mangle]
1530pub unsafe extern "C" fn hllPatLen(
1531    mut ele: *mut libc::c_uchar,
1532    mut elesize: size_t,
1533    mut regp: *mut libc::c_long,
1534) -> libc::c_int {
1535    let mut hash: uint64_t = 0;
1536    let mut bit: uint64_t = 0;
1537    let mut index: uint64_t = 0;
1538    let mut count: libc::c_int = 0;
1539    hash = MurmurHash64A(
1540        ele as *const libc::c_void,
1541        elesize as libc::c_int,
1542        0xadc83b19 as libc::c_ulonglong as libc::c_uint,
1543    );
1544    index = hash
1545        & (((1 as libc::c_int) << 14 as libc::c_int) - 1 as libc::c_int)
1546            as libc::c_ulong;
1547    hash >>= 14 as libc::c_int;
1548    hash |= (1 as libc::c_int as uint64_t) << 64 as libc::c_int - 14 as libc::c_int;
1549    bit = 1 as libc::c_int as uint64_t;
1550    count = 1 as libc::c_int;
1551    while hash & bit == 0 as libc::c_int as libc::c_ulong {
1552        count += 1;
1553        bit <<= 1 as libc::c_int;
1554    }
1555    *regp = index as libc::c_int as libc::c_long;
1556    return count;
1557}
1558#[no_mangle]
1559pub unsafe extern "C" fn hllDenseSet(
1560    mut registers: *mut uint8_t,
1561    mut index: libc::c_long,
1562    mut count: uint8_t,
1563) -> libc::c_int {
1564    let mut oldcount: uint8_t = 0;
1565    let mut _p: *mut uint8_t = registers;
1566    let mut _byte: libc::c_ulong = (index * 6 as libc::c_int as libc::c_long
1567        / 8 as libc::c_int as libc::c_long) as libc::c_ulong;
1568    let mut _fb: libc::c_ulong = (index * 6 as libc::c_int as libc::c_long
1569        & 7 as libc::c_int as libc::c_long) as libc::c_ulong;
1570    let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong).wrapping_sub(_fb);
1571    let mut b0: libc::c_ulong = *_p.offset(_byte as isize) as libc::c_ulong;
1572    let mut b1: libc::c_ulong = *_p
1573        .offset(_byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize)
1574        as libc::c_ulong;
1575    oldcount = ((b0 >> _fb | b1 << _fb8)
1576        & (((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int) as libc::c_ulong)
1577        as uint8_t;
1578    if count as libc::c_int > oldcount as libc::c_int {
1579        let mut _p_0: *mut uint8_t = registers;
1580        let mut _byte_0: libc::c_ulong = (index * 6 as libc::c_int as libc::c_long
1581            / 8 as libc::c_int as libc::c_long) as libc::c_ulong;
1582        let mut _fb_0: libc::c_ulong = (index * 6 as libc::c_int as libc::c_long
1583            & 7 as libc::c_int as libc::c_long) as libc::c_ulong;
1584        let mut _fb8_0: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
1585            .wrapping_sub(_fb_0);
1586        let mut _v: libc::c_ulong = count as libc::c_ulong;
1587        let ref mut fresh0 = *_p_0.offset(_byte_0 as isize);
1588        *fresh0 = (*fresh0 as libc::c_int
1589            & !((((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int) << _fb_0))
1590            as uint8_t;
1591        let ref mut fresh1 = *_p_0.offset(_byte_0 as isize);
1592        *fresh1 = (*fresh1 as libc::c_ulong | _v << _fb_0) as uint8_t;
1593        let ref mut fresh2 = *_p_0
1594            .offset(_byte_0.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
1595        *fresh2 = (*fresh2 as libc::c_int
1596            & !(((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int >> _fb8_0))
1597            as uint8_t;
1598        let ref mut fresh3 = *_p_0
1599            .offset(_byte_0.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
1600        *fresh3 = (*fresh3 as libc::c_ulong | _v >> _fb8_0) as uint8_t;
1601        return 1 as libc::c_int;
1602    } else {
1603        return 0 as libc::c_int
1604    };
1605}
1606#[no_mangle]
1607pub unsafe extern "C" fn hllDenseAdd(
1608    mut registers: *mut uint8_t,
1609    mut ele: *mut libc::c_uchar,
1610    mut elesize: size_t,
1611) -> libc::c_int {
1612    let mut index: libc::c_long = 0;
1613    let mut count: uint8_t = hllPatLen(ele, elesize, &mut index) as uint8_t;
1614    return hllDenseSet(registers, index, count);
1615}
1616#[no_mangle]
1617pub unsafe extern "C" fn hllDenseRegHisto(
1618    mut registers: *mut uint8_t,
1619    mut reghisto: *mut libc::c_int,
1620) {
1621    let mut j: libc::c_int = 0;
1622    if (1 as libc::c_int) << 14 as libc::c_int == 16384 as libc::c_int
1623        && 6 as libc::c_int == 6 as libc::c_int
1624    {
1625        let mut r: *mut uint8_t = registers;
1626        let mut r0: libc::c_ulong = 0;
1627        let mut r1: libc::c_ulong = 0;
1628        let mut r2: libc::c_ulong = 0;
1629        let mut r3: libc::c_ulong = 0;
1630        let mut r4: libc::c_ulong = 0;
1631        let mut r5: libc::c_ulong = 0;
1632        let mut r6: libc::c_ulong = 0;
1633        let mut r7: libc::c_ulong = 0;
1634        let mut r8: libc::c_ulong = 0;
1635        let mut r9: libc::c_ulong = 0;
1636        let mut r10: libc::c_ulong = 0;
1637        let mut r11: libc::c_ulong = 0;
1638        let mut r12: libc::c_ulong = 0;
1639        let mut r13: libc::c_ulong = 0;
1640        let mut r14: libc::c_ulong = 0;
1641        let mut r15: libc::c_ulong = 0;
1642        j = 0 as libc::c_int;
1643        while j < 1024 as libc::c_int {
1644            r0 = (*r.offset(0 as libc::c_int as isize) as libc::c_int
1645                & 63 as libc::c_int) as libc::c_ulong;
1646            r1 = ((*r.offset(0 as libc::c_int as isize) as libc::c_int
1647                >> 6 as libc::c_int
1648                | (*r.offset(1 as libc::c_int as isize) as libc::c_int)
1649                    << 2 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1650            r2 = ((*r.offset(1 as libc::c_int as isize) as libc::c_int
1651                >> 4 as libc::c_int
1652                | (*r.offset(2 as libc::c_int as isize) as libc::c_int)
1653                    << 4 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1654            r3 = (*r.offset(2 as libc::c_int as isize) as libc::c_int >> 2 as libc::c_int
1655                & 63 as libc::c_int) as libc::c_ulong;
1656            r4 = (*r.offset(3 as libc::c_int as isize) as libc::c_int
1657                & 63 as libc::c_int) as libc::c_ulong;
1658            r5 = ((*r.offset(3 as libc::c_int as isize) as libc::c_int
1659                >> 6 as libc::c_int
1660                | (*r.offset(4 as libc::c_int as isize) as libc::c_int)
1661                    << 2 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1662            r6 = ((*r.offset(4 as libc::c_int as isize) as libc::c_int
1663                >> 4 as libc::c_int
1664                | (*r.offset(5 as libc::c_int as isize) as libc::c_int)
1665                    << 4 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1666            r7 = (*r.offset(5 as libc::c_int as isize) as libc::c_int >> 2 as libc::c_int
1667                & 63 as libc::c_int) as libc::c_ulong;
1668            r8 = (*r.offset(6 as libc::c_int as isize) as libc::c_int
1669                & 63 as libc::c_int) as libc::c_ulong;
1670            r9 = ((*r.offset(6 as libc::c_int as isize) as libc::c_int
1671                >> 6 as libc::c_int
1672                | (*r.offset(7 as libc::c_int as isize) as libc::c_int)
1673                    << 2 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1674            r10 = ((*r.offset(7 as libc::c_int as isize) as libc::c_int
1675                >> 4 as libc::c_int
1676                | (*r.offset(8 as libc::c_int as isize) as libc::c_int)
1677                    << 4 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1678            r11 = (*r.offset(8 as libc::c_int as isize) as libc::c_int
1679                >> 2 as libc::c_int & 63 as libc::c_int) as libc::c_ulong;
1680            r12 = (*r.offset(9 as libc::c_int as isize) as libc::c_int
1681                & 63 as libc::c_int) as libc::c_ulong;
1682            r13 = ((*r.offset(9 as libc::c_int as isize) as libc::c_int
1683                >> 6 as libc::c_int
1684                | (*r.offset(10 as libc::c_int as isize) as libc::c_int)
1685                    << 2 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1686            r14 = ((*r.offset(10 as libc::c_int as isize) as libc::c_int
1687                >> 4 as libc::c_int
1688                | (*r.offset(11 as libc::c_int as isize) as libc::c_int)
1689                    << 4 as libc::c_int) & 63 as libc::c_int) as libc::c_ulong;
1690            r15 = (*r.offset(11 as libc::c_int as isize) as libc::c_int
1691                >> 2 as libc::c_int & 63 as libc::c_int) as libc::c_ulong;
1692            let ref mut fresh4 = *reghisto.offset(r0 as isize);
1693            *fresh4 += 1;
1694            let ref mut fresh5 = *reghisto.offset(r1 as isize);
1695            *fresh5 += 1;
1696            let ref mut fresh6 = *reghisto.offset(r2 as isize);
1697            *fresh6 += 1;
1698            let ref mut fresh7 = *reghisto.offset(r3 as isize);
1699            *fresh7 += 1;
1700            let ref mut fresh8 = *reghisto.offset(r4 as isize);
1701            *fresh8 += 1;
1702            let ref mut fresh9 = *reghisto.offset(r5 as isize);
1703            *fresh9 += 1;
1704            let ref mut fresh10 = *reghisto.offset(r6 as isize);
1705            *fresh10 += 1;
1706            let ref mut fresh11 = *reghisto.offset(r7 as isize);
1707            *fresh11 += 1;
1708            let ref mut fresh12 = *reghisto.offset(r8 as isize);
1709            *fresh12 += 1;
1710            let ref mut fresh13 = *reghisto.offset(r9 as isize);
1711            *fresh13 += 1;
1712            let ref mut fresh14 = *reghisto.offset(r10 as isize);
1713            *fresh14 += 1;
1714            let ref mut fresh15 = *reghisto.offset(r11 as isize);
1715            *fresh15 += 1;
1716            let ref mut fresh16 = *reghisto.offset(r12 as isize);
1717            *fresh16 += 1;
1718            let ref mut fresh17 = *reghisto.offset(r13 as isize);
1719            *fresh17 += 1;
1720            let ref mut fresh18 = *reghisto.offset(r14 as isize);
1721            *fresh18 += 1;
1722            let ref mut fresh19 = *reghisto.offset(r15 as isize);
1723            *fresh19 += 1;
1724            r = r.offset(12 as libc::c_int as isize);
1725            j += 1;
1726        }
1727    } else {
1728        j = 0 as libc::c_int;
1729        while j < (1 as libc::c_int) << 14 as libc::c_int {
1730            let mut reg: libc::c_ulong = 0;
1731            let mut _p: *mut uint8_t = registers;
1732            let mut _byte: libc::c_ulong = (j * 6 as libc::c_int / 8 as libc::c_int)
1733                as libc::c_ulong;
1734            let mut _fb: libc::c_ulong = (j * 6 as libc::c_int & 7 as libc::c_int)
1735                as libc::c_ulong;
1736            let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
1737                .wrapping_sub(_fb);
1738            let mut b0: libc::c_ulong = *_p.offset(_byte as isize) as libc::c_ulong;
1739            let mut b1: libc::c_ulong = *_p
1740                .offset(_byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize)
1741                as libc::c_ulong;
1742            reg = (b0 >> _fb | b1 << _fb8)
1743                & (((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
1744                    as libc::c_ulong;
1745            let ref mut fresh20 = *reghisto.offset(reg as isize);
1746            *fresh20 += 1;
1747            j += 1;
1748        }
1749    };
1750}
1751#[no_mangle]
1752pub unsafe extern "C" fn hllSparseToDense(mut o: *mut robj) -> libc::c_int {
1753    let mut sparse: sds = (*o).ptr as sds;
1754    let mut dense: sds = 0 as *mut libc::c_char;
1755    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
1756    let mut oldhdr: *mut hllhdr = sparse as *mut hllhdr;
1757    let mut idx: libc::c_int = 0 as libc::c_int;
1758    let mut runlen: libc::c_int = 0;
1759    let mut regval: libc::c_int = 0;
1760    let mut p: *mut uint8_t = sparse as *mut uint8_t;
1761    let mut end: *mut uint8_t = p.offset(sdslen(sparse) as isize);
1762    hdr = sparse as *mut hllhdr;
1763    if (*hdr).encoding as libc::c_int == 0 as libc::c_int {
1764        return 0 as libc::c_int;
1765    }
1766    dense = sdsnewlen(
1767        0 as *const libc::c_void,
1768        (core::mem::size_of::<hllhdr>() as libc::c_ulong)
1769            .wrapping_add(
1770                ((((1 as libc::c_int) << 14 as libc::c_int) * 6 as libc::c_int
1771                    + 7 as libc::c_int) / 8 as libc::c_int) as libc::c_ulong,
1772            ),
1773    );
1774    hdr = dense as *mut hllhdr;
1775    *hdr = *oldhdr;
1776    (*hdr).encoding = 0 as libc::c_int as uint8_t;
1777    p = p.offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
1778    while p < end {
1779        if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
1780            runlen = (*p as libc::c_int & 0x3f as libc::c_int) + 1 as libc::c_int;
1781            idx += runlen;
1782            p = p.offset(1);
1783        } else if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
1784            runlen = ((*p as libc::c_int & 0x3f as libc::c_int) << 8 as libc::c_int
1785                | *p.offset(1 as libc::c_int as isize) as libc::c_int)
1786                + 1 as libc::c_int;
1787            idx += runlen;
1788            p = p.offset(2 as libc::c_int as isize);
1789        } else {
1790            runlen = (*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int;
1791            regval = (*p as libc::c_int >> 2 as libc::c_int & 0x1f as libc::c_int)
1792                + 1 as libc::c_int;
1793            if runlen + idx > (1 as libc::c_int) << 14 as libc::c_int {
1794                break;
1795            }
1796            loop {
1797                let fresh21 = runlen;
1798                runlen = runlen - 1;
1799                if !(fresh21 != 0) {
1800                    break;
1801                }
1802                let mut _p: *mut uint8_t = ((*hdr).registers).as_mut_ptr();
1803                let mut _byte: libc::c_ulong = (idx * 6 as libc::c_int
1804                    / 8 as libc::c_int) as libc::c_ulong;
1805                let mut _fb: libc::c_ulong = (idx * 6 as libc::c_int & 7 as libc::c_int)
1806                    as libc::c_ulong;
1807                let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
1808                    .wrapping_sub(_fb);
1809                let mut _v: libc::c_ulong = regval as libc::c_ulong;
1810                let ref mut fresh22 = *_p.offset(_byte as isize);
1811                *fresh22 = (*fresh22 as libc::c_int
1812                    & !((((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
1813                        << _fb)) as uint8_t;
1814                let ref mut fresh23 = *_p.offset(_byte as isize);
1815                *fresh23 = (*fresh23 as libc::c_ulong | _v << _fb) as uint8_t;
1816                let ref mut fresh24 = *_p
1817                    .offset(
1818                        _byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize,
1819                    );
1820                *fresh24 = (*fresh24 as libc::c_int
1821                    & !(((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int
1822                        >> _fb8)) as uint8_t;
1823                let ref mut fresh25 = *_p
1824                    .offset(
1825                        _byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize,
1826                    );
1827                *fresh25 = (*fresh25 as libc::c_ulong | _v >> _fb8) as uint8_t;
1828                idx += 1;
1829            }
1830            p = p.offset(1);
1831        }
1832    }
1833    if idx != (1 as libc::c_int) << 14 as libc::c_int {
1834        sdsfree(dense);
1835        return -(1 as libc::c_int);
1836    }
1837    sdsfree((*o).ptr as sds);
1838    (*o).ptr = dense as *mut libc::c_void;
1839    return 0 as libc::c_int;
1840}
1841#[no_mangle]
1842pub unsafe extern "C" fn hllSparseSet(
1843    mut o: *mut robj,
1844    mut index: libc::c_long,
1845    mut count: uint8_t,
1846) -> libc::c_int {
1847    let mut seq: [uint8_t; 5] = [0; 5];
1848    let mut n: *mut uint8_t = 0 as *mut uint8_t;
1849    let mut last: libc::c_int = 0;
1850    let mut len: libc::c_int = 0;
1851    let mut seqlen: libc::c_int = 0;
1852    let mut oldlen: libc::c_int = 0;
1853    let mut deltalen: libc::c_int = 0;
1854    let mut scanlen: libc::c_int = 0;
1855    let mut current_block: u64;
1856    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
1857    let mut oldcount: uint8_t = 0;
1858    let mut sparse: *mut uint8_t = 0 as *mut uint8_t;
1859    let mut end: *mut uint8_t = 0 as *mut uint8_t;
1860    let mut p: *mut uint8_t = 0 as *mut uint8_t;
1861    let mut prev: *mut uint8_t = 0 as *mut uint8_t;
1862    let mut next: *mut uint8_t = 0 as *mut uint8_t;
1863    let mut first: libc::c_long = 0;
1864    let mut span: libc::c_long = 0;
1865    let mut is_zero: libc::c_long = 0 as libc::c_int as libc::c_long;
1866    let mut is_xzero: libc::c_long = 0 as libc::c_int as libc::c_long;
1867    let mut is_val: libc::c_long = 0 as libc::c_int as libc::c_long;
1868    let mut runlen: libc::c_long = 0 as libc::c_int as libc::c_long;
1869    if !(count as libc::c_int > 32 as libc::c_int) {
1870        (*o)
1871            .ptr = sdsMakeRoomFor((*o).ptr as sds, 3 as libc::c_int as size_t)
1872            as *mut libc::c_void;
1873        p = ((*o).ptr as *mut uint8_t)
1874            .offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
1875        sparse = p;
1876        end = p
1877            .offset(sdslen((*o).ptr as sds) as isize)
1878            .offset(-(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize));
1879        first = 0 as libc::c_int as libc::c_long;
1880        prev = 0 as *mut uint8_t;
1881        next = 0 as *mut uint8_t;
1882        span = 0 as libc::c_int as libc::c_long;
1883        while p < end {
1884            let mut oplen: libc::c_long = 0;
1885            oplen = 1 as libc::c_int as libc::c_long;
1886            if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
1887                span = ((*p as libc::c_int & 0x3f as libc::c_int) + 1 as libc::c_int)
1888                    as libc::c_long;
1889            } else if *p as libc::c_int & 0x80 as libc::c_int != 0 {
1890                span = ((*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int)
1891                    as libc::c_long;
1892            } else {
1893                span = (((*p as libc::c_int & 0x3f as libc::c_int) << 8 as libc::c_int
1894                    | *p.offset(1 as libc::c_int as isize) as libc::c_int)
1895                    + 1 as libc::c_int) as libc::c_long;
1896                oplen = 2 as libc::c_int as libc::c_long;
1897            }
1898            if index <= first + span - 1 as libc::c_int as libc::c_long {
1899                break;
1900            }
1901            prev = p;
1902            p = p.offset(oplen as isize);
1903            first += span;
1904        }
1905        if span == 0 as libc::c_int as libc::c_long || p >= end {
1906            return -(1 as libc::c_int);
1907        }
1908        next = if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
1909            p.offset(2 as libc::c_int as isize)
1910        } else {
1911            p.offset(1 as libc::c_int as isize)
1912        };
1913        if next >= end {
1914            next = 0 as *mut uint8_t;
1915        }
1916        if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
1917            is_zero = 1 as libc::c_int as libc::c_long;
1918            runlen = ((*p as libc::c_int & 0x3f as libc::c_int) + 1 as libc::c_int)
1919                as libc::c_long;
1920        } else if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
1921            is_xzero = 1 as libc::c_int as libc::c_long;
1922            runlen = (((*p as libc::c_int & 0x3f as libc::c_int) << 8 as libc::c_int
1923                | *p.offset(1 as libc::c_int as isize) as libc::c_int)
1924                + 1 as libc::c_int) as libc::c_long;
1925        } else {
1926            is_val = 1 as libc::c_int as libc::c_long;
1927            runlen = ((*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int)
1928                as libc::c_long;
1929        }
1930        if is_val != 0 {
1931            oldcount = ((*p as libc::c_int >> 2 as libc::c_int & 0x1f as libc::c_int)
1932                + 1 as libc::c_int) as uint8_t;
1933            if oldcount as libc::c_int >= count as libc::c_int {
1934                return 0 as libc::c_int;
1935            }
1936            if runlen == 1 as libc::c_int as libc::c_long {
1937                *p = ((count as libc::c_int - 1 as libc::c_int) << 2 as libc::c_int
1938                    | 1 as libc::c_int - 1 as libc::c_int | 0x80 as libc::c_int)
1939                    as uint8_t;
1940                current_block = 1772724598971987819;
1941            } else {
1942                current_block = 7746103178988627676;
1943            }
1944        } else {
1945            current_block = 7746103178988627676;
1946        }
1947        match current_block {
1948            7746103178988627676 => {
1949                if is_zero != 0 && runlen == 1 as libc::c_int as libc::c_long {
1950                    *p = ((count as libc::c_int - 1 as libc::c_int) << 2 as libc::c_int
1951                        | 1 as libc::c_int - 1 as libc::c_int | 0x80 as libc::c_int)
1952                        as uint8_t;
1953                    current_block = 1772724598971987819;
1954                } else {
1955                    seq = [0; 5];
1956                    n = seq.as_mut_ptr();
1957                    last = (first + span - 1 as libc::c_int as libc::c_long)
1958                        as libc::c_int;
1959                    len = 0;
1960                    if is_zero != 0 || is_xzero != 0 {
1961                        if index != first {
1962                            len = (index - first) as libc::c_int;
1963                            if len > 64 as libc::c_int {
1964                                let mut _l: libc::c_int = len - 1 as libc::c_int;
1965                                *n = (_l >> 8 as libc::c_int | 0x40 as libc::c_int)
1966                                    as uint8_t;
1967                                *n
1968                                    .offset(
1969                                        1 as libc::c_int as isize,
1970                                    ) = (_l & 0xff as libc::c_int) as uint8_t;
1971                                n = n.offset(2 as libc::c_int as isize);
1972                            } else {
1973                                *n = (len - 1 as libc::c_int) as uint8_t;
1974                                n = n.offset(1);
1975                            }
1976                        }
1977                        *n = ((count as libc::c_int - 1 as libc::c_int)
1978                            << 2 as libc::c_int | 1 as libc::c_int - 1 as libc::c_int
1979                            | 0x80 as libc::c_int) as uint8_t;
1980                        n = n.offset(1);
1981                        if index != last as libc::c_long {
1982                            len = (last as libc::c_long - index) as libc::c_int;
1983                            if len > 64 as libc::c_int {
1984                                let mut _l_0: libc::c_int = len - 1 as libc::c_int;
1985                                *n = (_l_0 >> 8 as libc::c_int | 0x40 as libc::c_int)
1986                                    as uint8_t;
1987                                *n
1988                                    .offset(
1989                                        1 as libc::c_int as isize,
1990                                    ) = (_l_0 & 0xff as libc::c_int) as uint8_t;
1991                                n = n.offset(2 as libc::c_int as isize);
1992                            } else {
1993                                *n = (len - 1 as libc::c_int) as uint8_t;
1994                                n = n.offset(1);
1995                            }
1996                        }
1997                    } else {
1998                        let mut curval: libc::c_int = (*p as libc::c_int
1999                            >> 2 as libc::c_int & 0x1f as libc::c_int)
2000                            + 1 as libc::c_int;
2001                        if index != first {
2002                            len = (index - first) as libc::c_int;
2003                            *n = ((curval - 1 as libc::c_int) << 2 as libc::c_int
2004                                | len - 1 as libc::c_int | 0x80 as libc::c_int) as uint8_t;
2005                            n = n.offset(1);
2006                        }
2007                        *n = ((count as libc::c_int - 1 as libc::c_int)
2008                            << 2 as libc::c_int | 1 as libc::c_int - 1 as libc::c_int
2009                            | 0x80 as libc::c_int) as uint8_t;
2010                        n = n.offset(1);
2011                        if index != last as libc::c_long {
2012                            len = (last as libc::c_long - index) as libc::c_int;
2013                            *n = ((curval - 1 as libc::c_int) << 2 as libc::c_int
2014                                | len - 1 as libc::c_int | 0x80 as libc::c_int) as uint8_t;
2015                            n = n.offset(1);
2016                        }
2017                    }
2018                    seqlen = n.offset_from(seq.as_mut_ptr()) as libc::c_long
2019                        as libc::c_int;
2020                    oldlen = if is_xzero != 0 {
2021                        2 as libc::c_int
2022                    } else {
2023                        1 as libc::c_int
2024                    };
2025                    deltalen = seqlen - oldlen;
2026                    if deltalen > 0 as libc::c_int
2027                        && (sdslen((*o).ptr as sds))
2028                            .wrapping_add(deltalen as libc::c_ulong)
2029                            > server.hll_sparse_max_bytes
2030                    {
2031                        current_block = 18064604767964208725;
2032                    } else {
2033                        if deltalen != 0 && !next.is_null() {
2034                            memmove(
2035                                next.offset(deltalen as isize) as *mut libc::c_void,
2036                                next as *const libc::c_void,
2037                                end.offset_from(next) as libc::c_long as libc::c_ulong,
2038                            );
2039                        }
2040                        sdsIncrLen((*o).ptr as sds, deltalen as ssize_t);
2041                        memcpy(
2042                            p as *mut libc::c_void,
2043                            seq.as_mut_ptr() as *const libc::c_void,
2044                            seqlen as libc::c_ulong,
2045                        );
2046                        end = end.offset(deltalen as isize);
2047                        current_block = 1772724598971987819;
2048                    }
2049                }
2050            }
2051            _ => {}
2052        }
2053        match current_block {
2054            18064604767964208725 => {}
2055            _ => {
2056                p = if !prev.is_null() { prev } else { sparse };
2057                scanlen = 5 as libc::c_int;
2058                while p < end
2059                    && {
2060                        let fresh26 = scanlen;
2061                        scanlen = scanlen - 1;
2062                        fresh26 != 0
2063                    }
2064                {
2065                    if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
2066                        p = p.offset(2 as libc::c_int as isize);
2067                    } else if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int
2068                    {
2069                        p = p.offset(1);
2070                    } else {
2071                        if p.offset(1 as libc::c_int as isize) < end
2072                            && *p.offset(1 as libc::c_int as isize) as libc::c_int
2073                                & 0x80 as libc::c_int != 0
2074                        {
2075                            let mut v1: libc::c_int = (*p as libc::c_int
2076                                >> 2 as libc::c_int & 0x1f as libc::c_int)
2077                                + 1 as libc::c_int;
2078                            let mut v2: libc::c_int = (*p
2079                                .offset(1 as libc::c_int as isize) as libc::c_int
2080                                >> 2 as libc::c_int & 0x1f as libc::c_int)
2081                                + 1 as libc::c_int;
2082                            if v1 == v2 {
2083                                let mut len_0: libc::c_int = (*p as libc::c_int
2084                                    & 0x3 as libc::c_int) + 1 as libc::c_int
2085                                    + ((*p.offset(1 as libc::c_int as isize) as libc::c_int
2086                                        & 0x3 as libc::c_int) + 1 as libc::c_int);
2087                                if len_0 <= 4 as libc::c_int {
2088                                    *p
2089                                        .offset(
2090                                            1 as libc::c_int as isize,
2091                                        ) = ((v1 - 1 as libc::c_int) << 2 as libc::c_int
2092                                        | len_0 - 1 as libc::c_int | 0x80 as libc::c_int)
2093                                        as uint8_t;
2094                                    memmove(
2095                                        p as *mut libc::c_void,
2096                                        p.offset(1 as libc::c_int as isize) as *const libc::c_void,
2097                                        end.offset_from(p) as libc::c_long as libc::c_ulong,
2098                                    );
2099                                    sdsIncrLen((*o).ptr as sds, -(1 as libc::c_int) as ssize_t);
2100                                    end = end.offset(-1);
2101                                    continue;
2102                                }
2103                            }
2104                        }
2105                        p = p.offset(1);
2106                    }
2107                }
2108                hdr = (*o).ptr as *mut hllhdr;
2109                (*hdr)
2110                    .card[7 as libc::c_int
2111                    as usize] = ((*hdr).card[7 as libc::c_int as usize] as libc::c_int
2112                    | (1 as libc::c_int) << 7 as libc::c_int) as uint8_t;
2113                return 1 as libc::c_int;
2114            }
2115        }
2116    }
2117    if hllSparseToDense(o) == -(1 as libc::c_int) {
2118        return -(1 as libc::c_int);
2119    }
2120    hdr = (*o).ptr as *mut hllhdr;
2121    let mut dense_retval: libc::c_int = hllDenseSet(
2122        ((*hdr).registers).as_mut_ptr(),
2123        index,
2124        count,
2125    );
2126    if dense_retval == 1 as libc::c_int {} else {
2127        _serverAssert(
2128            b"dense_retval == 1\0" as *const u8 as *const libc::c_char,
2129            b"hyperloglog.c\0" as *const u8 as *const libc::c_char,
2130            894 as libc::c_int,
2131        );
2132        unreachable!();
2133    };
2134    return dense_retval;
2135}
2136#[no_mangle]
2137pub unsafe extern "C" fn hllSparseAdd(
2138    mut o: *mut robj,
2139    mut ele: *mut libc::c_uchar,
2140    mut elesize: size_t,
2141) -> libc::c_int {
2142    let mut index: libc::c_long = 0;
2143    let mut count: uint8_t = hllPatLen(ele, elesize, &mut index) as uint8_t;
2144    return hllSparseSet(o, index, count);
2145}
2146#[no_mangle]
2147pub unsafe extern "C" fn hllSparseRegHisto(
2148    mut sparse: *mut uint8_t,
2149    mut sparselen: libc::c_int,
2150    mut invalid: *mut libc::c_int,
2151    mut reghisto: *mut libc::c_int,
2152) {
2153    let mut idx: libc::c_int = 0 as libc::c_int;
2154    let mut runlen: libc::c_int = 0;
2155    let mut regval: libc::c_int = 0;
2156    let mut end: *mut uint8_t = sparse.offset(sparselen as isize);
2157    let mut p: *mut uint8_t = sparse;
2158    while p < end {
2159        if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
2160            runlen = (*p as libc::c_int & 0x3f as libc::c_int) + 1 as libc::c_int;
2161            idx += runlen;
2162            *reghisto.offset(0 as libc::c_int as isize) += runlen;
2163            p = p.offset(1);
2164        } else if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
2165            runlen = ((*p as libc::c_int & 0x3f as libc::c_int) << 8 as libc::c_int
2166                | *p.offset(1 as libc::c_int as isize) as libc::c_int)
2167                + 1 as libc::c_int;
2168            idx += runlen;
2169            *reghisto.offset(0 as libc::c_int as isize) += runlen;
2170            p = p.offset(2 as libc::c_int as isize);
2171        } else {
2172            runlen = (*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int;
2173            regval = (*p as libc::c_int >> 2 as libc::c_int & 0x1f as libc::c_int)
2174                + 1 as libc::c_int;
2175            idx += runlen;
2176            *reghisto.offset(regval as isize) += runlen;
2177            p = p.offset(1);
2178        }
2179    }
2180    if idx != (1 as libc::c_int) << 14 as libc::c_int && !invalid.is_null() {
2181        *invalid = 1 as libc::c_int;
2182    }
2183}
2184#[no_mangle]
2185pub unsafe extern "C" fn hllRawRegHisto(
2186    mut registers: *mut uint8_t,
2187    mut reghisto: *mut libc::c_int,
2188) {
2189    let mut word: *mut uint64_t = registers as *mut uint64_t;
2190    let mut bytes: *mut uint8_t = 0 as *mut uint8_t;
2191    let mut j: libc::c_int = 0;
2192    j = 0 as libc::c_int;
2193    while j < ((1 as libc::c_int) << 14 as libc::c_int) / 8 as libc::c_int {
2194        if *word == 0 as libc::c_int as libc::c_ulong {
2195            *reghisto.offset(0 as libc::c_int as isize) += 8 as libc::c_int;
2196        } else {
2197            bytes = word as *mut uint8_t;
2198            let ref mut fresh27 = *reghisto
2199                .offset(*bytes.offset(0 as libc::c_int as isize) as isize);
2200            *fresh27 += 1;
2201            let ref mut fresh28 = *reghisto
2202                .offset(*bytes.offset(1 as libc::c_int as isize) as isize);
2203            *fresh28 += 1;
2204            let ref mut fresh29 = *reghisto
2205                .offset(*bytes.offset(2 as libc::c_int as isize) as isize);
2206            *fresh29 += 1;
2207            let ref mut fresh30 = *reghisto
2208                .offset(*bytes.offset(3 as libc::c_int as isize) as isize);
2209            *fresh30 += 1;
2210            let ref mut fresh31 = *reghisto
2211                .offset(*bytes.offset(4 as libc::c_int as isize) as isize);
2212            *fresh31 += 1;
2213            let ref mut fresh32 = *reghisto
2214                .offset(*bytes.offset(5 as libc::c_int as isize) as isize);
2215            *fresh32 += 1;
2216            let ref mut fresh33 = *reghisto
2217                .offset(*bytes.offset(6 as libc::c_int as isize) as isize);
2218            *fresh33 += 1;
2219            let ref mut fresh34 = *reghisto
2220                .offset(*bytes.offset(7 as libc::c_int as isize) as isize);
2221            *fresh34 += 1;
2222        }
2223        word = word.offset(1);
2224        j += 1;
2225    }
2226}
2227#[no_mangle]
2228pub unsafe extern "C" fn hllSigma(mut x: libc::c_double) -> libc::c_double {
2229    if x == 1.0f64 {
2230        return core::f32::INFINITY as libc::c_double;
2231    }
2232    let mut zPrime: libc::c_double = 0.;
2233    let mut y: libc::c_double = 1 as libc::c_int as libc::c_double;
2234    let mut z: libc::c_double = x;
2235    loop {
2236        x *= x;
2237        zPrime = z;
2238        z += x * y;
2239        y += y;
2240        if !(zPrime != z) {
2241            break;
2242        }
2243    }
2244    return z;
2245}
2246#[no_mangle]
2247pub unsafe extern "C" fn hllTau(mut x: libc::c_double) -> libc::c_double {
2248    if x == 0.0f64 || x == 1.0f64 {
2249        return 0.0f64;
2250    }
2251    let mut zPrime: libc::c_double = 0.;
2252    let mut y: libc::c_double = 1.0f64;
2253    let mut z: libc::c_double = 1 as libc::c_int as libc::c_double - x;
2254    loop {
2255        x = sqrt(x);
2256        zPrime = z;
2257        y *= 0.5f64;
2258        z
2259            -= pow(
2260                1 as libc::c_int as libc::c_double - x,
2261                2 as libc::c_int as libc::c_double,
2262            ) * y;
2263        if !(zPrime != z) {
2264            break;
2265        }
2266    }
2267    return z / 3 as libc::c_int as libc::c_double;
2268}
2269#[no_mangle]
2270pub unsafe extern "C" fn hllCount(
2271    mut hdr: *mut hllhdr,
2272    mut invalid: *mut libc::c_int,
2273) -> uint64_t {
2274    let mut m: libc::c_double = ((1 as libc::c_int) << 14 as libc::c_int)
2275        as libc::c_double;
2276    let mut E: libc::c_double = 0.;
2277    let mut j: libc::c_int = 0;
2278    let mut reghisto: [libc::c_int; 64] = [
2279        0 as libc::c_int,
2280        0,
2281        0,
2282        0,
2283        0,
2284        0,
2285        0,
2286        0,
2287        0,
2288        0,
2289        0,
2290        0,
2291        0,
2292        0,
2293        0,
2294        0,
2295        0,
2296        0,
2297        0,
2298        0,
2299        0,
2300        0,
2301        0,
2302        0,
2303        0,
2304        0,
2305        0,
2306        0,
2307        0,
2308        0,
2309        0,
2310        0,
2311        0,
2312        0,
2313        0,
2314        0,
2315        0,
2316        0,
2317        0,
2318        0,
2319        0,
2320        0,
2321        0,
2322        0,
2323        0,
2324        0,
2325        0,
2326        0,
2327        0,
2328        0,
2329        0,
2330        0,
2331        0,
2332        0,
2333        0,
2334        0,
2335        0,
2336        0,
2337        0,
2338        0,
2339        0,
2340        0,
2341        0,
2342        0,
2343    ];
2344    if (*hdr).encoding as libc::c_int == 0 as libc::c_int {
2345        hllDenseRegHisto(((*hdr).registers).as_mut_ptr(), reghisto.as_mut_ptr());
2346    } else if (*hdr).encoding as libc::c_int == 1 as libc::c_int {
2347        hllSparseRegHisto(
2348            ((*hdr).registers).as_mut_ptr(),
2349            (sdslen(hdr as sds))
2350                .wrapping_sub(core::mem::size_of::<hllhdr>() as libc::c_ulong)
2351                as libc::c_int,
2352            invalid,
2353            reghisto.as_mut_ptr(),
2354        );
2355    } else if (*hdr).encoding as libc::c_int == 255 as libc::c_int {
2356        hllRawRegHisto(((*hdr).registers).as_mut_ptr(), reghisto.as_mut_ptr());
2357    } else {
2358        _serverPanic(
2359            b"hyperloglog.c\0" as *const u8 as *const libc::c_char,
2360            1034 as libc::c_int,
2361            b"Unknown HyperLogLog encoding in hllCount()\0" as *const u8
2362                as *const libc::c_char,
2363        );
2364        unreachable!();
2365    }
2366    let mut z: libc::c_double = m
2367        * hllTau(
2368            (m
2369                - reghisto[(64 as libc::c_int - 14 as libc::c_int + 1 as libc::c_int)
2370                    as usize] as libc::c_double) / m,
2371        );
2372    j = 64 as libc::c_int - 14 as libc::c_int;
2373    while j >= 1 as libc::c_int {
2374        z += reghisto[j as usize] as libc::c_double;
2375        z *= 0.5f64;
2376        j -= 1;
2377    }
2378    z += m * hllSigma(reghisto[0 as libc::c_int as usize] as libc::c_double / m);
2379    E = llroundl((0.721347520444481703680f64 * m * m / z) as f64)
2380        as libc::c_double;
2381    return E as uint64_t;
2382}
2383#[no_mangle]
2384pub unsafe extern "C" fn hllAdd(
2385    mut o: *mut robj,
2386    mut ele: *mut libc::c_uchar,
2387    mut elesize: size_t,
2388) -> libc::c_int {
2389    let mut hdr: *mut hllhdr = (*o).ptr as *mut hllhdr;
2390    match (*hdr).encoding as libc::c_int {
2391        0 => return hllDenseAdd(((*hdr).registers).as_mut_ptr(), ele, elesize),
2392        1 => return hllSparseAdd(o, ele, elesize),
2393        _ => return -(1 as libc::c_int),
2394    };
2395}
2396#[no_mangle]
2397pub unsafe extern "C" fn hllMerge(
2398    mut max: *mut uint8_t,
2399    mut hll: *mut robj,
2400) -> libc::c_int {
2401    let mut hdr: *mut hllhdr = (*hll).ptr as *mut hllhdr;
2402    let mut i: libc::c_int = 0;
2403    if (*hdr).encoding as libc::c_int == 0 as libc::c_int {
2404        let mut val: uint8_t = 0;
2405        i = 0 as libc::c_int;
2406        while i < (1 as libc::c_int) << 14 as libc::c_int {
2407            let mut _p: *mut uint8_t = ((*hdr).registers).as_mut_ptr();
2408            let mut _byte: libc::c_ulong = (i * 6 as libc::c_int / 8 as libc::c_int)
2409                as libc::c_ulong;
2410            let mut _fb: libc::c_ulong = (i * 6 as libc::c_int & 7 as libc::c_int)
2411                as libc::c_ulong;
2412            let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
2413                .wrapping_sub(_fb);
2414            let mut b0: libc::c_ulong = *_p.offset(_byte as isize) as libc::c_ulong;
2415            let mut b1: libc::c_ulong = *_p
2416                .offset(_byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize)
2417                as libc::c_ulong;
2418            val = ((b0 >> _fb | b1 << _fb8)
2419                & (((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
2420                    as libc::c_ulong) as uint8_t;
2421            if val as libc::c_int > *max.offset(i as isize) as libc::c_int {
2422                *max.offset(i as isize) = val;
2423            }
2424            i += 1;
2425        }
2426    } else {
2427        let mut p: *mut uint8_t = (*hll).ptr as *mut uint8_t;
2428        let mut end: *mut uint8_t = p.offset(sdslen((*hll).ptr as sds) as isize);
2429        let mut runlen: libc::c_long = 0;
2430        let mut regval: libc::c_long = 0;
2431        p = p.offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
2432        i = 0 as libc::c_int;
2433        while p < end {
2434            if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
2435                runlen = ((*p as libc::c_int & 0x3f as libc::c_int) + 1 as libc::c_int)
2436                    as libc::c_long;
2437                i = (i as libc::c_long + runlen) as libc::c_int;
2438                p = p.offset(1);
2439            } else if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int {
2440                runlen = (((*p as libc::c_int & 0x3f as libc::c_int) << 8 as libc::c_int
2441                    | *p.offset(1 as libc::c_int as isize) as libc::c_int)
2442                    + 1 as libc::c_int) as libc::c_long;
2443                i = (i as libc::c_long + runlen) as libc::c_int;
2444                p = p.offset(2 as libc::c_int as isize);
2445            } else {
2446                runlen = ((*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int)
2447                    as libc::c_long;
2448                regval = ((*p as libc::c_int >> 2 as libc::c_int & 0x1f as libc::c_int)
2449                    + 1 as libc::c_int) as libc::c_long;
2450                if runlen + i as libc::c_long
2451                    > ((1 as libc::c_int) << 14 as libc::c_int) as libc::c_long
2452                {
2453                    break;
2454                }
2455                loop {
2456                    let fresh35 = runlen;
2457                    runlen = runlen - 1;
2458                    if !(fresh35 != 0) {
2459                        break;
2460                    }
2461                    if regval > *max.offset(i as isize) as libc::c_long {
2462                        *max.offset(i as isize) = regval as uint8_t;
2463                    }
2464                    i += 1;
2465                }
2466                p = p.offset(1);
2467            }
2468        }
2469        if i != (1 as libc::c_int) << 14 as libc::c_int {
2470            return -(1 as libc::c_int);
2471        }
2472    }
2473    return 0 as libc::c_int;
2474}
2475#[no_mangle]
2476pub unsafe extern "C" fn createHLLObject() -> *mut robj {
2477    let mut o: *mut robj = 0 as *mut robj;
2478    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
2479    let mut s: sds = 0 as *mut libc::c_char;
2480    let mut p: *mut uint8_t = 0 as *mut uint8_t;
2481    let mut sparselen: libc::c_int = (core::mem::size_of::<hllhdr>() as libc::c_ulong)
2482        .wrapping_add(
2483            ((((1 as libc::c_int) << 14 as libc::c_int)
2484                + (16384 as libc::c_int - 1 as libc::c_int)) / 16384 as libc::c_int
2485                * 2 as libc::c_int) as libc::c_ulong,
2486        ) as libc::c_int;
2487    let mut aux: libc::c_int = 0;
2488    aux = (1 as libc::c_int) << 14 as libc::c_int;
2489    s = sdsnewlen(0 as *const libc::c_void, sparselen as size_t);
2490    p = (s as *mut uint8_t)
2491        .offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
2492    while aux != 0 {
2493        let mut xzero: libc::c_int = 16384 as libc::c_int;
2494        if xzero > aux {
2495            xzero = aux;
2496        }
2497        let mut _l: libc::c_int = xzero - 1 as libc::c_int;
2498        *p = (_l >> 8 as libc::c_int | 0x40 as libc::c_int) as uint8_t;
2499        *p.offset(1 as libc::c_int as isize) = (_l & 0xff as libc::c_int) as uint8_t;
2500        p = p.offset(2 as libc::c_int as isize);
2501        aux -= xzero;
2502    }
2503    if p.offset_from(s as *mut uint8_t) as libc::c_long == sparselen as libc::c_long
2504    {} else {
2505        _serverAssert(
2506            b"(p-(uint8_t*)s) == sparselen\0" as *const u8 as *const libc::c_char,
2507            b"hyperloglog.c\0" as *const u8 as *const libc::c_char,
2508            1137 as libc::c_int,
2509        );
2510        unreachable!();
2511    };
2512    o = createObject(0 as libc::c_int, s as *mut libc::c_void);
2513    hdr = (*o).ptr as *mut hllhdr;
2514    memcpy(
2515        ((*hdr).magic).as_mut_ptr() as *mut libc::c_void,
2516        b"HYLL\0" as *const u8 as *const libc::c_char as *const libc::c_void,
2517        4 as libc::c_int as libc::c_ulong,
2518    );
2519    (*hdr).encoding = 1 as libc::c_int as uint8_t;
2520    return o;
2521}
2522#[no_mangle]
2523pub unsafe extern "C" fn isHLLObjectOrReply(
2524    mut c: *mut client,
2525    mut o: *mut robj,
2526) -> libc::c_int {
2527    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
2528    if checkType(c, o, 0 as libc::c_int) != 0 {
2529        return -(1 as libc::c_int);
2530    }
2531    if (*o).encoding() as libc::c_int == 0 as libc::c_int
2532        || (*o).encoding() as libc::c_int == 8 as libc::c_int
2533    {
2534        if !(stringObjectLen(o) < core::mem::size_of::<hllhdr>() as libc::c_ulong) {
2535            hdr = (*o).ptr as *mut hllhdr;
2536            if !((*hdr).magic[0 as libc::c_int as usize] as libc::c_int != 'H' as i32
2537                || (*hdr).magic[1 as libc::c_int as usize] as libc::c_int != 'Y' as i32
2538                || (*hdr).magic[2 as libc::c_int as usize] as libc::c_int != 'L' as i32
2539                || (*hdr).magic[3 as libc::c_int as usize] as libc::c_int != 'L' as i32)
2540            {
2541                if !((*hdr).encoding as libc::c_int > 1 as libc::c_int) {
2542                    if !((*hdr).encoding as libc::c_int == 0 as libc::c_int
2543                        && stringObjectLen(o)
2544                            != (core::mem::size_of::<hllhdr>() as libc::c_ulong)
2545                                .wrapping_add(
2546                                    ((((1 as libc::c_int) << 14 as libc::c_int)
2547                                        * 6 as libc::c_int + 7 as libc::c_int) / 8 as libc::c_int)
2548                                        as libc::c_ulong,
2549                                ))
2550                    {
2551                        return 0 as libc::c_int;
2552                    }
2553                }
2554            }
2555        }
2556    }
2557    addReplyError(
2558        c,
2559        b"-WRONGTYPE Key is not a valid HyperLogLog string value.\0" as *const u8
2560            as *const libc::c_char,
2561    );
2562    return -(1 as libc::c_int);
2563}
2564#[no_mangle]
2565pub unsafe extern "C" fn pfaddCommand(mut c: *mut client) {
2566    let mut o: *mut robj = lookupKeyWrite(
2567        (*c).db,
2568        *((*c).argv).offset(1 as libc::c_int as isize),
2569    );
2570    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
2571    let mut updated: libc::c_int = 0 as libc::c_int;
2572    let mut j: libc::c_int = 0;
2573    if o.is_null() {
2574        o = createHLLObject();
2575        dbAdd((*c).db, *((*c).argv).offset(1 as libc::c_int as isize), o);
2576        updated += 1;
2577    } else {
2578        if isHLLObjectOrReply(c, o) != 0 as libc::c_int {
2579            return;
2580        }
2581        o = dbUnshareStringValue(
2582            (*c).db,
2583            *((*c).argv).offset(1 as libc::c_int as isize),
2584            o,
2585        );
2586    }
2587    j = 2 as libc::c_int;
2588    while j < (*c).argc {
2589        let mut retval: libc::c_int = hllAdd(
2590            o,
2591            (**((*c).argv).offset(j as isize)).ptr as *mut libc::c_uchar,
2592            sdslen((**((*c).argv).offset(j as isize)).ptr as sds),
2593        );
2594        match retval {
2595            1 => {
2596                updated += 1;
2597            }
2598            -1 => {
2599                addReplyError(c, invalid_hll_err);
2600                return;
2601            }
2602            _ => {}
2603        }
2604        j += 1;
2605    }
2606    hdr = (*o).ptr as *mut hllhdr;
2607    if updated != 0 {
2608        signalModifiedKey(c, (*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
2609        notifyKeyspaceEvent(
2610            (1 as libc::c_int) << 3 as libc::c_int,
2611            b"pfadd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2612            *((*c).argv).offset(1 as libc::c_int as isize),
2613            (*(*c).db).id,
2614        );
2615        server.dirty += updated as libc::c_longlong;
2616        (*hdr)
2617            .card[7 as libc::c_int
2618            as usize] = ((*hdr).card[7 as libc::c_int as usize] as libc::c_int
2619            | (1 as libc::c_int) << 7 as libc::c_int) as uint8_t;
2620    }
2621    addReply(c, if updated != 0 { shared.cone } else { shared.czero });
2622}
2623#[no_mangle]
2624pub unsafe extern "C" fn pfcountCommand(mut c: *mut client) {
2625    let mut o: *mut robj = 0 as *mut robj;
2626    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
2627    let mut card: uint64_t = 0;
2628    if (*c).argc > 2 as libc::c_int {
2629        let mut max: [uint8_t; 16400] = [0; 16400];
2630        let mut registers: *mut uint8_t = 0 as *mut uint8_t;
2631        let mut j: libc::c_int = 0;
2632        memset(
2633            max.as_mut_ptr() as *mut libc::c_void,
2634            0 as libc::c_int,
2635            core::mem::size_of::<[uint8_t; 16400]>() as libc::c_ulong,
2636        );
2637        hdr = max.as_mut_ptr() as *mut hllhdr;
2638        (*hdr).encoding = 255 as libc::c_int as uint8_t;
2639        registers = max
2640            .as_mut_ptr()
2641            .offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
2642        j = 1 as libc::c_int;
2643        while j < (*c).argc {
2644            let mut o_0: *mut robj = lookupKeyRead(
2645                (*c).db,
2646                *((*c).argv).offset(j as isize),
2647            );
2648            if !o_0.is_null() {
2649                if isHLLObjectOrReply(c, o_0) != 0 as libc::c_int {
2650                    return;
2651                }
2652                if hllMerge(registers, o_0) == -(1 as libc::c_int) {
2653                    addReplyError(c, invalid_hll_err);
2654                    return;
2655                }
2656            }
2657            j += 1;
2658        }
2659        addReplyLongLong(c, hllCount(hdr, 0 as *mut libc::c_int) as libc::c_longlong);
2660        return;
2661    }
2662    o = lookupKeyRead((*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
2663    if o.is_null() {
2664        addReply(c, shared.czero);
2665    } else {
2666        if isHLLObjectOrReply(c, o) != 0 as libc::c_int {
2667            return;
2668        }
2669        o = dbUnshareStringValue(
2670            (*c).db,
2671            *((*c).argv).offset(1 as libc::c_int as isize),
2672            o,
2673        );
2674        hdr = (*o).ptr as *mut hllhdr;
2675        if (*hdr).card[7 as libc::c_int as usize] as libc::c_int
2676            & (1 as libc::c_int) << 7 as libc::c_int == 0 as libc::c_int
2677        {
2678            card = (*hdr).card[0 as libc::c_int as usize] as uint64_t;
2679            card
2680                |= ((*hdr).card[1 as libc::c_int as usize] as uint64_t)
2681                    << 8 as libc::c_int;
2682            card
2683                |= ((*hdr).card[2 as libc::c_int as usize] as uint64_t)
2684                    << 16 as libc::c_int;
2685            card
2686                |= ((*hdr).card[3 as libc::c_int as usize] as uint64_t)
2687                    << 24 as libc::c_int;
2688            card
2689                |= ((*hdr).card[4 as libc::c_int as usize] as uint64_t)
2690                    << 32 as libc::c_int;
2691            card
2692                |= ((*hdr).card[5 as libc::c_int as usize] as uint64_t)
2693                    << 40 as libc::c_int;
2694            card
2695                |= ((*hdr).card[6 as libc::c_int as usize] as uint64_t)
2696                    << 48 as libc::c_int;
2697            card
2698                |= ((*hdr).card[7 as libc::c_int as usize] as uint64_t)
2699                    << 56 as libc::c_int;
2700        } else {
2701            let mut invalid: libc::c_int = 0 as libc::c_int;
2702            card = hllCount(hdr, &mut invalid);
2703            if invalid != 0 {
2704                addReplyError(c, invalid_hll_err);
2705                return;
2706            }
2707            (*hdr)
2708                .card[0 as libc::c_int
2709                as usize] = (card & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2710            (*hdr)
2711                .card[1 as libc::c_int
2712                as usize] = (card >> 8 as libc::c_int
2713                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2714            (*hdr)
2715                .card[2 as libc::c_int
2716                as usize] = (card >> 16 as libc::c_int
2717                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2718            (*hdr)
2719                .card[3 as libc::c_int
2720                as usize] = (card >> 24 as libc::c_int
2721                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2722            (*hdr)
2723                .card[4 as libc::c_int
2724                as usize] = (card >> 32 as libc::c_int
2725                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2726            (*hdr)
2727                .card[5 as libc::c_int
2728                as usize] = (card >> 40 as libc::c_int
2729                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2730            (*hdr)
2731                .card[6 as libc::c_int
2732                as usize] = (card >> 48 as libc::c_int
2733                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2734            (*hdr)
2735                .card[7 as libc::c_int
2736                as usize] = (card >> 56 as libc::c_int
2737                & 0xff as libc::c_int as libc::c_ulong) as uint8_t;
2738            signalModifiedKey(
2739                c,
2740                (*c).db,
2741                *((*c).argv).offset(1 as libc::c_int as isize),
2742            );
2743            server.dirty += 1;
2744        }
2745        addReplyLongLong(c, card as libc::c_longlong);
2746    };
2747}
2748#[no_mangle]
2749pub unsafe extern "C" fn pfmergeCommand(mut c: *mut client) {
2750    let mut max: [uint8_t; 16384] = [0; 16384];
2751    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
2752    let mut j: libc::c_int = 0;
2753    let mut use_dense: libc::c_int = 0 as libc::c_int;
2754    memset(
2755        max.as_mut_ptr() as *mut libc::c_void,
2756        0 as libc::c_int,
2757        core::mem::size_of::<[uint8_t; 16384]>() as libc::c_ulong,
2758    );
2759    j = 1 as libc::c_int;
2760    while j < (*c).argc {
2761        let mut o: *mut robj = lookupKeyRead((*c).db, *((*c).argv).offset(j as isize));
2762        if !o.is_null() {
2763            if isHLLObjectOrReply(c, o) != 0 as libc::c_int {
2764                return;
2765            }
2766            hdr = (*o).ptr as *mut hllhdr;
2767            if (*hdr).encoding as libc::c_int == 0 as libc::c_int {
2768                use_dense = 1 as libc::c_int;
2769            }
2770            if hllMerge(max.as_mut_ptr(), o) == -(1 as libc::c_int) {
2771                addReplyError(c, invalid_hll_err);
2772                return;
2773            }
2774        }
2775        j += 1;
2776    }
2777    let mut o_0: *mut robj = lookupKeyWrite(
2778        (*c).db,
2779        *((*c).argv).offset(1 as libc::c_int as isize),
2780    );
2781    if o_0.is_null() {
2782        o_0 = createHLLObject();
2783        dbAdd((*c).db, *((*c).argv).offset(1 as libc::c_int as isize), o_0);
2784    } else {
2785        o_0 = dbUnshareStringValue(
2786            (*c).db,
2787            *((*c).argv).offset(1 as libc::c_int as isize),
2788            o_0,
2789        );
2790    }
2791    if use_dense != 0 && hllSparseToDense(o_0) == -(1 as libc::c_int) {
2792        addReplyError(c, invalid_hll_err);
2793        return;
2794    }
2795    j = 0 as libc::c_int;
2796    while j < (1 as libc::c_int) << 14 as libc::c_int {
2797        if !(max[j as usize] as libc::c_int == 0 as libc::c_int) {
2798            hdr = (*o_0).ptr as *mut hllhdr;
2799            match (*hdr).encoding as libc::c_int {
2800                0 => {
2801                    hllDenseSet(
2802                        ((*hdr).registers).as_mut_ptr(),
2803                        j as libc::c_long,
2804                        max[j as usize],
2805                    );
2806                }
2807                1 => {
2808                    hllSparseSet(o_0, j as libc::c_long, max[j as usize]);
2809                }
2810                _ => {}
2811            }
2812        }
2813        j += 1;
2814    }
2815    hdr = (*o_0).ptr as *mut hllhdr;
2816    (*hdr)
2817        .card[7 as libc::c_int
2818        as usize] = ((*hdr).card[7 as libc::c_int as usize] as libc::c_int
2819        | (1 as libc::c_int) << 7 as libc::c_int) as uint8_t;
2820    signalModifiedKey(c, (*c).db, *((*c).argv).offset(1 as libc::c_int as isize));
2821    notifyKeyspaceEvent(
2822        (1 as libc::c_int) << 3 as libc::c_int,
2823        b"pfadd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2824        *((*c).argv).offset(1 as libc::c_int as isize),
2825        (*(*c).db).id,
2826    );
2827    server.dirty += 1;
2828    addReply(c, shared.ok);
2829}
2830#[no_mangle]
2831pub unsafe extern "C" fn pfselftestCommand(mut c: *mut client) {
2832    let mut relerr: libc::c_double = 0.;
2833    let mut checkpoint: int64_t = 0;
2834    let mut seed: uint64_t = 0;
2835    let mut ele: uint64_t = 0;
2836    let mut current_block: u64;
2837    let mut j: libc::c_uint = 0;
2838    let mut i: libc::c_uint = 0;
2839    let mut bitcounters: sds = sdsnewlen(
2840        0 as *const libc::c_void,
2841        (core::mem::size_of::<hllhdr>() as libc::c_ulong)
2842            .wrapping_add(
2843                ((((1 as libc::c_int) << 14 as libc::c_int) * 6 as libc::c_int
2844                    + 7 as libc::c_int) / 8 as libc::c_int) as libc::c_ulong,
2845            ),
2846    );
2847    let mut hdr: *mut hllhdr = bitcounters as *mut hllhdr;
2848    let mut hdr2: *mut hllhdr = 0 as *mut hllhdr;
2849    let mut o: *mut robj = 0 as *mut robj;
2850    let mut bytecounters: [uint8_t; 16384] = [0; 16384];
2851    j = 0 as libc::c_int as libc::c_uint;
2852    's_12: loop {
2853        if !(j < 1000 as libc::c_int as libc::c_uint) {
2854            current_block = 2719512138335094285;
2855            break;
2856        }
2857        i = 0 as libc::c_int as libc::c_uint;
2858        while i < ((1 as libc::c_int) << 14 as libc::c_int) as libc::c_uint {
2859            let mut r: libc::c_uint = (rand()
2860                & ((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
2861                as libc::c_uint;
2862            bytecounters[i as usize] = r as uint8_t;
2863            let mut _p: *mut uint8_t = ((*hdr).registers).as_mut_ptr();
2864            let mut _byte: libc::c_ulong = i
2865                .wrapping_mul(6 as libc::c_int as libc::c_uint)
2866                .wrapping_div(8 as libc::c_int as libc::c_uint) as libc::c_ulong;
2867            let mut _fb: libc::c_ulong = (i
2868                .wrapping_mul(6 as libc::c_int as libc::c_uint)
2869                & 7 as libc::c_int as libc::c_uint) as libc::c_ulong;
2870            let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
2871                .wrapping_sub(_fb);
2872            let mut _v: libc::c_ulong = r as libc::c_ulong;
2873            let ref mut fresh36 = *_p.offset(_byte as isize);
2874            *fresh36 = (*fresh36 as libc::c_int
2875                & !((((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
2876                    << _fb)) as uint8_t;
2877            let ref mut fresh37 = *_p.offset(_byte as isize);
2878            *fresh37 = (*fresh37 as libc::c_ulong | _v << _fb) as uint8_t;
2879            let ref mut fresh38 = *_p
2880                .offset(_byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
2881            *fresh38 = (*fresh38 as libc::c_int
2882                & !(((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int >> _fb8))
2883                as uint8_t;
2884            let ref mut fresh39 = *_p
2885                .offset(_byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize);
2886            *fresh39 = (*fresh39 as libc::c_ulong | _v >> _fb8) as uint8_t;
2887            i = i.wrapping_add(1);
2888        }
2889        i = 0 as libc::c_int as libc::c_uint;
2890        while i < ((1 as libc::c_int) << 14 as libc::c_int) as libc::c_uint {
2891            let mut val: libc::c_uint = 0;
2892            let mut _p_0: *mut uint8_t = ((*hdr).registers).as_mut_ptr();
2893            let mut _byte_0: libc::c_ulong = i
2894                .wrapping_mul(6 as libc::c_int as libc::c_uint)
2895                .wrapping_div(8 as libc::c_int as libc::c_uint) as libc::c_ulong;
2896            let mut _fb_0: libc::c_ulong = (i
2897                .wrapping_mul(6 as libc::c_int as libc::c_uint)
2898                & 7 as libc::c_int as libc::c_uint) as libc::c_ulong;
2899            let mut _fb8_0: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
2900                .wrapping_sub(_fb_0);
2901            let mut b0: libc::c_ulong = *_p_0.offset(_byte_0 as isize) as libc::c_ulong;
2902            let mut b1: libc::c_ulong = *_p_0
2903                .offset(_byte_0.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize)
2904                as libc::c_ulong;
2905            val = ((b0 >> _fb_0 | b1 << _fb8_0)
2906                & (((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
2907                    as libc::c_ulong) as libc::c_uint;
2908            if val != bytecounters[i as usize] as libc::c_uint {
2909                addReplyErrorFormat(
2910                    c,
2911                    b"TESTFAILED Register %d should be %d but is %d\0" as *const u8
2912                        as *const libc::c_char,
2913                    i,
2914                    bytecounters[i as usize] as libc::c_int,
2915                    val as libc::c_int,
2916                );
2917                current_block = 4808091333740361217;
2918                break 's_12;
2919            } else {
2920                i = i.wrapping_add(1);
2921            }
2922        }
2923        j = j.wrapping_add(1);
2924    }
2925    match current_block {
2926        2719512138335094285 => {
2927            memset(
2928                ((*hdr).registers).as_mut_ptr() as *mut libc::c_void,
2929                0 as libc::c_int,
2930                (core::mem::size_of::<hllhdr>() as libc::c_ulong)
2931                    .wrapping_add(
2932                        ((((1 as libc::c_int) << 14 as libc::c_int) * 6 as libc::c_int
2933                            + 7 as libc::c_int) / 8 as libc::c_int) as libc::c_ulong,
2934                    )
2935                    .wrapping_sub(core::mem::size_of::<hllhdr>() as libc::c_ulong),
2936            );
2937            o = createHLLObject();
2938            relerr = 1.04f64
2939                / sqrt(((1 as libc::c_int) << 14 as libc::c_int) as libc::c_double);
2940            checkpoint = 1 as libc::c_int as int64_t;
2941            seed = rand() as uint64_t | (rand() as uint64_t) << 32 as libc::c_int;
2942            ele = 0;
2943            j = 1 as libc::c_int as libc::c_uint;
2944            loop {
2945                if !(j <= 10000000 as libc::c_int as libc::c_uint) {
2946                    current_block = 12381812505308290051;
2947                    break;
2948                }
2949                ele = j as libc::c_ulong ^ seed;
2950                hllDenseAdd(
2951                    ((*hdr).registers).as_mut_ptr(),
2952                    &mut ele as *mut uint64_t as *mut libc::c_uchar,
2953                    core::mem::size_of::<uint64_t>() as libc::c_ulong,
2954                );
2955                hllAdd(
2956                    o,
2957                    &mut ele as *mut uint64_t as *mut libc::c_uchar,
2958                    core::mem::size_of::<uint64_t>() as libc::c_ulong,
2959                );
2960                if j as libc::c_long == checkpoint
2961                    && (j as libc::c_ulong)
2962                        < (server.hll_sparse_max_bytes)
2963                            .wrapping_div(2 as libc::c_int as libc::c_ulong)
2964                {
2965                    hdr2 = (*o).ptr as *mut hllhdr;
2966                    if (*hdr2).encoding as libc::c_int != 1 as libc::c_int {
2967                        addReplyError(
2968                            c,
2969                            b"TESTFAILED sparse encoding not used\0" as *const u8
2970                                as *const libc::c_char,
2971                        );
2972                        current_block = 4808091333740361217;
2973                        break;
2974                    }
2975                }
2976                if j as libc::c_long == checkpoint
2977                    && hllCount(hdr, 0 as *mut libc::c_int)
2978                        != hllCount((*o).ptr as *mut hllhdr, 0 as *mut libc::c_int)
2979                {
2980                    addReplyError(
2981                        c,
2982                        b"TESTFAILED dense/sparse disagree\0" as *const u8
2983                            as *const libc::c_char,
2984                    );
2985                    current_block = 4808091333740361217;
2986                    break;
2987                } else {
2988                    if j as libc::c_long == checkpoint {
2989                        let mut abserr: int64_t = checkpoint
2990                            - hllCount(hdr, 0 as *mut libc::c_int) as int64_t;
2991                        let mut maxerr: uint64_t = ceil(
2992                            relerr * 6 as libc::c_int as libc::c_double
2993                                * checkpoint as libc::c_double,
2994                        ) as uint64_t;
2995                        if j == 10 as libc::c_int as libc::c_uint {
2996                            maxerr = 1 as libc::c_int as uint64_t;
2997                        }
2998                        if abserr < 0 as libc::c_int as libc::c_long {
2999                            abserr = -abserr;
3000                        }
3001                        if abserr > maxerr as int64_t {
3002                            addReplyErrorFormat(
3003                                c,
3004                                b"TESTFAILED Too big error. card:%llu abserr:%llu\0"
3005                                    as *const u8 as *const libc::c_char,
3006                                checkpoint as libc::c_ulonglong,
3007                                abserr as libc::c_ulonglong,
3008                            );
3009                            current_block = 4808091333740361217;
3010                            break;
3011                        } else {
3012                            checkpoint *= 10 as libc::c_int as libc::c_long;
3013                        }
3014                    }
3015                    j = j.wrapping_add(1);
3016                }
3017            }
3018            match current_block {
3019                4808091333740361217 => {}
3020                _ => {
3021                    addReply(c, shared.ok);
3022                }
3023            }
3024        }
3025        _ => {}
3026    }
3027    sdsfree(bitcounters);
3028    if !o.is_null() {
3029        decrRefCount(o);
3030    }
3031}
3032#[no_mangle]
3033pub unsafe extern "C" fn pfdebugCommand(mut c: *mut client) {
3034    let mut current_block: u64;
3035    let mut cmd: *mut libc::c_char = (**((*c).argv).offset(1 as libc::c_int as isize))
3036        .ptr as *mut libc::c_char;
3037    let mut hdr: *mut hllhdr = 0 as *mut hllhdr;
3038    let mut o: *mut robj = 0 as *mut robj;
3039    let mut j: libc::c_int = 0;
3040    o = lookupKeyWrite((*c).db, *((*c).argv).offset(2 as libc::c_int as isize));
3041    if o.is_null() {
3042        addReplyError(
3043            c,
3044            b"The specified key does not exist\0" as *const u8 as *const libc::c_char,
3045        );
3046        return;
3047    }
3048    if isHLLObjectOrReply(c, o) != 0 as libc::c_int {
3049        return;
3050    }
3051    o = dbUnshareStringValue((*c).db, *((*c).argv).offset(2 as libc::c_int as isize), o);
3052    hdr = (*o).ptr as *mut hllhdr;
3053    if strcasecmp(cmd, b"getreg\0" as *const u8 as *const libc::c_char) == 0 {
3054        if (*c).argc != 3 as libc::c_int {
3055            current_block = 7351741740727689750;
3056        } else {
3057            if (*hdr).encoding as libc::c_int == 1 as libc::c_int {
3058                if hllSparseToDense(o) == -(1 as libc::c_int) {
3059                    addReplyError(c, invalid_hll_err);
3060                    return;
3061                }
3062                server.dirty += 1;
3063            }
3064            hdr = (*o).ptr as *mut hllhdr;
3065            addReplyArrayLen(
3066                c,
3067                ((1 as libc::c_int) << 14 as libc::c_int) as libc::c_long,
3068            );
3069            j = 0 as libc::c_int;
3070            while j < (1 as libc::c_int) << 14 as libc::c_int {
3071                let mut val: uint8_t = 0;
3072                let mut _p: *mut uint8_t = ((*hdr).registers).as_mut_ptr();
3073                let mut _byte: libc::c_ulong = (j * 6 as libc::c_int / 8 as libc::c_int)
3074                    as libc::c_ulong;
3075                let mut _fb: libc::c_ulong = (j * 6 as libc::c_int & 7 as libc::c_int)
3076                    as libc::c_ulong;
3077                let mut _fb8: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
3078                    .wrapping_sub(_fb);
3079                let mut b0: libc::c_ulong = *_p.offset(_byte as isize) as libc::c_ulong;
3080                let mut b1: libc::c_ulong = *_p
3081                    .offset(
3082                        _byte.wrapping_add(1 as libc::c_int as libc::c_ulong) as isize,
3083                    ) as libc::c_ulong;
3084                val = ((b0 >> _fb | b1 << _fb8)
3085                    & (((1 as libc::c_int) << 6 as libc::c_int) - 1 as libc::c_int)
3086                        as libc::c_ulong) as uint8_t;
3087                addReplyLongLong(c, val as libc::c_longlong);
3088                j += 1;
3089            }
3090            current_block = 16203797167131938757;
3091        }
3092    } else if strcasecmp(cmd, b"decode\0" as *const u8 as *const libc::c_char) == 0 {
3093        if (*c).argc != 3 as libc::c_int {
3094            current_block = 7351741740727689750;
3095        } else {
3096            let mut p: *mut uint8_t = (*o).ptr as *mut uint8_t;
3097            let mut end: *mut uint8_t = p.offset(sdslen((*o).ptr as sds) as isize);
3098            let mut decoded: sds = sdsempty();
3099            if (*hdr).encoding as libc::c_int != 1 as libc::c_int {
3100                sdsfree(decoded);
3101                addReplyError(
3102                    c,
3103                    b"HLL encoding is not sparse\0" as *const u8 as *const libc::c_char,
3104                );
3105                return;
3106            }
3107            p = p.offset(core::mem::size_of::<hllhdr>() as libc::c_ulong as isize);
3108            while p < end {
3109                let mut runlen: libc::c_int = 0;
3110                let mut regval: libc::c_int = 0;
3111                if *p as libc::c_int & 0xc0 as libc::c_int == 0 as libc::c_int {
3112                    runlen = (*p as libc::c_int & 0x3f as libc::c_int)
3113                        + 1 as libc::c_int;
3114                    p = p.offset(1);
3115                    decoded = sdscatprintf(
3116                        decoded,
3117                        b"z:%d \0" as *const u8 as *const libc::c_char,
3118                        runlen,
3119                    );
3120                } else if *p as libc::c_int & 0xc0 as libc::c_int == 0x40 as libc::c_int
3121                {
3122                    runlen = ((*p as libc::c_int & 0x3f as libc::c_int)
3123                        << 8 as libc::c_int
3124                        | *p.offset(1 as libc::c_int as isize) as libc::c_int)
3125                        + 1 as libc::c_int;
3126                    p = p.offset(2 as libc::c_int as isize);
3127                    decoded = sdscatprintf(
3128                        decoded,
3129                        b"Z:%d \0" as *const u8 as *const libc::c_char,
3130                        runlen,
3131                    );
3132                } else {
3133                    runlen = (*p as libc::c_int & 0x3 as libc::c_int) + 1 as libc::c_int;
3134                    regval = (*p as libc::c_int >> 2 as libc::c_int
3135                        & 0x1f as libc::c_int) + 1 as libc::c_int;
3136                    p = p.offset(1);
3137                    decoded = sdscatprintf(
3138                        decoded,
3139                        b"v:%d,%d \0" as *const u8 as *const libc::c_char,
3140                        regval,
3141                        runlen,
3142                    );
3143                }
3144            }
3145            decoded = sdstrim(decoded, b" \0" as *const u8 as *const libc::c_char);
3146            addReplyBulkCBuffer(c, decoded as *const libc::c_void, sdslen(decoded));
3147            sdsfree(decoded);
3148            current_block = 16203797167131938757;
3149        }
3150    } else if strcasecmp(cmd, b"encoding\0" as *const u8 as *const libc::c_char) == 0 {
3151        let mut encodingstr: [*mut libc::c_char; 2] = [
3152            b"dense\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3153            b"sparse\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
3154        ];
3155        if (*c).argc != 3 as libc::c_int {
3156            current_block = 7351741740727689750;
3157        } else {
3158            addReplyStatus(c, encodingstr[(*hdr).encoding as usize]);
3159            current_block = 16203797167131938757;
3160        }
3161    } else if strcasecmp(cmd, b"todense\0" as *const u8 as *const libc::c_char) == 0 {
3162        let mut conv: libc::c_int = 0 as libc::c_int;
3163        if (*c).argc != 3 as libc::c_int {
3164            current_block = 7351741740727689750;
3165        } else {
3166            if (*hdr).encoding as libc::c_int == 1 as libc::c_int {
3167                if hllSparseToDense(o) == -(1 as libc::c_int) {
3168                    addReplyError(c, invalid_hll_err);
3169                    return;
3170                }
3171                conv = 1 as libc::c_int;
3172                server.dirty += 1;
3173            }
3174            addReply(c, if conv != 0 { shared.cone } else { shared.czero });
3175            current_block = 16203797167131938757;
3176        }
3177    } else {
3178        addReplyErrorFormat(
3179            c,
3180            b"Unknown PFDEBUG subcommand '%s'\0" as *const u8 as *const libc::c_char,
3181            cmd,
3182        );
3183        current_block = 16203797167131938757;
3184    }
3185    match current_block {
3186        16203797167131938757 => return,
3187        _ => {
3188            addReplyErrorFormat(
3189                c,
3190                b"Wrong number of arguments for the '%s' subcommand\0" as *const u8
3191                    as *const libc::c_char,
3192                cmd,
3193            );
3194            return;
3195        }
3196    };
3197}