//! returns: 0

/// Adjacent swaps and rotation produce all 120 region argument permutations.
record Node: 'a + 'b + 'c + 'd + 'e + Copy {
    /// Link with rotated region arguments.
    rotated: ?*Node 'b 'c 'd 'e 'a,
    /// Link with the first two region arguments exchanged.
    swapped: ?*Node 'b 'a 'c 'd 'e,
    /// Value retained across all applications.
    value: u32,
}

/// Read through a distinct set of five region identities.
fn read0 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read1 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read2 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read3 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read4 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read5 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read6 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read7 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Read through a distinct set of five region identities.
fn read8 'a 'b 'c 'd 'e (node: Node 'a 'b 'c 'd 'e) -> u32 {
    assert node.rotated == nil;
    assert node.swapped == nil;
    return node.value;
}

/// Resolve more exact applications than the cache has buckets.
fn check 'a 'b 'c 'd 'e (a: &'a u32, b: &'b u32, c: &'c u32, d: &'d u32, e: &'e u32) {
    let node = Node 'a 'b 'c 'd 'e { rotated: nil, swapped: nil, value: 42 };
    assert read0(node) == 42;
    assert read1(node) == 42;
    assert read2(node) == 42;
    assert read3(node) == 42;
    assert read4(node) == 42;
    assert read5(node) == 42;
    assert read6(node) == 42;
    assert read7(node) == 42;
    assert read8(node) == 42;
}

/// Execute the cache collision workload with live region arguments.
@default fn main() -> u32 {
    let value: u32 = 0;
    let p: 'r = &value in {
        check(p, p, p, p, p);
    }
    return 0;
}
