Without going into too much detail, you might want to start
having a look at the MonetDB-extend repository.
Also keep in mind, that the use of MAL scripts for declaring C
functions in MAL is deprecated in favor of the command and
pattern preprocessor macro's.