c114645
--- src/main/java/com/ning/compress/lzf/impl/UnsafeChunkEncoderBE.java	2013-03-10 03:40:11.000000000 +0100
c114645
+++ src/main/java/com/ning/compress/lzf/impl/UnsafeChunkEncoderBE.java-ibm-bug-proxy	2014-07-02 10:20:10.626157173 +0200
c114645
@@ -98,7 +98,7 @@
c114645
         int i1 = unsafe.getInt(in, BYTE_ARRAY_OFFSET + ptr1);
c114645
         int i2 = unsafe.getInt(in, BYTE_ARRAY_OFFSET + ptr2);
c114645
         if (i1 != i2) {
c114645
-            return 1 + _leadingBytes(i1, i2);
c114645
+            return 1 + _leadingBytes(Integer.reverseBytes(i1), Integer.reverseBytes(i2));
c114645
         }
c114645
         ptr1 += 4;
c114645
         ptr2 += 4;
c114645
@@ -106,7 +106,7 @@
c114645
         i1 = unsafe.getInt(in, BYTE_ARRAY_OFFSET + ptr1);
c114645
         i2 = unsafe.getInt(in, BYTE_ARRAY_OFFSET + ptr2);
c114645
         if (i1 != i2) {
c114645
-            return 5 + _leadingBytes(i1, i2);
c114645
+            return 5 + _leadingBytes(Integer.reverseBytes(i1), Integer.reverseBytes(i2));
c114645
         }
c114645
         return _findLongMatchLength(in, ptr1+4, ptr2+4, maxPtr1);
c114645
     }
c114645
@@ -120,7 +120,7 @@
c114645
             long l1 = unsafe.getLong(in, BYTE_ARRAY_OFFSET + ptr1);
c114645
             long l2 = unsafe.getLong(in, BYTE_ARRAY_OFFSET + ptr2);
c114645
             if (l1 != l2) {
c114645
-                return ptr1 - base + (Long.numberOfLeadingZeros(l1 ^ l2) >> 3);
c114645
+                return ptr1 - base + (Long.numberOfTrailingZeros(Long.reverseBytes(l1) ^ Long.reverseBytes(l2)) >> 3);
c114645
             }
c114645
             ptr1 += 8;
c114645
             ptr2 += 8;
c114645
@@ -134,6 +134,6 @@
c114645
     }
c114645
 
c114645
     private final static int _leadingBytes(int i1, int i2) {
c114645
-        return (Long.numberOfLeadingZeros(i1 ^ i2) >> 3);
c114645
+        return (Long.numberOfTrailingZeros(i1 ^ i2) >> 3);
c114645
     }
c114645
 }