You haven't specified where the infinite loop is occurring. One potential source of problems is the down_to_one_asm
function. You also need to specify the registers you have clobbered, e.g.
: "=c" (v) : "c" (v) : "%eax", "%ebx"
You might be getting away with "-O0"
, but higher levels are probably optimizing the call-stack/frame setup - and "-O2"
is (IIRC) implementing tail-call optimization.