package androidx.emoji2.text;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/* JADX INFO: loaded from: classes.dex */
public abstract class m0 {
    public static f1.b a(ByteBuffer byteBuffer) throws IOException {
        long j10;
        ByteBuffer byteBufferDuplicate = byteBuffer.duplicate();
        k0 k0Var = new k0(0, byteBufferDuplicate);
        k0Var.a(4);
        ByteBuffer byteBuffer2 = k0Var.f2240a;
        int i10 = byteBuffer2.getShort() & 65535;
        if (i10 > 100) {
            throw new IOException("Cannot read metadata.");
        }
        k0Var.a(6);
        int i11 = 0;
        while (true) {
            if (i11 >= i10) {
                j10 = -1;
                break;
            }
            int i12 = byteBuffer2.getInt();
            k0Var.a(4);
            j10 = ((long) byteBuffer2.getInt()) & 4294967295L;
            k0Var.a(4);
            if (1835365473 == i12) {
                break;
            }
            i11++;
        }
        if (j10 != -1) {
            k0Var.a((int) (j10 - ((long) byteBuffer2.position())));
            k0Var.a(12);
            long j11 = ((long) byteBuffer2.getInt()) & 4294967295L;
            for (int i13 = 0; i13 < j11; i13++) {
                int i14 = byteBuffer2.getInt();
                long j12 = ((long) byteBuffer2.getInt()) & 4294967295L;
                byteBuffer2.getInt();
                if (1164798569 == i14 || 1701669481 == i14) {
                    byteBufferDuplicate.position((int) (j12 + j10));
                    f1.b bVar = new f1.b();
                    byteBufferDuplicate.order(ByteOrder.LITTLE_ENDIAN);
                    int iPosition = byteBufferDuplicate.position() + byteBufferDuplicate.getInt(byteBufferDuplicate.position());
                    bVar.f25892b = byteBufferDuplicate;
                    bVar.f25891a = iPosition;
                    int i15 = iPosition - byteBufferDuplicate.getInt(iPosition);
                    bVar.f25893c = i15;
                    bVar.f25894d = bVar.f25892b.getShort(i15);
                    return bVar;
                }
            }
        }
        throw new IOException("Cannot read metadata.");
    }
}
