completed gen_fmtstr_rop function