On Linux moving 32 bit program to 64 bit: 3 segmentation faults for invalid memory references (malloc?)

This will not work. You do not have an explicit interface for call_it. The implicit none will probably catch you in this case and the compiler will complain, since it won’t be able to assume the return type of the function. If you add an explicit interface it might work as expected, but the call_it function is completely unnecessary in this case. Just call func directly.

SUBROUTINE foobar ()
         interface
           function func(arg) result(res) bind(C, name='func')
             import :: c_int
             integer(c_int), intent(in), value :: arg
             integer(c_int) :: res
           end function
         end interface
         INTEGER(KIND=C_INT) :: i
     
         ! Use it.
         DO i = 1_C_INT, 10_C_INT
           PRINT *, func (i)
         END DO
END SUBROUTINE foobar