Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created May 16, 2018 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/4b0396c7599d3b15dadc2c82f62b624e to your computer and use it in GitHub Desktop.
Save alexcrichton/4b0396c7599d3b15dadc2c82f62b624e to your computer and use it in GitHub Desktop.
#![crate_type = "cdylib"]
pub struct V4(u16, u16, u16, u16);
pub struct V8(u16, u16, u16, u16, u16, u16, u16, u16);
#[inline(never)]
fn inv4(v: &V4) -> u16 {
v.2 ^ (v.2 & v.0)
}
fn split8(a: u16, b: u16, c: u16) -> (V4, V4) {
(V4(0, 0, 0, a), V4(b, c, 0, 0))
}
#[inline(never)]
fn inv8(v: V8) -> u16 {
let (_b, a) = split8(v.3, v.4, v.5);
inv4(&a)
}
#[no_mangle]
pub extern fn test() -> u16 {
inv8(V8(0, 0, 0, 0, 1, 65520, 0, 2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment