// GENERATED BY DSC COMPILER
// Generated at 2026-02-23 17:29:47

// Imports
include print: "./lib/io/print.dsa"
include alloc: "./lib/memory/block_alloc.dsa"

// Globals & Reserved Memory

// Entry Point
dw stack: 0x010000
db message: "Process Exited with code:"
_init:
    ldw stack, bpr, 0
    mov bpr, spr
    push zero
    call main
    call print::print_newline
    lwi message, rg0
    push rg0
    call print::print
    pop zero
    call print::print_hex_word
    pop zero
    hlt

// Return
_ret:
    mov bpr, spr
    pop bpr
    return

db str_16: "successful free of ptr"
// fn main() -> u32
main:
    push bpr
    mov spr, bpr
    lli 32, rg0
    lli 64, rg1
    // push arg 1
    push rg0
    // push arg 0
    push rg1
    call alloc::init
    pop rg2
    pop zero
    push rg2
    // push arg 0
    push rg2
    call print::print_hex_word
    pop zero
    call print::print_newline
    ldw spr, rg0, 0
    stw rg0, spr, 0
    // push arg 0
    push rg0
    call alloc::alloc
    pop rg1
    push rg1
    // push arg 0
    push rg1
    call print::print_hex_word
    pop zero
    lli 200, rg0
    ldw spr, rg1, 0
    stw rg0, rg1, 0
    stw rg1, spr, 0
    call print::print_newline
    ldw spr, rg0, 4
    stw rg0, spr, 4
    // push arg 0
    push rg0
    call alloc::alloc
    pop rg2
    push rg2
    // push arg 0
    push rg2
    call print::print_hex_word
    pop zero
    call print::print_newline
    ldw spr, rg0, 4
    ldw rg0, rg2, 0
    stw rg0, spr, 4
    // push arg 0
    push rg2
    call print::print_num
    pop zero
    ldw spr, rg2, 4
    stw rg2, spr, 4
    addi spr, 4, rg3
    ldw spr, rg2, 8
    stw rg2, spr, 8
    // push arg 1
    push rg3
    // push arg 0
    push rg2
    call alloc::free
    pop zero
    pop zero
    ldw spr, rg2, 8
    stw rg2, spr, 8
    // push arg 0
    push rg2
    call alloc::alloc
    pop rg3
    push rg3
    call print::print_newline
    ldw spr, rg2, 0
    stw rg2, spr, 0
    // push arg 0
    push rg2
    call print::print_hex_word
    pop zero
    call print::print_newline
    ldw spr, rg2, 8
    stw rg2, spr, 8
    // push arg 0
    push rg2
    call print::print_hex_word
    pop zero
    ldw spr, rg2, 8
    lli 0, rg4
    cmp rg2, rg4
    lli 1, rg5
    jeq _cmp_end_12
    lli 0, rg5
_cmp_end_12:
    cmp rg5, zero
    jeq _else_14
_then_13:
    lwi str_16, rg4
    stw rg2, spr, 8
    // push arg 0
    push rg4
    call print::print
    pop zero
    jmp _end_15
_else_14:
    nop
_end_15:
    lli 0, rg4
    stw rg4, bpr, 8
    jmp _ret