//! An array repeat literal of more than 32 scalar elements of 1, 2, 4, or 8 bytes fills the array
//! in double words. The IL reserves the array at an 8-byte alignment, replicates a constant item
//! into a constant word, masks and multiplies a run-time item, and stores 64 bytes per loop
//! iteration, and has no loop when fewer than 64 bytes fit. The words and elements that remain
//! follow the loop at fixed offsets. A zero item stores the zero register. An item of 8 bytes is
//! its own word. A record item keeps the loop of one blit per element, and a literal of at most 32
//! elements stays inline. This IL snapshot covers each case.

/// Record with a string slice and a word.
record Entry: Copy {
    /// Name of the entry.
    name: *[u8],
    /// Count of the entry.
    n: u32,
}

/// Fill 33 zero bytes. Fewer than 64 bytes need no loop: a store for each double word, then one
/// byte.
fn zeroBytes() -> u8 {
    let a: [u8; 33] = [0; 33];
    return a[3];
}

/// Fill 73 bytes with a run-time value: one loop iteration, a double word, and one byte.
fn loopBytes(x: u8) -> u8 {
    let a: [u8; 73] = [x; 73];
    return a[3];
}

/// Fill 1024 bytes with a constant that is replicated in a word.
fn constBytes() -> u8 {
    let a: [u8; 1024] = [0xFF; 1024];
    return a[3];
}

/// Fill 40 halfwords with a run-time value, which is masked and multiplied.
fn runHalves(x: u16) -> u16 {
    let a: [u16; 40] = [x; 40];
    return a[3];
}

/// Fill 1025 words with a constant.
fn constWords() -> u32 {
    let a: [u32; 1025] = [0x1234; 1025];
    return a[3];
}

/// Fill 40 double words with a run-time value, which needs no replication.
fn runDoubles(x: u64) -> u64 {
    let a: [u64; 40] = [x; 40];
    return a[3];
}

/// Fill 40 signed bytes with a negative constant.
fn negBytes() -> i8 {
    let a: [i8; 40] = [-2; 40];
    return a[3];
}

/// Store four bytes inline.
fn inlineBytes(x: u8) -> u8 {
    let a: [u8; 4] = [x; 4];
    return a[3];
}

/// Fill 40 records in a loop, each by a blit.
fn loopEntries(x: u32) -> u32 {
    let a: [Entry; 40] = [Entry { name: "", n: x }; 40];
    return a[3].n;
}

/// An `undefined` item stores nothing, so the literal emits no fill.
unsafe fn skipUndefined() -> u32 {
    let a: [u32; 100] = [undefined; 100];
    return 0;
}

@default fn main() -> i32 {
    return 0;
}
