long PaConvert_TriangularDither(void) {
  static unsigned long previous = 0;
  static unsigned long randSeed1 = 22222;
  static unsigned long randSeed2 = 5555555;
  long current, highPass;
  randSeed1 = (randSeed1 * 196314165) + 907633515;
  randSeed2 = (randSeed2 * 196314165) + 907633515;
  current = (((long)randSeed1) >> ((32 - (15)) + 1)) +
            (((long)randSeed2) >> ((32 - (15)) + 1));
  highPass = current - previous;
  previous = current;
  return highPass;
}


x86 assembly (clang, -O0):
<PaConvert_TriangularDither>:
push   %rbp
mov    %rsp,%rbp
imul   $0xbb38435,0x2f11(%rip),%rax
35 84 b3 0b
add    $0x3619636b,%rax
mov    %rax,0x2f04(%rip)
imul   $0xbb38435,0x2f01(%rip),%rax
35 84 b3 0b
add    $0x3619636b,%rax
mov    %rax,0x2ef4(%rip)
mov    0x2ee5(%rip),%rax
sar    $0x12,%rax
mov    0x2ee2(%rip),%rcx
sar    $0x12,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
sub    0x2edc(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,0x2ecd(%rip)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<PaConvert_TriangularDither>:
imul   $0xbb38435,0x2f15(%rip),%rax
35 84 b3 0b
add    $0x3619636b,%rax
mov    %rax,0x2f08(%rip)
imul   $0xbb38435,0x2f05(%rip),%rcx
35 84 b3 0b
add    $0x3619636b,%rcx
mov    %rcx,0x2ef7(%rip)
sar    $0x12,%rax
sar    $0x12,%rcx
add    %rax,%rcx
mov    %rcx,%rax
sub    0x2ef2(%rip),%rax
mov    %rcx,0x2eeb(%rip)
ret

LLVM IR (-O0):
@PaConvert_TriangularDither.previous = internal global i64 0
@PaConvert_TriangularDither.randSeed1 = internal global i64 22222
@PaConvert_TriangularDither.randSeed2 = internal global i64 5555555
define i64 @PaConvert_TriangularDither() {
%1 = alloca i64
%2 = alloca i64
%3 = load i64, i64* @PaConvert_TriangularDither.randSeed1
%4 = mul i64 %3, 196314165
%5 = add i64 %4, 907633515
store i64 %5, i64* @PaConvert_TriangularDither.randSeed1
%6 = load i64, i64* @PaConvert_TriangularDither.randSeed2
%7 = mul i64 %6, 196314165
%8 = add i64 %7, 907633515
store i64 %8, i64* @PaConvert_TriangularDither.randSeed2
%9 = load i64, i64* @PaConvert_TriangularDither.randSeed1
%10 = ashr i64 %9, 18
%11 = load i64, i64* @PaConvert_TriangularDither.randSeed2
%12 = ashr i64 %11, 18
%13 = add nsw i64 %10, %12
store i64 %13, i64* %1
%14 = load i64, i64* %1
%15 = load i64, i64* @PaConvert_TriangularDither.previous
%16 = sub i64 %14, %15
store i64 %16, i64* %2
%17 = load i64, i64* %1
store i64 %17, i64* @PaConvert_TriangularDither.previous
%18 = load i64, i64* %2
ret i64 %18
}

LLVM IR (-O2):
@PaConvert_TriangularDither.previous = internal unnamed_addr global i64 0
@PaConvert_TriangularDither.randSeed1 = internal unnamed_addr global i64 22222
@PaConvert_TriangularDither.randSeed2 = internal unnamed_addr global i64 5555555
define i64 @PaConvert_TriangularDither() {
%1 = load i64, i64* @PaConvert_TriangularDither.randSeed1
%2 = mul i64 %1, 196314165
%3 = add i64 %2, 907633515
store i64 %3, i64* @PaConvert_TriangularDither.randSeed1
%4 = load i64, i64* @PaConvert_TriangularDither.randSeed2
%5 = mul i64 %4, 196314165
%6 = add i64 %5, 907633515
store i64 %6, i64* @PaConvert_TriangularDither.randSeed2
%7 = ashr i64 %3, 18
%8 = ashr i64 %6, 18
%9 = add nsw i64 %8, %7
%10 = load i64, i64* @PaConvert_TriangularDither.previous
%11 = sub i64 %9, %10
store i64 %9, i64* @PaConvert_TriangularDither.previous
ret i64 %11
}