'Arrange the blocks in order and resolve jumps'

def flattenGraph(self):

    assert (self.stage == RAW)
    self.insts = insts = []
    pc = 0
    begin = {}
    end = {}
    for b in self.getBlocksInOrder():
        begin[b] = pc
        for inst in b.getInstructions():
            insts.append(inst)
            if (len(inst) == 1):
                pc = (pc + 1)
            elif (inst[0] != 'SET_LINENO'):
                pc = (pc + 3)
        end[b] = pc
    pc = 0
    for i in range(len(insts)):
        inst = insts[i]
        if (len(inst) == 1):
            pc = (pc + 1)
        elif (inst[0] != 'SET_LINENO'):
            pc = (pc + 3)
        opname = inst[0]
        if (opname in self.hasjrel):
            oparg = inst[1]
            offset = (begin[oparg] - pc)
            insts[i] = (opname, offset)
        elif (opname in self.hasjabs):
            insts[i] = (opname, begin[inst[1]])
    self.stage = FLAT
