redrust 0.1.1

redrust is a port of the popular Redis database system written in Rust programming language. This port aims to provide all the features of Redis while taking advantage of the Rust language's safety, speed, and modern language features.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
extern crate c2rust_bitfields;
extern crate libc;
extern crate core;
extern "C" {
    fn snprintf(
        _: *mut libc::c_char,
        _: libc::c_ulong,
        _: *const libc::c_char,
        _: ...
    ) -> libc::c_int;
    fn random() -> libc::c_long;
    fn rand() -> libc::c_int;
    fn memcpy(
        _: *mut libc::c_void,
        _: *const libc::c_void,
        _: libc::c_ulong,
    ) -> *mut libc::c_void;
    fn memset(
        _: *mut libc::c_void,
        _: libc::c_int,
        _: libc::c_ulong,
    ) -> *mut libc::c_void;
    fn strlen(_: *const libc::c_char) -> libc::c_ulong;
    fn gettimeofday(__tv: *mut timeval, __tz: *mut libc::c_void) -> libc::c_int;
    fn genrand64_int64() -> libc::c_ulonglong;
    fn zmalloc(size: size_t) -> *mut libc::c_void;
    fn zcalloc(size: size_t) -> *mut libc::c_void;
    fn ztrycalloc(size: size_t) -> *mut libc::c_void;
    fn zfree(ptr: *mut libc::c_void);
    fn _serverAssert(
        estr: *const libc::c_char,
        file: *const libc::c_char,
        line: libc::c_int,
    );
    fn siphash(in_0: *const uint8_t, inlen: size_t, k: *const uint8_t) -> uint64_t;
    fn siphash_nocase(
        in_0: *const uint8_t,
        inlen: size_t,
        k: *const uint8_t,
    ) -> uint64_t;
}
pub type size_t = libc::c_ulong;
pub type __uint8_t = libc::c_uchar;
pub type __int16_t = libc::c_short;
pub type __int64_t = libc::c_long;
pub type __uint64_t = libc::c_ulong;
pub type __time_t = libc::c_long;
pub type __suseconds_t = libc::c_long;
pub type int16_t = __int16_t;
pub type int64_t = __int64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
    pub tv_sec: __time_t,
    pub tv_usec: __suseconds_t,
}
pub type uint8_t = __uint8_t;
pub type uint64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct dictEntry {
    pub key: *mut libc::c_void,
    pub v: C2RustUnnamed,
    pub next: *mut dictEntry,
    pub metadata: [*mut libc::c_void; 0],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
    pub val: *mut libc::c_void,
    pub u64_0: uint64_t,
    pub s64: int64_t,
    pub d: libc::c_double,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct dict {
    pub type_0: *mut dictType,
    pub ht_table: [*mut *mut dictEntry; 2],
    pub ht_used: [libc::c_ulong; 2],
    pub rehashidx: libc::c_long,
    pub pauserehash: int16_t,
    pub ht_size_exp: [libc::c_schar; 2],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct dictType {
    pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
    pub keyDup: Option::<
        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
    >,
    pub valDup: Option::<
        unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
    >,
    pub keyCompare: Option::<
        unsafe extern "C" fn(
            *mut dict,
            *const libc::c_void,
            *const libc::c_void,
        ) -> libc::c_int,
    >,
    pub keyDestructor: Option::<
        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
    >,
    pub valDestructor: Option::<
        unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
    >,
    pub expandAllowed: Option::<
        unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
    >,
    pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct dictIterator {
    pub d: *mut dict,
    pub index: libc::c_long,
    pub table: libc::c_int,
    pub safe: libc::c_int,
    pub entry: *mut dictEntry,
    pub nextEntry: *mut dictEntry,
    pub fingerprint: libc::c_ulonglong,
}
pub type dictScanFunction = unsafe extern "C" fn(
    *mut libc::c_void,
    *const dictEntry,
) -> ();
pub type dictScanBucketFunction = unsafe extern "C" fn(
    *mut dict,
    *mut *mut dictEntry,
) -> ();
pub type dictResizeEnable = libc::c_uint;
pub const DICT_RESIZE_FORBID: dictResizeEnable = 2;
pub const DICT_RESIZE_AVOID: dictResizeEnable = 1;
pub const DICT_RESIZE_ENABLE: dictResizeEnable = 0;
static mut dict_can_resize: dictResizeEnable = DICT_RESIZE_ENABLE;
static mut dict_force_resize_ratio: libc::c_uint = 5 as libc::c_int as libc::c_uint;
static mut dict_hash_function_seed: [uint8_t; 16] = [0; 16];
#[no_mangle]
pub unsafe extern "C" fn dictSetHashFunctionSeed(mut seed: *mut uint8_t) {
    memcpy(
        dict_hash_function_seed.as_mut_ptr() as *mut libc::c_void,
        seed as *const libc::c_void,
        core::mem::size_of::<[uint8_t; 16]>() as libc::c_ulong,
    );
}
#[no_mangle]
pub unsafe extern "C" fn dictGetHashFunctionSeed() -> *mut uint8_t {
    return dict_hash_function_seed.as_mut_ptr();
}
#[no_mangle]
pub unsafe extern "C" fn dictGenHashFunction(
    mut key: *const libc::c_void,
    mut len: size_t,
) -> uint64_t {
    return siphash(key as *const uint8_t, len, dict_hash_function_seed.as_mut_ptr());
}
#[no_mangle]
pub unsafe extern "C" fn dictGenCaseHashFunction(
    mut buf: *const libc::c_uchar,
    mut len: size_t,
) -> uint64_t {
    return siphash_nocase(buf, len, dict_hash_function_seed.as_mut_ptr());
}
unsafe extern "C" fn _dictReset(mut d: *mut dict, mut htidx: libc::c_int) {
    (*d).ht_table[htidx as usize] = 0 as *mut *mut dictEntry;
    (*d).ht_size_exp[htidx as usize] = -(1 as libc::c_int) as libc::c_schar;
    (*d).ht_used[htidx as usize] = 0 as libc::c_int as libc::c_ulong;
}
#[no_mangle]
pub unsafe extern "C" fn dictCreate(mut type_0: *mut dictType) -> *mut dict {
    let mut d: *mut dict = zmalloc(core::mem::size_of::<dict>() as libc::c_ulong)
        as *mut dict;
    _dictInit(d, type_0);
    return d;
}
unsafe extern "C" fn _dictInit(
    mut d: *mut dict,
    mut type_0: *mut dictType,
) -> libc::c_int {
    _dictReset(d, 0 as libc::c_int);
    _dictReset(d, 1 as libc::c_int);
    (*d).type_0 = type_0;
    (*d).rehashidx = -(1 as libc::c_int) as libc::c_long;
    (*d).pauserehash = 0 as libc::c_int as int16_t;
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn dictResize(mut d: *mut dict) -> libc::c_int {
    let mut minimal: libc::c_ulong = 0;
    if dict_can_resize as libc::c_uint
        != DICT_RESIZE_ENABLE as libc::c_int as libc::c_uint
        || (*d).rehashidx != -(1 as libc::c_int) as libc::c_long
    {
        return 1 as libc::c_int;
    }
    minimal = (*d).ht_used[0 as libc::c_int as usize];
    if minimal < ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong {
        minimal = ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong;
    }
    return dictExpand(d, minimal);
}
#[no_mangle]
pub unsafe extern "C" fn _dictExpand(
    mut d: *mut dict,
    mut size: libc::c_ulong,
    mut malloc_failed: *mut libc::c_int,
) -> libc::c_int {
    if !malloc_failed.is_null() {
        *malloc_failed = 0 as libc::c_int;
    }
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long
        || (*d).ht_used[0 as libc::c_int as usize] > size
    {
        return 1 as libc::c_int;
    }
    let mut new_ht_table: *mut *mut dictEntry = 0 as *mut *mut dictEntry;
    let mut new_ht_used: libc::c_ulong = 0;
    let mut new_ht_size_exp: libc::c_schar = _dictNextExp(size);
    let mut newsize: size_t = (1 as libc::c_ulong) << new_ht_size_exp as libc::c_int;
    if newsize < size
        || newsize
            .wrapping_mul(core::mem::size_of::<*mut dictEntry>() as libc::c_ulong)
            < newsize
    {
        return 1 as libc::c_int;
    }
    if new_ht_size_exp as libc::c_int
        == (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
    {
        return 1 as libc::c_int;
    }
    if !malloc_failed.is_null() {
        new_ht_table = ztrycalloc(
            newsize
                .wrapping_mul(core::mem::size_of::<*mut dictEntry>() as libc::c_ulong),
        ) as *mut *mut dictEntry;
        *malloc_failed = (new_ht_table == 0 as *mut libc::c_void as *mut *mut dictEntry)
            as libc::c_int;
        if *malloc_failed != 0 {
            return 1 as libc::c_int;
        }
    } else {
        new_ht_table = zcalloc(
            newsize
                .wrapping_mul(core::mem::size_of::<*mut dictEntry>() as libc::c_ulong),
        ) as *mut *mut dictEntry;
    }
    new_ht_used = 0 as libc::c_int as libc::c_ulong;
    if ((*d).ht_table[0 as libc::c_int as usize]).is_null() {
        (*d).ht_size_exp[0 as libc::c_int as usize] = new_ht_size_exp;
        (*d).ht_used[0 as libc::c_int as usize] = new_ht_used;
        (*d).ht_table[0 as libc::c_int as usize] = new_ht_table;
        return 0 as libc::c_int;
    }
    (*d).ht_size_exp[1 as libc::c_int as usize] = new_ht_size_exp;
    (*d).ht_used[1 as libc::c_int as usize] = new_ht_used;
    (*d).ht_table[1 as libc::c_int as usize] = new_ht_table;
    (*d).rehashidx = 0 as libc::c_int as libc::c_long;
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn dictExpand(
    mut d: *mut dict,
    mut size: libc::c_ulong,
) -> libc::c_int {
    return _dictExpand(d, size, 0 as *mut libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn dictTryExpand(
    mut d: *mut dict,
    mut size: libc::c_ulong,
) -> libc::c_int {
    let mut malloc_failed: libc::c_int = 0;
    _dictExpand(d, size, &mut malloc_failed);
    return if malloc_failed != 0 { 1 as libc::c_int } else { 0 as libc::c_int };
}
#[no_mangle]
pub unsafe extern "C" fn dictRehash(
    mut d: *mut dict,
    mut n: libc::c_int,
) -> libc::c_int {
    let mut empty_visits: libc::c_int = n * 10 as libc::c_int;
    if dict_can_resize as libc::c_uint
        == DICT_RESIZE_FORBID as libc::c_int as libc::c_uint
        || !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long)
    {
        return 0 as libc::c_int;
    }
    if dict_can_resize as libc::c_uint
        == DICT_RESIZE_AVOID as libc::c_int as libc::c_uint
        && (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
            == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
        })
            .wrapping_div(
                (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                }),
            ) < dict_force_resize_ratio as libc::c_ulong
    {
        return 0 as libc::c_int;
    }
    loop {
        let fresh0 = n;
        n = n - 1;
        if !(fresh0 != 0
            && (*d).ht_used[0 as libc::c_int as usize]
                != 0 as libc::c_int as libc::c_ulong)
        {
            break;
        }
        let mut de: *mut dictEntry = 0 as *mut dictEntry;
        let mut nextde: *mut dictEntry = 0 as *mut dictEntry;
        if ((if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
            == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
        }) > (*d).rehashidx as libc::c_ulong) as libc::c_int as libc::c_long != 0
        {} else {
            _serverAssert(
                b"DICTHT_SIZE(d->ht_size_exp[0]) > (unsigned long)d->rehashidx\0"
                    as *const u8 as *const libc::c_char,
                b"dict.c\0" as *const u8 as *const libc::c_char,
                225 as libc::c_int,
            );
            unreachable!();
        };
        while (*((*d).ht_table[0 as libc::c_int as usize])
            .offset((*d).rehashidx as isize))
            .is_null()
        {
            (*d).rehashidx += 1;
            empty_visits -= 1;
            if empty_visits == 0 as libc::c_int {
                return 1 as libc::c_int;
            }
        }
        de = *((*d).ht_table[0 as libc::c_int as usize]).offset((*d).rehashidx as isize);
        while !de.is_null() {
            let mut h: uint64_t = 0;
            nextde = (*de).next;
            h = ((*(*d).type_0).hashFunction)
                .expect("non-null function pointer")((*de).key)
                & (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                        == -(1 as libc::c_int)
                    {
                        0 as libc::c_int as libc::c_ulong
                    } else {
                        (1 as libc::c_int as libc::c_ulong)
                            << (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                    })
                        .wrapping_sub(1 as libc::c_int as libc::c_ulong)
                });
            (*de).next = *((*d).ht_table[1 as libc::c_int as usize]).offset(h as isize);
            let ref mut fresh1 = *((*d).ht_table[1 as libc::c_int as usize])
                .offset(h as isize);
            *fresh1 = de;
            (*d)
                .ht_used[0 as libc::c_int
                as usize] = ((*d).ht_used[0 as libc::c_int as usize]).wrapping_sub(1);
            (*d)
                .ht_used[1 as libc::c_int
                as usize] = ((*d).ht_used[1 as libc::c_int as usize]).wrapping_add(1);
            de = nextde;
        }
        let ref mut fresh2 = *((*d).ht_table[0 as libc::c_int as usize])
            .offset((*d).rehashidx as isize);
        *fresh2 = 0 as *mut dictEntry;
        (*d).rehashidx += 1;
    }
    if (*d).ht_used[0 as libc::c_int as usize] == 0 as libc::c_int as libc::c_ulong {
        zfree((*d).ht_table[0 as libc::c_int as usize] as *mut libc::c_void);
        (*d)
            .ht_table[0 as libc::c_int
            as usize] = (*d).ht_table[1 as libc::c_int as usize];
        (*d)
            .ht_used[0 as libc::c_int
            as usize] = (*d).ht_used[1 as libc::c_int as usize];
        (*d)
            .ht_size_exp[0 as libc::c_int
            as usize] = (*d).ht_size_exp[1 as libc::c_int as usize];
        _dictReset(d, 1 as libc::c_int);
        (*d).rehashidx = -(1 as libc::c_int) as libc::c_long;
        return 0 as libc::c_int;
    }
    return 1 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn timeInMilliseconds() -> libc::c_longlong {
    let mut tv: timeval = timeval { tv_sec: 0, tv_usec: 0 };
    gettimeofday(&mut tv, 0 as *mut libc::c_void);
    return tv.tv_sec as libc::c_longlong * 1000 as libc::c_int as libc::c_longlong
        + (tv.tv_usec / 1000 as libc::c_int as libc::c_long) as libc::c_longlong;
}
#[no_mangle]
pub unsafe extern "C" fn dictRehashMilliseconds(
    mut d: *mut dict,
    mut ms: libc::c_int,
) -> libc::c_int {
    if (*d).pauserehash as libc::c_int > 0 as libc::c_int {
        return 0 as libc::c_int;
    }
    let mut start: libc::c_longlong = timeInMilliseconds();
    let mut rehashes: libc::c_int = 0 as libc::c_int;
    while dictRehash(d, 100 as libc::c_int) != 0 {
        rehashes += 100 as libc::c_int;
        if timeInMilliseconds() - start > ms as libc::c_longlong {
            break;
        }
    }
    return rehashes;
}
unsafe extern "C" fn _dictRehashStep(mut d: *mut dict) {
    if (*d).pauserehash as libc::c_int == 0 as libc::c_int {
        dictRehash(d, 1 as libc::c_int);
    }
}
#[no_mangle]
pub unsafe extern "C" fn dictAdd(
    mut d: *mut dict,
    mut key: *mut libc::c_void,
    mut val: *mut libc::c_void,
) -> libc::c_int {
    let mut entry: *mut dictEntry = dictAddRaw(d, key, 0 as *mut *mut dictEntry);
    if entry.is_null() {
        return 1 as libc::c_int;
    }
    if ((*(*d).type_0).valDup).is_some() {
        (*entry)
            .v
            .val = ((*(*d).type_0).valDup).expect("non-null function pointer")(d, val);
    } else {
        (*entry).v.val = val;
    }
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn dictAddRaw(
    mut d: *mut dict,
    mut key: *mut libc::c_void,
    mut existing: *mut *mut dictEntry,
) -> *mut dictEntry {
    let mut index: libc::c_long = 0;
    let mut entry: *mut dictEntry = 0 as *mut dictEntry;
    let mut htidx: libc::c_int = 0;
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        _dictRehashStep(d);
    }
    index = _dictKeyIndex(
        d,
        key,
        ((*(*d).type_0).hashFunction).expect("non-null function pointer")(key),
        existing,
    );
    if index == -(1 as libc::c_int) as libc::c_long {
        return 0 as *mut dictEntry;
    }
    htidx = if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        1 as libc::c_int
    } else {
        0 as libc::c_int
    };
    let mut metasize: size_t = if ((*(*d).type_0).dictEntryMetadataBytes).is_some() {
        ((*(*d).type_0).dictEntryMetadataBytes).expect("non-null function pointer")(d)
    } else {
        0 as libc::c_int as libc::c_ulong
    };
    entry = zmalloc(
        (core::mem::size_of::<dictEntry>() as libc::c_ulong).wrapping_add(metasize),
    ) as *mut dictEntry;
    if metasize > 0 as libc::c_int as libc::c_ulong {
        memset(
            &mut (*entry).metadata as *mut [*mut libc::c_void; 0] as *mut libc::c_void,
            0 as libc::c_int,
            metasize,
        );
    }
    (*entry).next = *((*d).ht_table[htidx as usize]).offset(index as isize);
    let ref mut fresh3 = *((*d).ht_table[htidx as usize]).offset(index as isize);
    *fresh3 = entry;
    (*d).ht_used[htidx as usize] = ((*d).ht_used[htidx as usize]).wrapping_add(1);
    if ((*(*d).type_0).keyDup).is_some() {
        (*entry)
            .key = ((*(*d).type_0).keyDup).expect("non-null function pointer")(d, key);
    } else {
        (*entry).key = key;
    }
    return entry;
}
#[no_mangle]
pub unsafe extern "C" fn dictReplace(
    mut d: *mut dict,
    mut key: *mut libc::c_void,
    mut val: *mut libc::c_void,
) -> libc::c_int {
    let mut entry: *mut dictEntry = 0 as *mut dictEntry;
    let mut existing: *mut dictEntry = 0 as *mut dictEntry;
    let mut auxentry: dictEntry = dictEntry {
        key: 0 as *mut libc::c_void,
        v: C2RustUnnamed {
            val: 0 as *mut libc::c_void,
        },
        next: 0 as *mut dictEntry,
        metadata: [],
    };
    entry = dictAddRaw(d, key, &mut existing);
    if !entry.is_null() {
        if ((*(*d).type_0).valDup).is_some() {
            (*entry)
                .v
                .val = ((*(*d).type_0).valDup)
                .expect("non-null function pointer")(d, val);
        } else {
            (*entry).v.val = val;
        }
        return 1 as libc::c_int;
    }
    auxentry = *existing;
    if ((*(*d).type_0).valDup).is_some() {
        (*existing)
            .v
            .val = ((*(*d).type_0).valDup).expect("non-null function pointer")(d, val);
    } else {
        (*existing).v.val = val;
    }
    if ((*(*d).type_0).valDestructor).is_some() {
        ((*(*d).type_0).valDestructor)
            .expect("non-null function pointer")(d, auxentry.v.val);
    }
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn dictAddOrFind(
    mut d: *mut dict,
    mut key: *mut libc::c_void,
) -> *mut dictEntry {
    let mut entry: *mut dictEntry = 0 as *mut dictEntry;
    let mut existing: *mut dictEntry = 0 as *mut dictEntry;
    entry = dictAddRaw(d, key, &mut existing);
    return if !entry.is_null() { entry } else { existing };
}
unsafe extern "C" fn dictGenericDelete(
    mut d: *mut dict,
    mut key: *const libc::c_void,
    mut nofree: libc::c_int,
) -> *mut dictEntry {
    let mut h: uint64_t = 0;
    let mut idx: uint64_t = 0;
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    let mut prevHe: *mut dictEntry = 0 as *mut dictEntry;
    let mut table: libc::c_int = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
        == 0 as libc::c_int as libc::c_ulong
    {
        return 0 as *mut dictEntry;
    }
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        _dictRehashStep(d);
    }
    h = ((*(*d).type_0).hashFunction).expect("non-null function pointer")(key);
    table = 0 as libc::c_int;
    while table <= 1 as libc::c_int {
        idx = h
            & (if (*d).ht_size_exp[table as usize] as libc::c_int == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (if (*d).ht_size_exp[table as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[table as usize] as libc::c_int
                })
                    .wrapping_sub(1 as libc::c_int as libc::c_ulong)
            });
        he = *((*d).ht_table[table as usize]).offset(idx as isize);
        prevHe = 0 as *mut dictEntry;
        while !he.is_null() {
            if key == (*he).key as *const libc::c_void
                || (if ((*(*d).type_0).keyCompare).is_some() {
                    ((*(*d).type_0).keyCompare)
                        .expect("non-null function pointer")(d, key, (*he).key)
                } else {
                    (key == (*he).key as *const libc::c_void) as libc::c_int
                }) != 0
            {
                if !prevHe.is_null() {
                    (*prevHe).next = (*he).next;
                } else {
                    let ref mut fresh4 = *((*d).ht_table[table as usize])
                        .offset(idx as isize);
                    *fresh4 = (*he).next;
                }
                if nofree == 0 {
                    dictFreeUnlinkedEntry(d, he);
                }
                (*d)
                    .ht_used[table
                    as usize] = ((*d).ht_used[table as usize]).wrapping_sub(1);
                return he;
            }
            prevHe = he;
            he = (*he).next;
        }
        if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
            break;
        }
        table += 1;
    }
    return 0 as *mut dictEntry;
}
#[no_mangle]
pub unsafe extern "C" fn dictDelete(
    mut ht: *mut dict,
    mut key: *const libc::c_void,
) -> libc::c_int {
    return if !(dictGenericDelete(ht, key, 0 as libc::c_int)).is_null() {
        0 as libc::c_int
    } else {
        1 as libc::c_int
    };
}
#[no_mangle]
pub unsafe extern "C" fn dictUnlink(
    mut d: *mut dict,
    mut key: *const libc::c_void,
) -> *mut dictEntry {
    return dictGenericDelete(d, key, 1 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn dictFreeUnlinkedEntry(
    mut d: *mut dict,
    mut he: *mut dictEntry,
) {
    if he.is_null() {
        return;
    }
    if ((*(*d).type_0).keyDestructor).is_some() {
        ((*(*d).type_0).keyDestructor).expect("non-null function pointer")(d, (*he).key);
    }
    if ((*(*d).type_0).valDestructor).is_some() {
        ((*(*d).type_0).valDestructor)
            .expect("non-null function pointer")(d, (*he).v.val);
    }
    zfree(he as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn _dictClear(
    mut d: *mut dict,
    mut htidx: libc::c_int,
    mut callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
) -> libc::c_int {
    let mut i: libc::c_ulong = 0;
    i = 0 as libc::c_int as libc::c_ulong;
    while i
        < (if (*d).ht_size_exp[htidx as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[htidx as usize] as libc::c_int
        }) && (*d).ht_used[htidx as usize] > 0 as libc::c_int as libc::c_ulong
    {
        let mut he: *mut dictEntry = 0 as *mut dictEntry;
        let mut nextHe: *mut dictEntry = 0 as *mut dictEntry;
        if callback.is_some()
            && i & 65535 as libc::c_int as libc::c_ulong
                == 0 as libc::c_int as libc::c_ulong
        {
            callback.expect("non-null function pointer")(d);
        }
        he = *((*d).ht_table[htidx as usize]).offset(i as isize);
        if !he.is_null() {
            while !he.is_null() {
                nextHe = (*he).next;
                if ((*(*d).type_0).keyDestructor).is_some() {
                    ((*(*d).type_0).keyDestructor)
                        .expect("non-null function pointer")(d, (*he).key);
                }
                if ((*(*d).type_0).valDestructor).is_some() {
                    ((*(*d).type_0).valDestructor)
                        .expect("non-null function pointer")(d, (*he).v.val);
                }
                zfree(he as *mut libc::c_void);
                (*d)
                    .ht_used[htidx
                    as usize] = ((*d).ht_used[htidx as usize]).wrapping_sub(1);
                he = nextHe;
            }
        }
        i = i.wrapping_add(1);
    }
    zfree((*d).ht_table[htidx as usize] as *mut libc::c_void);
    _dictReset(d, htidx);
    return 0 as libc::c_int;
}
#[no_mangle]
pub unsafe extern "C" fn dictRelease(mut d: *mut dict) {
    _dictClear(d, 0 as libc::c_int, None);
    _dictClear(d, 1 as libc::c_int, None);
    zfree(d as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn dictFind(
    mut d: *mut dict,
    mut key: *const libc::c_void,
) -> *mut dictEntry {
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    let mut h: uint64_t = 0;
    let mut idx: uint64_t = 0;
    let mut table: uint64_t = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
        == 0 as libc::c_int as libc::c_ulong
    {
        return 0 as *mut dictEntry;
    }
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        _dictRehashStep(d);
    }
    h = ((*(*d).type_0).hashFunction).expect("non-null function pointer")(key);
    table = 0 as libc::c_int as uint64_t;
    while table <= 1 as libc::c_int as libc::c_ulong {
        idx = h
            & (if (*d).ht_size_exp[table as usize] as libc::c_int == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (if (*d).ht_size_exp[table as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[table as usize] as libc::c_int
                })
                    .wrapping_sub(1 as libc::c_int as libc::c_ulong)
            });
        he = *((*d).ht_table[table as usize]).offset(idx as isize);
        while !he.is_null() {
            if key == (*he).key as *const libc::c_void
                || (if ((*(*d).type_0).keyCompare).is_some() {
                    ((*(*d).type_0).keyCompare)
                        .expect("non-null function pointer")(d, key, (*he).key)
                } else {
                    (key == (*he).key as *const libc::c_void) as libc::c_int
                }) != 0
            {
                return he;
            }
            he = (*he).next;
        }
        if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
            return 0 as *mut dictEntry;
        }
        table = table.wrapping_add(1);
    }
    return 0 as *mut dictEntry;
}
#[no_mangle]
pub unsafe extern "C" fn dictFetchValue(
    mut d: *mut dict,
    mut key: *const libc::c_void,
) -> *mut libc::c_void {
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    he = dictFind(d, key);
    return if !he.is_null() { (*he).v.val } else { 0 as *mut libc::c_void };
}
#[no_mangle]
pub unsafe extern "C" fn dictFingerprint(mut d: *mut dict) -> libc::c_ulonglong {
    let mut integers: [libc::c_ulonglong; 6] = [0; 6];
    let mut hash: libc::c_ulonglong = 0 as libc::c_int as libc::c_ulonglong;
    let mut j: libc::c_int = 0;
    integers[0 as libc::c_int
        as usize] = (*d).ht_table[0 as libc::c_int as usize] as libc::c_long
        as libc::c_ulonglong;
    integers[1 as libc::c_int
        as usize] = (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_ulonglong;
    integers[2 as libc::c_int
        as usize] = (*d).ht_used[0 as libc::c_int as usize] as libc::c_ulonglong;
    integers[3 as libc::c_int
        as usize] = (*d).ht_table[1 as libc::c_int as usize] as libc::c_long
        as libc::c_ulonglong;
    integers[4 as libc::c_int
        as usize] = (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_ulonglong;
    integers[5 as libc::c_int
        as usize] = (*d).ht_used[1 as libc::c_int as usize] as libc::c_ulonglong;
    j = 0 as libc::c_int;
    while j < 6 as libc::c_int {
        hash = hash.wrapping_add(integers[j as usize]);
        hash = (!hash).wrapping_add(hash << 21 as libc::c_int);
        hash = hash ^ hash >> 24 as libc::c_int;
        hash = hash
            .wrapping_add(hash << 3 as libc::c_int)
            .wrapping_add(hash << 8 as libc::c_int);
        hash = hash ^ hash >> 14 as libc::c_int;
        hash = hash
            .wrapping_add(hash << 2 as libc::c_int)
            .wrapping_add(hash << 4 as libc::c_int);
        hash = hash ^ hash >> 28 as libc::c_int;
        hash = hash.wrapping_add(hash << 31 as libc::c_int);
        j += 1;
    }
    return hash;
}
#[no_mangle]
pub unsafe extern "C" fn dictGetIterator(mut d: *mut dict) -> *mut dictIterator {
    let mut iter: *mut dictIterator = zmalloc(
        core::mem::size_of::<dictIterator>() as libc::c_ulong,
    ) as *mut dictIterator;
    (*iter).d = d;
    (*iter).table = 0 as libc::c_int;
    (*iter).index = -(1 as libc::c_int) as libc::c_long;
    (*iter).safe = 0 as libc::c_int;
    (*iter).entry = 0 as *mut dictEntry;
    (*iter).nextEntry = 0 as *mut dictEntry;
    return iter;
}
#[no_mangle]
pub unsafe extern "C" fn dictGetSafeIterator(mut d: *mut dict) -> *mut dictIterator {
    let mut i: *mut dictIterator = dictGetIterator(d);
    (*i).safe = 1 as libc::c_int;
    return i;
}
#[no_mangle]
pub unsafe extern "C" fn dictNext(mut iter: *mut dictIterator) -> *mut dictEntry {
    loop {
        if ((*iter).entry).is_null() {
            if (*iter).index == -(1 as libc::c_int) as libc::c_long
                && (*iter).table == 0 as libc::c_int
            {
                if (*iter).safe != 0 {
                    (*(*iter).d).pauserehash += 1;
                } else {
                    (*iter).fingerprint = dictFingerprint((*iter).d);
                }
            }
            (*iter).index += 1;
            if (*iter).index
                >= (if (*(*iter).d).ht_size_exp[(*iter).table as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*(*iter).d).ht_size_exp[(*iter).table as usize]
                            as libc::c_int
                }) as libc::c_long
            {
                if !((*(*iter).d).rehashidx != -(1 as libc::c_int) as libc::c_long
                    && (*iter).table == 0 as libc::c_int)
                {
                    break;
                }
                (*iter).table += 1;
                (*iter).index = 0 as libc::c_int as libc::c_long;
            }
            (*iter)
                .entry = *((*(*iter).d).ht_table[(*iter).table as usize])
                .offset((*iter).index as isize);
        } else {
            (*iter).entry = (*iter).nextEntry;
        }
        if !((*iter).entry).is_null() {
            (*iter).nextEntry = (*(*iter).entry).next;
            return (*iter).entry;
        }
    }
    return 0 as *mut dictEntry;
}
#[no_mangle]
pub unsafe extern "C" fn dictReleaseIterator(mut iter: *mut dictIterator) {
    if !((*iter).index == -(1 as libc::c_int) as libc::c_long
        && (*iter).table == 0 as libc::c_int)
    {
        if (*iter).safe != 0 {
            (*(*iter).d).pauserehash -= 1;
        } else {
            if ((*iter).fingerprint == dictFingerprint((*iter).d)) as libc::c_int
                as libc::c_long != 0
            {} else {
                _serverAssert(
                    b"iter->fingerprint == dictFingerprint(iter->d)\0" as *const u8
                        as *const libc::c_char,
                    b"dict.c\0" as *const u8 as *const libc::c_char,
                    639 as libc::c_int,
                );
                unreachable!();
            };
        }
    }
    zfree(iter as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn dictGetRandomKey(mut d: *mut dict) -> *mut dictEntry {
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    let mut orighe: *mut dictEntry = 0 as *mut dictEntry;
    let mut h: libc::c_ulong = 0;
    let mut listlen: libc::c_int = 0;
    let mut listele: libc::c_int = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
        == 0 as libc::c_int as libc::c_ulong
    {
        return 0 as *mut dictEntry;
    }
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        _dictRehashStep(d);
    }
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        let mut s0: libc::c_ulong = if (*d).ht_size_exp[0 as libc::c_int as usize]
            as libc::c_int == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
        };
        loop {
            h = ((*d).rehashidx as libc::c_ulong)
                .wrapping_add(
                    (genrand64_int64() as libc::c_ulong)
                        .wrapping_rem(
                            (if (*d).ht_size_exp[0 as libc::c_int as usize]
                                as libc::c_int == -(1 as libc::c_int)
                            {
                                0 as libc::c_int as libc::c_ulong
                            } else {
                                (1 as libc::c_int as libc::c_ulong)
                                    << (*d).ht_size_exp[0 as libc::c_int as usize]
                                        as libc::c_int
                            })
                                .wrapping_add(
                                    (if (*d).ht_size_exp[1 as libc::c_int as usize]
                                        as libc::c_int == -(1 as libc::c_int)
                                    {
                                        0 as libc::c_int as libc::c_ulong
                                    } else {
                                        (1 as libc::c_int as libc::c_ulong)
                                            << (*d).ht_size_exp[1 as libc::c_int as usize]
                                                as libc::c_int
                                    }),
                                )
                                .wrapping_sub((*d).rehashidx as libc::c_ulong),
                        ),
                );
            he = if h >= s0 {
                *((*d).ht_table[1 as libc::c_int as usize])
                    .offset(h.wrapping_sub(s0) as isize)
            } else {
                *((*d).ht_table[0 as libc::c_int as usize]).offset(h as isize)
            };
            if !he.is_null() {
                break;
            }
        }
    } else {
        let mut m: libc::c_ulong = if (*d).ht_size_exp[0 as libc::c_int as usize]
            as libc::c_int == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
            })
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        };
        loop {
            h = genrand64_int64() as libc::c_ulong & m;
            he = *((*d).ht_table[0 as libc::c_int as usize]).offset(h as isize);
            if !he.is_null() {
                break;
            }
        }
    }
    listlen = 0 as libc::c_int;
    orighe = he;
    while !he.is_null() {
        he = (*he).next;
        listlen += 1;
    }
    listele = (random() % listlen as libc::c_long) as libc::c_int;
    he = orighe;
    loop {
        let fresh5 = listele;
        listele = listele - 1;
        if !(fresh5 != 0) {
            break;
        }
        he = (*he).next;
    }
    return he;
}
#[no_mangle]
pub unsafe extern "C" fn dictGetSomeKeys(
    mut d: *mut dict,
    mut des: *mut *mut dictEntry,
    mut count: libc::c_uint,
) -> libc::c_uint {
    let mut j: libc::c_ulong = 0;
    let mut tables: libc::c_ulong = 0;
    let mut stored: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
    let mut maxsizemask: libc::c_ulong = 0;
    let mut maxsteps: libc::c_ulong = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize]) < count as libc::c_ulong
    {
        count = ((*d).ht_used[0 as libc::c_int as usize])
            .wrapping_add((*d).ht_used[1 as libc::c_int as usize]) as libc::c_uint;
    }
    maxsteps = count.wrapping_mul(10 as libc::c_int as libc::c_uint) as libc::c_ulong;
    j = 0 as libc::c_int as libc::c_ulong;
    while j < count as libc::c_ulong {
        if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
            break;
        }
        _dictRehashStep(d);
        j = j.wrapping_add(1);
    }
    tables = (if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        2 as libc::c_int
    } else {
        1 as libc::c_int
    }) as libc::c_ulong;
    maxsizemask = if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
        == -(1 as libc::c_int)
    {
        0 as libc::c_int as libc::c_ulong
    } else {
        (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
            == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
        })
            .wrapping_sub(1 as libc::c_int as libc::c_ulong)
    };
    if tables > 1 as libc::c_int as libc::c_ulong
        && maxsizemask
            < (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                })
                    .wrapping_sub(1 as libc::c_int as libc::c_ulong)
            })
    {
        maxsizemask = if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
            == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
            })
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        };
    }
    let mut i: libc::c_ulong = genrand64_int64() as libc::c_ulong & maxsizemask;
    let mut emptylen: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
    while stored < count as libc::c_ulong
        && {
            let fresh6 = maxsteps;
            maxsteps = maxsteps.wrapping_sub(1);
            fresh6 != 0
        }
    {
        let mut current_block_28: u64;
        j = 0 as libc::c_int as libc::c_ulong;
        while j < tables {
            if tables == 2 as libc::c_int as libc::c_ulong
                && j == 0 as libc::c_int as libc::c_ulong
                && i < (*d).rehashidx as libc::c_ulong
            {
                if i
                    >= (if (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                        == -(1 as libc::c_int)
                    {
                        0 as libc::c_int as libc::c_ulong
                    } else {
                        (1 as libc::c_int as libc::c_ulong)
                            << (*d).ht_size_exp[1 as libc::c_int as usize] as libc::c_int
                    })
                {
                    i = (*d).rehashidx as libc::c_ulong;
                    current_block_28 = 17833034027772472439;
                } else {
                    current_block_28 = 12800627514080957624;
                }
            } else {
                current_block_28 = 17833034027772472439;
            }
            match current_block_28 {
                17833034027772472439 => {
                    if !(i
                        >= (if (*d).ht_size_exp[j as usize] as libc::c_int
                            == -(1 as libc::c_int)
                        {
                            0 as libc::c_int as libc::c_ulong
                        } else {
                            (1 as libc::c_int as libc::c_ulong)
                                << (*d).ht_size_exp[j as usize] as libc::c_int
                        }))
                    {
                        let mut he: *mut dictEntry = *((*d).ht_table[j as usize])
                            .offset(i as isize);
                        if he.is_null() {
                            emptylen = emptylen.wrapping_add(1);
                            if emptylen >= 5 as libc::c_int as libc::c_ulong
                                && emptylen > count as libc::c_ulong
                            {
                                i = genrand64_int64() as libc::c_ulong & maxsizemask;
                                emptylen = 0 as libc::c_int as libc::c_ulong;
                            }
                        } else {
                            emptylen = 0 as libc::c_int as libc::c_ulong;
                            while !he.is_null() {
                                *des = he;
                                des = des.offset(1);
                                he = (*he).next;
                                stored = stored.wrapping_add(1);
                                if stored == count as libc::c_ulong {
                                    return stored as libc::c_uint;
                                }
                            }
                        }
                    }
                }
                _ => {}
            }
            j = j.wrapping_add(1);
        }
        i = i.wrapping_add(1 as libc::c_int as libc::c_ulong) & maxsizemask;
    }
    return stored as libc::c_uint;
}
#[no_mangle]
pub unsafe extern "C" fn dictGetFairRandomKey(mut d: *mut dict) -> *mut dictEntry {
    let mut entries: [*mut dictEntry; 15] = [0 as *mut dictEntry; 15];
    let mut count: libc::c_uint = dictGetSomeKeys(
        d,
        entries.as_mut_ptr(),
        15 as libc::c_int as libc::c_uint,
    );
    if count == 0 as libc::c_int as libc::c_uint {
        return dictGetRandomKey(d);
    }
    let mut idx: libc::c_uint = (rand() as libc::c_uint).wrapping_rem(count);
    return entries[idx as usize];
}
unsafe extern "C" fn rev(mut v: libc::c_ulong) -> libc::c_ulong {
    let mut s: libc::c_ulong = (8 as libc::c_int as libc::c_ulong)
        .wrapping_mul(core::mem::size_of::<libc::c_ulong>() as libc::c_ulong);
    let mut mask: libc::c_ulong = !(0 as libc::c_ulong);
    loop {
        s >>= 1 as libc::c_int;
        if !(s > 0 as libc::c_int as libc::c_ulong) {
            break;
        }
        mask ^= mask << s;
        v = v >> s & mask | v << s & !mask;
    }
    return v;
}
#[no_mangle]
pub unsafe extern "C" fn dictScan(
    mut d: *mut dict,
    mut v: libc::c_ulong,
    mut fn_0: Option::<dictScanFunction>,
    mut bucketfn: Option::<dictScanBucketFunction>,
    mut privdata: *mut libc::c_void,
) -> libc::c_ulong {
    let mut htidx0: libc::c_int = 0;
    let mut htidx1: libc::c_int = 0;
    let mut de: *const dictEntry = 0 as *const dictEntry;
    let mut next: *const dictEntry = 0 as *const dictEntry;
    let mut m0: libc::c_ulong = 0;
    let mut m1: libc::c_ulong = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
        == 0 as libc::c_int as libc::c_ulong
    {
        return 0 as libc::c_int as libc::c_ulong;
    }
    (*d).pauserehash += 1;
    if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
        htidx0 = 0 as libc::c_int;
        m0 = if (*d).ht_size_exp[htidx0 as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (if (*d).ht_size_exp[htidx0 as usize] as libc::c_int == -(1 as libc::c_int) {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[htidx0 as usize] as libc::c_int
            })
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        };
        if bucketfn.is_some() {
            bucketfn
                .expect(
                    "non-null function pointer",
                )(
                d,
                &mut *(*((*d).ht_table).as_mut_ptr().offset(htidx0 as isize))
                    .offset((v & m0) as isize),
            );
        }
        de = *((*d).ht_table[htidx0 as usize]).offset((v & m0) as isize);
        while !de.is_null() {
            next = (*de).next;
            fn_0.expect("non-null function pointer")(privdata, de);
            de = next;
        }
        v |= !m0;
        v = rev(v);
        v = v.wrapping_add(1);
        v = rev(v);
    } else {
        htidx0 = 0 as libc::c_int;
        htidx1 = 1 as libc::c_int;
        if (if (*d).ht_size_exp[htidx0 as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[htidx0 as usize] as libc::c_int
        })
            > (if (*d).ht_size_exp[htidx1 as usize] as libc::c_int == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[htidx1 as usize] as libc::c_int
            })
        {
            htidx0 = 1 as libc::c_int;
            htidx1 = 0 as libc::c_int;
        }
        m0 = if (*d).ht_size_exp[htidx0 as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (if (*d).ht_size_exp[htidx0 as usize] as libc::c_int == -(1 as libc::c_int) {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[htidx0 as usize] as libc::c_int
            })
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        };
        m1 = if (*d).ht_size_exp[htidx1 as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (if (*d).ht_size_exp[htidx1 as usize] as libc::c_int == -(1 as libc::c_int) {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[htidx1 as usize] as libc::c_int
            })
                .wrapping_sub(1 as libc::c_int as libc::c_ulong)
        };
        if bucketfn.is_some() {
            bucketfn
                .expect(
                    "non-null function pointer",
                )(
                d,
                &mut *(*((*d).ht_table).as_mut_ptr().offset(htidx0 as isize))
                    .offset((v & m0) as isize),
            );
        }
        de = *((*d).ht_table[htidx0 as usize]).offset((v & m0) as isize);
        while !de.is_null() {
            next = (*de).next;
            fn_0.expect("non-null function pointer")(privdata, de);
            de = next;
        }
        loop {
            if bucketfn.is_some() {
                bucketfn
                    .expect(
                        "non-null function pointer",
                    )(
                    d,
                    &mut *(*((*d).ht_table).as_mut_ptr().offset(htidx1 as isize))
                        .offset((v & m1) as isize),
                );
            }
            de = *((*d).ht_table[htidx1 as usize]).offset((v & m1) as isize);
            while !de.is_null() {
                next = (*de).next;
                fn_0.expect("non-null function pointer")(privdata, de);
                de = next;
            }
            v |= !m1;
            v = rev(v);
            v = v.wrapping_add(1);
            v = rev(v);
            if !(v & (m0 ^ m1) != 0) {
                break;
            }
        }
    }
    (*d).pauserehash -= 1;
    return v;
}
unsafe extern "C" fn dictTypeExpandAllowed(mut d: *mut dict) -> libc::c_int {
    if ((*(*d).type_0).expandAllowed).is_none() {
        return 1 as libc::c_int;
    }
    return ((*(*d).type_0).expandAllowed)
        .expect(
            "non-null function pointer",
        )(
        (if _dictNextExp(
            ((*d).ht_used[0 as libc::c_int as usize])
                .wrapping_add(1 as libc::c_int as libc::c_ulong),
        ) as libc::c_int == -(1 as libc::c_int)
        {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << _dictNextExp(
                    ((*d).ht_used[0 as libc::c_int as usize])
                        .wrapping_add(1 as libc::c_int as libc::c_ulong),
                ) as libc::c_int
        })
            .wrapping_mul(core::mem::size_of::<*mut dictEntry>() as libc::c_ulong),
        (*d).ht_used[0 as libc::c_int as usize] as libc::c_double
            / (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
            }) as libc::c_double,
    );
}
unsafe extern "C" fn _dictExpandIfNeeded(mut d: *mut dict) -> libc::c_int {
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long {
        return 0 as libc::c_int;
    }
    if (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
        == -(1 as libc::c_int)
    {
        0 as libc::c_int as libc::c_ulong
    } else {
        (1 as libc::c_int as libc::c_ulong)
            << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
    }) == 0 as libc::c_int as libc::c_ulong
    {
        return dictExpand(d, ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong);
    }
    if dictTypeExpandAllowed(d) == 0 {
        return 0 as libc::c_int;
    }
    if dict_can_resize as libc::c_uint
        == DICT_RESIZE_ENABLE as libc::c_int as libc::c_uint
        && (*d).ht_used[0 as libc::c_int as usize]
            >= (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (1 as libc::c_int as libc::c_ulong)
                    << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
            })
        || dict_can_resize as libc::c_uint
            != DICT_RESIZE_FORBID as libc::c_int as libc::c_uint
            && ((*d).ht_used[0 as libc::c_int as usize])
                .wrapping_div(
                    (if (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                        == -(1 as libc::c_int)
                    {
                        0 as libc::c_int as libc::c_ulong
                    } else {
                        (1 as libc::c_int as libc::c_ulong)
                            << (*d).ht_size_exp[0 as libc::c_int as usize] as libc::c_int
                    }),
                ) > dict_force_resize_ratio as libc::c_ulong
    {
        return dictExpand(
            d,
            ((*d).ht_used[0 as libc::c_int as usize])
                .wrapping_add(1 as libc::c_int as libc::c_ulong),
        );
    }
    return 0 as libc::c_int;
}
unsafe extern "C" fn _dictNextExp(mut size: libc::c_ulong) -> libc::c_schar {
    let mut e: libc::c_uchar = 2 as libc::c_int as libc::c_uchar;
    if size >= 9223372036854775807 as libc::c_long as libc::c_ulong {
        return (8 as libc::c_int as libc::c_ulong)
            .wrapping_mul(core::mem::size_of::<libc::c_long>() as libc::c_ulong)
            .wrapping_sub(1 as libc::c_int as libc::c_ulong) as libc::c_schar;
    }
    loop {
        if (1 as libc::c_int as libc::c_ulong) << e as libc::c_int >= size {
            return e as libc::c_schar;
        }
        e = e.wrapping_add(1);
    };
}
unsafe extern "C" fn _dictKeyIndex(
    mut d: *mut dict,
    mut key: *const libc::c_void,
    mut hash: uint64_t,
    mut existing: *mut *mut dictEntry,
) -> libc::c_long {
    let mut idx: libc::c_ulong = 0;
    let mut table: libc::c_ulong = 0;
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    if !existing.is_null() {
        *existing = 0 as *mut dictEntry;
    }
    if _dictExpandIfNeeded(d) == 1 as libc::c_int {
        return -(1 as libc::c_int) as libc::c_long;
    }
    table = 0 as libc::c_int as libc::c_ulong;
    while table <= 1 as libc::c_int as libc::c_ulong {
        idx = hash
            & (if (*d).ht_size_exp[table as usize] as libc::c_int == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (if (*d).ht_size_exp[table as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[table as usize] as libc::c_int
                })
                    .wrapping_sub(1 as libc::c_int as libc::c_ulong)
            });
        he = *((*d).ht_table[table as usize]).offset(idx as isize);
        while !he.is_null() {
            if key == (*he).key as *const libc::c_void
                || (if ((*(*d).type_0).keyCompare).is_some() {
                    ((*(*d).type_0).keyCompare)
                        .expect("non-null function pointer")(d, key, (*he).key)
                } else {
                    (key == (*he).key as *const libc::c_void) as libc::c_int
                }) != 0
            {
                if !existing.is_null() {
                    *existing = he;
                }
                return -(1 as libc::c_int) as libc::c_long;
            }
            he = (*he).next;
        }
        if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
            break;
        }
        table = table.wrapping_add(1);
    }
    return idx as libc::c_long;
}
#[no_mangle]
pub unsafe extern "C" fn dictEmpty(
    mut d: *mut dict,
    mut callback: Option::<unsafe extern "C" fn(*mut dict) -> ()>,
) {
    _dictClear(d, 0 as libc::c_int, callback);
    _dictClear(d, 1 as libc::c_int, callback);
    (*d).rehashidx = -(1 as libc::c_int) as libc::c_long;
    (*d).pauserehash = 0 as libc::c_int as int16_t;
}
#[no_mangle]
pub unsafe extern "C" fn dictSetResizeEnabled(mut enable: dictResizeEnable) {
    dict_can_resize = enable;
}
#[no_mangle]
pub unsafe extern "C" fn dictGetHash(
    mut d: *mut dict,
    mut key: *const libc::c_void,
) -> uint64_t {
    return ((*(*d).type_0).hashFunction).expect("non-null function pointer")(key);
}
#[no_mangle]
pub unsafe extern "C" fn dictFindEntryRefByPtrAndHash(
    mut d: *mut dict,
    mut oldptr: *const libc::c_void,
    mut hash: uint64_t,
) -> *mut *mut dictEntry {
    let mut he: *mut dictEntry = 0 as *mut dictEntry;
    let mut heref: *mut *mut dictEntry = 0 as *mut *mut dictEntry;
    let mut idx: libc::c_ulong = 0;
    let mut table: libc::c_ulong = 0;
    if ((*d).ht_used[0 as libc::c_int as usize])
        .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
        == 0 as libc::c_int as libc::c_ulong
    {
        return 0 as *mut *mut dictEntry;
    }
    table = 0 as libc::c_int as libc::c_ulong;
    while table <= 1 as libc::c_int as libc::c_ulong {
        idx = hash
            & (if (*d).ht_size_exp[table as usize] as libc::c_int == -(1 as libc::c_int)
            {
                0 as libc::c_int as libc::c_ulong
            } else {
                (if (*d).ht_size_exp[table as usize] as libc::c_int
                    == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[table as usize] as libc::c_int
                })
                    .wrapping_sub(1 as libc::c_int as libc::c_ulong)
            });
        heref = &mut *(*((*d).ht_table).as_mut_ptr().offset(table as isize))
            .offset(idx as isize) as *mut *mut dictEntry;
        he = *heref;
        while !he.is_null() {
            if oldptr == (*he).key as *const libc::c_void {
                return heref;
            }
            heref = &mut (*he).next;
            he = *heref;
        }
        if !((*d).rehashidx != -(1 as libc::c_int) as libc::c_long) {
            return 0 as *mut *mut dictEntry;
        }
        table = table.wrapping_add(1);
    }
    return 0 as *mut *mut dictEntry;
}
#[no_mangle]
pub unsafe extern "C" fn _dictGetStatsHt(
    mut buf: *mut libc::c_char,
    mut bufsize: size_t,
    mut d: *mut dict,
    mut htidx: libc::c_int,
) -> size_t {
    let mut i: libc::c_ulong = 0;
    let mut slots: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
    let mut chainlen: libc::c_ulong = 0;
    let mut maxchainlen: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
    let mut totchainlen: libc::c_ulong = 0 as libc::c_int as libc::c_ulong;
    let mut clvector: [libc::c_ulong; 50] = [0; 50];
    let mut l: size_t = 0 as libc::c_int as size_t;
    if (*d).ht_used[htidx as usize] == 0 as libc::c_int as libc::c_ulong {
        return snprintf(
            buf,
            bufsize,
            b"No stats available for empty dictionaries\n\0" as *const u8
                as *const libc::c_char,
        ) as size_t;
    }
    i = 0 as libc::c_int as libc::c_ulong;
    while i < 50 as libc::c_int as libc::c_ulong {
        clvector[i as usize] = 0 as libc::c_int as libc::c_ulong;
        i = i.wrapping_add(1);
    }
    i = 0 as libc::c_int as libc::c_ulong;
    while i
        < (if (*d).ht_size_exp[htidx as usize] as libc::c_int == -(1 as libc::c_int) {
            0 as libc::c_int as libc::c_ulong
        } else {
            (1 as libc::c_int as libc::c_ulong)
                << (*d).ht_size_exp[htidx as usize] as libc::c_int
        })
    {
        let mut he: *mut dictEntry = 0 as *mut dictEntry;
        if (*((*d).ht_table[htidx as usize]).offset(i as isize)).is_null() {
            clvector[0 as libc::c_int
                as usize] = (clvector[0 as libc::c_int as usize]).wrapping_add(1);
        } else {
            slots = slots.wrapping_add(1);
            chainlen = 0 as libc::c_int as libc::c_ulong;
            he = *((*d).ht_table[htidx as usize]).offset(i as isize);
            while !he.is_null() {
                chainlen = chainlen.wrapping_add(1);
                he = (*he).next;
            }
            clvector[(if chainlen < 50 as libc::c_int as libc::c_ulong {
                chainlen
            } else {
                (50 as libc::c_int - 1 as libc::c_int) as libc::c_ulong
            })
                as usize] = (clvector[(if chainlen < 50 as libc::c_int as libc::c_ulong {
                chainlen
            } else {
                (50 as libc::c_int - 1 as libc::c_int) as libc::c_ulong
            }) as usize])
                .wrapping_add(1);
            if chainlen > maxchainlen {
                maxchainlen = chainlen;
            }
            totchainlen = totchainlen.wrapping_add(chainlen);
        }
        i = i.wrapping_add(1);
    }
    l = (l as libc::c_ulong)
        .wrapping_add(
            snprintf(
                buf.offset(l as isize),
                bufsize.wrapping_sub(l),
                b"Hash table %d stats (%s):\n table size: %lu\n number of elements: %lu\n different slots: %lu\n max chain length: %lu\n avg chain length (counted): %.02f\n avg chain length (computed): %.02f\n Chain length distribution:\n\0"
                    as *const u8 as *const libc::c_char,
                htidx,
                if htidx == 0 as libc::c_int {
                    b"main hash table\0" as *const u8 as *const libc::c_char
                } else {
                    b"rehashing target\0" as *const u8 as *const libc::c_char
                },
                if (*d).ht_size_exp[htidx as usize] as libc::c_int == -(1 as libc::c_int)
                {
                    0 as libc::c_int as libc::c_ulong
                } else {
                    (1 as libc::c_int as libc::c_ulong)
                        << (*d).ht_size_exp[htidx as usize] as libc::c_int
                },
                (*d).ht_used[htidx as usize],
                slots,
                maxchainlen,
                (totchainlen as libc::c_float / slots as libc::c_float)
                    as libc::c_double,
                ((*d).ht_used[htidx as usize] as libc::c_float / slots as libc::c_float)
                    as libc::c_double,
            ) as libc::c_ulong,
        ) as size_t as size_t;
    i = 0 as libc::c_int as libc::c_ulong;
    while i < (50 as libc::c_int - 1 as libc::c_int) as libc::c_ulong {
        if !(clvector[i as usize] == 0 as libc::c_int as libc::c_ulong) {
            if l >= bufsize {
                break;
            }
            l = (l as libc::c_ulong)
                .wrapping_add(
                    snprintf(
                        buf.offset(l as isize),
                        bufsize.wrapping_sub(l),
                        b"   %ld: %ld (%.02f%%)\n\0" as *const u8 as *const libc::c_char,
                        i,
                        clvector[i as usize],
                        (clvector[i as usize] as libc::c_float
                            / (if (*d).ht_size_exp[htidx as usize] as libc::c_int
                                == -(1 as libc::c_int)
                            {
                                0 as libc::c_int as libc::c_ulong
                            } else {
                                (1 as libc::c_int as libc::c_ulong)
                                    << (*d).ht_size_exp[htidx as usize] as libc::c_int
                            }) as libc::c_float * 100 as libc::c_int as libc::c_float)
                            as libc::c_double,
                    ) as libc::c_ulong,
                ) as size_t as size_t;
        }
        i = i.wrapping_add(1);
    }
    if bufsize != 0 {
        *buf
            .offset(
                bufsize.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize,
            ) = '\0' as i32 as libc::c_char;
    }
    return strlen(buf);
}
#[no_mangle]
pub unsafe extern "C" fn dictGetStats(
    mut buf: *mut libc::c_char,
    mut bufsize: size_t,
    mut d: *mut dict,
) {
    let mut l: size_t = 0;
    let mut orig_buf: *mut libc::c_char = buf;
    let mut orig_bufsize: size_t = bufsize;
    l = _dictGetStatsHt(buf, bufsize, d, 0 as libc::c_int);
    buf = buf.offset(l as isize);
    bufsize = (bufsize as libc::c_ulong).wrapping_sub(l) as size_t as size_t;
    if (*d).rehashidx != -(1 as libc::c_int) as libc::c_long
        && bufsize > 0 as libc::c_int as libc::c_ulong
    {
        _dictGetStatsHt(buf, bufsize, d, 1 as libc::c_int);
    }
    if orig_bufsize != 0 {
        *orig_buf
            .offset(
                orig_bufsize.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize,
            ) = '\0' as i32 as libc::c_char;
    }
}