Interrupt without Arduino lib help

So i'm a hobbyist but after finishing a project with Due recently that made me have to delve deep into the datasheet I'm intrigued to learn more. My question is how exactly is something like attachInterrupt() supported and how do you register a function of some type to a specific interrupt outside the Arduino.

For example, I'm seeing how to set the different PIO interrupt registers, but I don't see exactly how I go from that to executing a function. I am just setting a register and not giving it sufficient information to execute one or suspend execution.

In fact the documentation says,

"When the software reads PIO_ISR, all the interrupts are automatically cleared. This signifies that all the interrupts
that are pending when PIO_ISR is read must be handled. When an Interrupt is enabled on a “Level”, the interrupt
is generated as long as the interrupt source is not cleared, even if some read accesses in PIO_ISR are performed. "

Which implies to me interrupts are just queryable flags for the PIO channels, am I missing something? Does that mean I basically need to lock up the processor with

while(!readInterrupt(pin)) {}

or else risk it triggering to late because the cpu is busy doing something else? I think I'm misunderstanding something so would appreciate someone elses insight.

The beauty of the system is it's open source. You can open up attachInterrupt() and see what it's doing.