All pastes #297486 Raw Edit

ocamlopt lsr

public text v1 · immutable
#297486 ·published 2006-12-31 03:23 UTC
rendered paste body
let next_char c =
        let x = int_of_char c in
        let ab = (x land 0x80 lsr 7) land (x land 0x40 lsr 6) in
        let abc = ab land (x land 0x20 lsr 5) in
        let abcd = abc land (x land 0x10 lsr 4) in
        1 + ab + abc + abcd;;
        
(* compiles to:
        
        movl    %eax, %ebx
        andl    $3, %ebx
        movl    %eax, %edx
        andl    $3, %edx
        andl    %ebx, %edx
        movl    %eax, %ebx
        andl    $3, %ebx
        movl    %edx, %ecx
        andl    %ebx, %ecx
        andl    $3, %eax
        movl    %ecx, %ebx
        andl    %eax, %ebx
        movl    %edx, %eax
        addl    %ecx, %eax
        addl    %ebx, %eax
        ret
*)