'Guess the number of arguments passed to a function - x86_64'

def _get_function_args_64(self, code, argc=None):

    arg_order = ['rdi', 'rsi', 'rdx', 'rcx', 'r8', 'r9']
    p = re.compile(':\\s*([^    ]*)\\s*(.*),')
    matches = p.findall(code)
    regs = [r for (_, r) in matches]
    p = re.compile('di|si|dx|cx|r8|r9')
    m = p.findall('    '.join(regs))
    m = list(set(m))
    argc = 0
    if (('si' in m) and ('di' not in m)):
        argc += 1
    argc += m.count('di')
    if (argc > 0):
        argc += m.count('si')
    if (argc > 1):
        argc += m.count('dx')
    if (argc > 2):
        argc += m.count('cx')
    if (argc > 3):
        argc += m.count('r8')
    if (argc > 4):
        argc += m.count('r9')
    if (argc == 0):
        return []
    args = []
    regs = self.getregs()
    for i in range(argc):
        args += [regs[arg_order[i]]]
    return args
