@echo off
setlocal
where cl >nul 2>nul || (echo Open the Visual Studio x64 Native Tools Command Prompt. & exit /b 1)
pushd "%~dp0" || exit /b 1
if not exist bin mkdir bin
ml64 /nologo /c /Fobin\entry.obj entry.asm || goto failed
call :build 1 gray-rotate || goto failed
call :build 2 nibble-permutation || goto failed
call :build 3 modular-recurrence || goto failed
call :build 4 branch-mixer || goto failed
call :build 5 paired-rounds || goto failed
popd
exit /b 0

:build
cl /nologo /O2 /GS- /c /DCASE_ID=%1 /Fobin\%2.obj challenge.c || exit /b 1
link /nologo /nodefaultlib /entry:fixture_entry /subsystem:console /out:bin\%2.exe bin\entry.obj bin\%2.obj kernel32.lib
exit /b %errorlevel%

:failed
popd
exit /b 1
