6 inline uint64_t mulhu(uint64_t a
, uint64_t b
)
10 uint64_t a0
= (uint32_t)a
, a1
= a
>> 32;
11 uint64_t b0
= (uint32_t)b
, b1
= b
>> 32;
13 t
= a1
*b0
+ ((a0
*b0
) >> 32);
20 t
= a1
*b1
+ y2
+ (t
>> 32);
24 return ((uint64_t)y3
<< 32) | y2
;
27 inline int64_t mulh(int64_t a
, int64_t b
)
29 int negate
= (a
< 0) != (b
< 0);
30 uint64_t res
= mulhu(a
< 0 ? -a
: a
, b
< 0 ? -b
: b
);
31 return negate
? ~res
+ (a
* b
== 0) : res
;
34 inline int64_t mulhsu(int64_t a
, uint64_t b
)
37 uint64_t res
= mulhu(a
< 0 ? -a
: a
, b
);
38 return negate
? ~res
+ (a
* b
== 0) : res
;