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

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

    if (not argc):
        argc = 0
        p = re.compile('.*mov.*\\[esp(.*)\\],')
        matches = p.findall(code)
        if matches:
            l = len(matches)
            for v in matches:
                if v.startswith('+'):
                    offset = to_int(v[1:])
                    if ((offset is not None) and ((offset // 4) > l)):
                        continue
                argc += 1
        else:
            argc = code.count('push')
    argc = min(argc, 6)
    if (argc == 0):
        return []
    args = []
    sp = self.getreg('sp')
    mem = self.dumpmem(sp, (sp + (4 * argc)))
    for i in range(argc):
        args += [struct.unpack('<L', mem[(i * 4):((i + 1) * 4)])[0]]
    return args
