import re
from ASTCore import *

HelloASTCore()

# argc/7=%d
# 除数为有符号非2的幂
def div_argc_7_d():
    print("argc/7=%d")
    bigNum = int(lsInsUp[-1].split(",")[1].replace('h',''),16)
    matchKeyPos = [i for i, s in enumerate(lsInsUp) if re.search(r'sar\s+edx',s)] # the pos of shr 
    if len(matchKeyPos)>0:
        powerNum = 32 + int(lsInsUp[matchKeyPos[0]].split(",")[1].replace('h',''), 16)
        print(f"div: /{2**powerNum/bigNum}")

# argc/-4=%d
# 除数为有符号负2的幂
def div_argc_neg_4_d():
    print("argc/-4=%d")
    num = int(lsInsDown[0].split(",")[1], 16)
    print("num=",num)
    print(f"div: /-{num**2}")
    
AnalyCaseTable = {"argc/7=%d":div_argc_7_d, "argc/-4=%d":div_argc_neg_4_d}
for k,v in AnalyCaseTable.items():
    if k == methodMatched:
        v()
