package rum;

// Algorithm taken from React.js

public class Adler32 {
    public static int MOD = 65521;

    public static int calc(String data) {
        long a = 1;
        long b = 0;
        int i = 0;
        int l = data.length();
        long m = l & ~0x3;
        long n;
        while (i < m) {
            n = Math.min(i + 4096, m);
            for (; i < n; i += 4) {
                b += (a += data.charAt(i)) +
                     (a += data.charAt(i + 1)) +
                     (a += data.charAt(i + 2)) +
                     (a += data.charAt(i + 3));
            }
            a %= MOD;
            b %= MOD;
        }
        for (; i < l; i++) {
            b += a += data.charAt(i);
        }
        a %= MOD;
        b %= MOD;
        return (int) a | (int) b << 16;
    }
}

@@ -150,20 +150,19 @@
         
-long
+int
  a = 1;%0A
@@ -169,20 +169,19 @@
         
-long
+int
  b = 0;%0A
@@ -238,20 +238,19 @@
         
-long
+int
  m = l &
@@ -268,12 +268,11 @@
     
-long
+int
  n;%0A
@@ -761,23 +761,11 @@
 urn 
-(int) a %7C (int)
+a %7C
  b %3C

ints in adler32 are ok