Rewrite subsync in C

Since subsync was the only code that I wrote in Go and since I forgot
Go, I decided to rewrite it in C.