package o; import com.google.common.base.Ascii; import com.google.common.primitives.UnsignedBytes; import java.io.IOException; import java.io.UnsupportedEncodingException; import org.bouncycastle.crypto.tls.CipherSuite; /* loaded from: classes.dex */ public abstract class Pmg { public boolean b = true; public abstract long a() throws IOException; protected abstract void a(int i, int i2) throws IOException; protected abstract boolean b(int i, int i2) throws IOException; public abstract byte[] c(int i, int i2) throws IOException; public abstract byte d(int i) throws IOException; public final boolean c(int i) throws IOException { int i2 = i / 8; a(i2, 1); return ((d(i2) >> (i % 8)) & 1) == 1; } public final short m(int i) throws IOException { a(i, 1); return (short) (d(i) & UnsignedBytes.MAX_VALUE); } public final byte j(int i) throws IOException { a(i, 1); return d(i); } public final int l(int i) throws IOException { int d; byte d2; a(i, 2); if (this.b) { d = (d(i) << 8) & CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB; d2 = d(i + 1); } else { d = (d(i + 1) << 8) & CipherSuite.DRAFT_TLS_DHE_RSA_WITH_AES_128_OCB; d2 = d(i); } return (d2 & UnsignedBytes.MAX_VALUE) | d; } public final short a(int i) throws IOException { int d; byte d2; a(i, 2); if (this.b) { d = (d(i) << 8) & (-256); d2 = d(i + 1); } else { d = (d(i + 1) << 8) & (-256); d2 = d(i); } return (short) ((d2 & 255) | d); } public final int f(int i) throws IOException { int d; byte d2; a(i, 3); if (this.b) { d = ((d(i) << 16) & 16711680) | (65280 & (d(i + 1) << 8)); d2 = d(i + 2); } else { d = ((d(i + 2) << 16) & 16711680) | (65280 & (d(i + 1) << 8)); d2 = d(i); } return (d2 & UnsignedBytes.MAX_VALUE) | d; } public final long o(int i) throws IOException { long d; byte d2; a(i, 4); if (this.b) { d = ((d(i) << 24) & 4278190080L) | ((d(i + 1) << 16) & 16711680) | ((d(i + 2) << 8) & 65280); d2 = d(i + 3); } else { d = ((d(i + 3) << 24) & 4278190080L) | ((d(i + 2) << 16) & 16711680) | ((d(i + 1) << 8) & 65280); d2 = d(i); } return (d2 & 255) | d; } public final int g(int i) throws IOException { int d; byte d2; a(i, 4); if (this.b) { d = ((d(i) << Ascii.CAN) & (-16777216)) | (16711680 & (d(i + 1) << 16)) | (65280 & (d(i + 2) << 8)); d2 = d(i + 3); } else { d = ((d(i + 3) << Ascii.CAN) & (-16777216)) | (16711680 & (d(i + 2) << 16)) | (65280 & (d(i + 1) << 8)); d2 = d(i); } return (d2 & UnsignedBytes.MAX_VALUE) | d; } public final long i(int i) throws IOException { long d; byte d2; a(i, 8); if (this.b) { long d3 = d(i); d = ((d(i + 1) << 48) & 71776119061217280L) | ((d3 << 56) & (-72057594037927936L)) | ((d(i + 2) << 40) & 280375465082880L) | ((d(i + 3) << 32) & 1095216660480L) | ((d(i + 4) << 24) & 4278190080L) | ((d(i + 5) << 16) & 16711680) | ((d(i + 6) << 8) & 65280); d2 = d(i + 7); } else { d = ((d(i + 7) << 56) & (-72057594037927936L)) | ((d(i + 6) << 48) & 71776119061217280L) | ((d(i + 5) << 40) & 280375465082880L) | ((d(i + 4) << 32) & 1095216660480L) | ((d(i + 3) << 24) & 4278190080L) | ((d(i + 2) << 16) & 16711680) | ((d(i + 1) << 8) & 65280); d2 = d(i); } return d | (d2 & 255); } public final float h(int i) throws IOException { float d; int d2; byte d3; a(i, 4); if (this.b) { d = ((d(i) & UnsignedBytes.MAX_VALUE) << 8) | (d(i + 1) & UnsignedBytes.MAX_VALUE); d2 = (d(i + 2) & UnsignedBytes.MAX_VALUE) << 8; d3 = d(i + 3); } else { d = ((d(i + 3) & UnsignedBytes.MAX_VALUE) << 8) | (d(i + 2) & UnsignedBytes.MAX_VALUE); d2 = (d(i + 1) & UnsignedBytes.MAX_VALUE) << 8; d3 = d(i); } return (float) (d + (((d3 & UnsignedBytes.MAX_VALUE) | d2) / 65536.0d)); } public final float e(int i) throws IOException { return Float.intBitsToFloat(g(i)); } public final double b(int i) throws IOException { return Double.longBitsToDouble(i(i)); } public final String e(int i, int i2, String str) throws IOException { byte[] c = c(i, i2); try { return new String(c, str); } catch (UnsupportedEncodingException unused) { return new String(c); } } public final byte[] d(int i, int i2) throws IOException { byte[] c = c(i, i2); int i3 = 0; while (i3 < c.length && c[i3] != 0) { i3++; } if (i3 == i2) { return c; } byte[] bArr = new byte[i3]; if (i3 > 0) { System.arraycopy(c, 0, bArr, 0, i3); } return bArr; } }