def solve(fzn):
    """Call FlatZinc solver (Gecode) and process output."""
    import subprocess
    from problog.util import mktempfile
    fznfile = mktempfile('.fzn')
    with open(fznfile, 'w') as f:
        f.write(fzn)
    cmd = ['fzn-gecode', '-a', fznfile]
    result = subprocess.check_output(cmd).decode()
    current = {}
    for line in result.split('\n'):
        if line.startswith('----'):
            yield current
            current = {}
        elif line.startswith('===='):
            return
        else:
            vr, vl = line.strip(';').split(' = ')
            vr = int(vr[1:])
            vl = 1 if vl == 'true' else 0
            current[vr] = vl
