  .text
  .global _start
  .type   _start, @function

_start:
  # Initialize global pointer.
.option push
.option norelax
  la      gp, __global_pointer$
.option pop

  # Stack pointer is intentionally not set here.
  # In the Hazard3 testbench flow, common/init.S enters _start with sp
  # already loaded from __stack_top and adjusted to leave the argc/argv
  # area expected by newlib-style startup code.

  # Clear the .bss segment so debug globals start in a known state.
  la      a0, __bss_start
  la      a1, __bss_end

clear_bss:
  bgeu    a0, a1, finish_bss
  sb      x0, 0(a0)
  addi    a0, a0, 1
  j       clear_bss
finish_bss:

  call    main

  # Exit the testbench with main() return code (Hazard3 init.S provides _exit).
  tail    _exit

  .size  _start, .-_start
