This is what I did to solve the issue.
My environment is the following:
Xcode 14.0.1
macOS Monterrey 12.6
Python 3.8.5
I downloaded an old SDK version that works as expected (MacOSX10.9.sdk). I downloaded from phracker's github:
git clone https://github.com/phracker/MacOSX-SDKs.git
I downloaded it into the SDKs folder created when installing xcode tools, and I set the CONDA_BUILD_SYSROOT to that path:
export CONDA_BUILD_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/manual/MacOSX-SDKs/MacOSX10.9.sdk"
After that the compilation worked successfully:
x86_64-apple-darwin13.4.0-clang /tmp/main.c -o /tmp/main.out