if [ $(uname -m) != "riscv64" ]; then function compile_and_run() { riscv64-linux-gnu-gcc-12 -static $1.s -o $1.elf && qemu-riscv64 $1.elf < ../boot.c > $2.s return $? } else function compile_and_run() { gcc $1.s -o $1.elf && ./$1.elf < ../boot.c > $2.s return $? } fi mkdir -p build && cd build && gcc ../boot.c -o gcc.elf && ./gcc.elf < ../boot.c > boot1.s && compile_and_run boot1 boot2 && compile_and_run boot2 boot3 cmp --silent boot1.s boot2.s && echo "boot1.s == boot2.s" || echo "boot1.s != boot2.s" cmp --silent boot2.s boot3.s && echo "boot2.s == boot3.s" || echo "boot2.s != boot3.s" cmp --silent boot1.s boot3.s && echo "boot1.s == boot3.s" || echo "boot1.s != boot3.s"