Given the following minimal example:
repro:
xor ecx, ecx
mov eax, 0DEADh
mov edx, 0BEEFh
mov r8, 8000000000000001h
shr r8, 1
cmovo rax, rdx
ret
At MMAT_GENERATED, the SHR instruction produces:
mov #1.1, t1.1 ; u= d=t1.1
cfshr r8.8, t1.1, cf.1 ; u=r8.8,t1.1 d=cf.1
shr r8.8, t1.1, r8.8 ; u=r8.8,t1.1 d=r8.8
und of.1 ; u= d=of.1
setz r8.8, #0.8, zf.1 ; u=r8.8 d=zf.1
setp r8.8, #0.8, pf.1 ; u=r8.8 d=pf.1
sets r8.8, sf.1 ; u=r8.8 d=sf.1
Notice the unconditional und of.1.
At MMAT_LVARS, the OF dependency remains unresolved:
mov #0xDEAD.8, result.8 ; u= d=rax.8
jcnd lnot(of1.1{1}), @3 ; u=of.1
The resulting pseudocode contains an uninitialized flag variable:
__int64 result; // rax
char v1; // of
result = 0xDEAD;
if ( v1 )
return 0xBEEF;
return result;
For SHR with a count of one, OF is defined as the original most significant bit of the destination operand.
Here, the original MSB is one, so OF must be one and the correct return value is 0xBEEF.
Unlike shifts with counts greater than one, OF is not undefined in this case. The initial lift should calculate OF from the original destination instead of marking it undefined.