# -*- coding: utf-8 -*-
#!/usr/bin/python

import pickle
import sys

##########################################################
# usage
# pypy get_jump.py xid_train.p /ins_train ./jump_train
##########################################################

xid=pickle.load(open(sys.argv[1],'rb'))
#unconditional_jump=['jmp','j','ja']
ins_path=sys.argv[2]
jump_path=sys.argv[3]

for cc,i in enumerate(xid):
    jmp={}
    tmp=pickle.load(open(ins_path+'/'+i+'_ins.p','rb'))
    for add in tmp:
        if tmp[add] == 'jmp' or tmp[add]=='ja':
            jmp[add]=1
    del tmp
    if len(jmp) > 1:
        pickle.dump(jmp,open(jump_path+'/'+i+'_jmp.p','wb+'))
    del jmp

    print(cc*1.0/len(xid))
















