RK match written in C