fn copy() {
    let operation = operation_from_args();
    MEMORY.with(|memory| {
        let mut memory_ref = memory.borrow_mut();
        let memory = memory_ref.as_mut_slice();
        let repeat = operation.repeat.unwrap_or(1);
        let len = (operation.size + ELEMENT_SIZE - 1) / ELEMENT_SIZE;
        assert!(2 * len <= MEMORY_LEN);
        let value = operation
            .value
            .unwrap_or_else(|| rand(0, u8::MAX.into()) as u8);
        for _ in 0..repeat {
            let src = rand(len, MEMORY_LEN - len + 1);
            let dst = rand(0, src - len + 1);
            for i in 0..len as usize {
                memory[dst + i] = memory[src + i] + value as u64;
            }
        }
    });
    api::reply(&[]);
}
/// Copies a memory regions of the given size from one random address to another
/// and adds the given eight byte value to each destination eight byte word.
/// The latter is done to ensure that the memory regions remain different so
/// that multiple update calls get similar state.
///
/// The addresses are chosen such that they do not overlap.
///
/// Arguments:
/// - operation.repeat: the number of operations.
/// - operation.size: the size of the memory region in bytes. It must not exceed
///   MEMORY_SIZE / 2.
/// - operation.value: an optional value to be added on copy. It is chosen
///   randomly if not specified.
Copies a memory regions of the given size from one random address to another
and adds the given eight byte value to each destination eight byte word.
The latter is done to ensure that the memory regions remain different so
that multiple update calls get similar state.

The addresses are chosen such that they do not overlap.

operation.repeat: the number of operations.
operation.size: the size of the memory region in bytes. It must not exceed
MEMORY_SIZE / 2.
operation.value: an optional value to be added on copy. It is chosen
randomly if not specified.
Copies a memory regions of the given size from one random address to another and adds the given eight byte value to each destination eight byte word . The latter is done to ensure that the memory regions remain different so that multiple update calls get similar state . The addresses are chosen such that they do not overlap . operation . repeat : the number of operations . operation . size : the size of the memory region in bytes . It must not exceed MEMORY_SIZE / 2 . operation . value : an optional value to be added on copy . It is chosen randomly if not specified .
fn copy() {
    let operation = operation_from_args();
    MEMORY.with(|memory| {
        let mut memory_ref = memory.borrow_mut();
        let memory = memory_ref.as_mut_slice();
        let repeat = operation.repeat.unwrap_or(1);
        let len = (operation.size + ELEMENT_SIZE - 1) / ELEMENT_SIZE;
        assert!(2 * len <= MEMORY_LEN);
        let value = operation
            .value
            .unwrap_or_else(|| rand(0, u8::MAX.into()) as u8);
        for _ in 0..repeat {
            let src = rand(len, MEMORY_LEN - len + 1);
            let dst = rand(0, src - len + 1);
            for i in 0..len as usize {
                memory[dst + i] = memory[src + i] + value as u64;
            }
        }
    });
    api::reply(&[]);
}
fn copy ( ) { let operation = operation_from_args ( ) ; MEMORY . with ( | memory | { let mut memory_ref = memory . borrow_mut ( ) ; let memory = memory_ref . as_mut_slice ( ) ; let repeat = operation . repeat . unwrap_or ( 1 ) ; let len = ( operation . size + ELEMENT_SIZE - 1 ) / ELEMENT_SIZE ; assert ! ( 2 len MEMORY_LEN ) ; let value = operation . value . unwrap_or_else ( | | rand ( 0 , u8 :: MAX . into ( ) ) as u8 ) ; for _ in 0 .. repeat { let src = rand ( len , MEMORY_LEN - len + 1 ) ; let dst = rand ( 0 , src - len + 1 ) ; for i in 0 .. len as usize { memory [ dst + i ] = memory [ src + i ] + value as u64 ; } } } ) ; api :: reply ( & [ ] ) ; }
Copies a memory regions of the given size from one random address to another
and adds the given eight byte value to each destination eight byte word.
Copies a memory regions of the given size from one random address to another and adds the given eight byte value to each destination eight byte word .