package io.netty.util.internal;

import com.seewo.libmcuservice.constant.IMcuConstants;
import com.seewo.sdk.model.SDKKeyboardCode;
import io.netty.util.internal.chmv8.ConcurrentHashMapV8;
import io.netty.util.internal.chmv8.LongAdderV8;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue;
import io.netty.util.internal.shaded.org.jctools.queues.MpscChunkedArrayQueue;
import io.netty.util.internal.shaded.org.jctools.queues.SpscLinkedQueue;
import io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscAtomicArrayQueue;
import io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscLinkedAtomicQueue;
import io.netty.util.internal.shaded.org.jctools.queues.atomic.SpscLinkedAtomicQueue;
import java.io.File;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Deque;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/* JADX INFO: loaded from: classes.dex */
public final class PlatformDependent {
    static final /* synthetic */ boolean $assertionsDisabled = false;
    private static final int ADDRESS_SIZE;
    public static final boolean BIG_ENDIAN_NATIVE_ORDER;
    private static final int BIT_MODE;
    private static final long BYTE_ARRAY_BASE_OFFSET;
    private static final boolean CAN_ENABLE_TCP_NODELAY_BY_DEFAULT;
    private static final boolean CAN_USE_CHM_V8;
    private static final int DEFAULT_MAX_MPSC_CAPACITY = 1048576;
    private static final boolean DIRECT_BUFFER_PREFERRED;
    private static final AtomicLong DIRECT_MEMORY_COUNTER;
    private static final long DIRECT_MEMORY_LIMIT;
    private static final boolean HAS_JAVASSIST;
    private static final boolean HAS_UNSAFE;
    private static final boolean IS_ANDROID;
    private static volatile Boolean IS_ROOT = null;
    private static final boolean IS_WINDOWS;
    private static final int JAVA_VERSION;
    private static final int MAX_ALLOWED_MPSC_CAPACITY = 1073741824;
    private static final long MAX_DIRECT_MEMORY;
    private static final Pattern MAX_DIRECT_MEMORY_SIZE_ARG_PATTERN;
    private static final int MIN_MAX_MPSC_CAPACITY = 2048;
    private static final int MPSC_CHUNK_SIZE = 1024;
    private static final File TMPDIR;
    private static final boolean USE_DIRECT_BUFFER_NO_CLEANER;
    private static final InternalLogger logger;

    private static final class AtomicLongCounter extends AtomicLong implements LongCounter {
        private static final long serialVersionUID = 4074772784610639305L;

        private AtomicLongCounter() {
        }

        @Override // io.netty.util.internal.LongCounter
        public void add(long j) {
            addAndGet(j);
        }

        @Override // io.netty.util.internal.LongCounter
        public void decrement() {
            decrementAndGet();
        }

        @Override // io.netty.util.internal.LongCounter
        public void increment() {
            incrementAndGet();
        }

        @Override // io.netty.util.internal.LongCounter
        public long value() {
            return get();
        }
    }

    static {
        InternalLogger internalLoggerFactory = InternalLoggerFactory.getInstance((Class<?>) PlatformDependent.class);
        logger = internalLoggerFactory;
        MAX_DIRECT_MEMORY_SIZE_ARG_PATTERN = Pattern.compile("\\s*-XX:MaxDirectMemorySize\\s*=\\s*([0-9]+)\\s*([kKmMgG]?)\\s*$");
        IS_ANDROID = isAndroid0();
        IS_WINDOWS = isWindows0();
        int iJavaVersion0 = javaVersion0();
        JAVA_VERSION = iJavaVersion0;
        CAN_ENABLE_TCP_NODELAY_BY_DEFAULT = !isAndroid();
        boolean zHasUnsafe0 = hasUnsafe0();
        HAS_UNSAFE = zHasUnsafe0;
        CAN_USE_CHM_V8 = zHasUnsafe0 && iJavaVersion0 < 8;
        boolean z = zHasUnsafe0 && !SystemPropertyUtil.getBoolean("io.netty.noPreferDirect", false);
        DIRECT_BUFFER_PREFERRED = z;
        MAX_DIRECT_MEMORY = maxDirectMemory0();
        BYTE_ARRAY_BASE_OFFSET = PlatformDependent0.byteArrayBaseOffset();
        HAS_JAVASSIST = hasJavassist0();
        TMPDIR = tmpdir0();
        BIT_MODE = bitMode0();
        ADDRESS_SIZE = addressSize0();
        BIG_ENDIAN_NATIVE_ORDER = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
        if (internalLoggerFactory.isDebugEnabled()) {
            internalLoggerFactory.debug("-Dio.netty.noPreferDirect: {}", Boolean.valueOf(!z));
        }
        if (!hasUnsafe() && !isAndroid()) {
            internalLoggerFactory.info("Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system unstability.");
        }
        long jMaxDirectMemory0 = SystemPropertyUtil.getLong("io.netty.maxDirectMemory", -1L);
        if (jMaxDirectMemory0 != 0 && hasUnsafe() && PlatformDependent0.hasDirectBufferNoCleanerConstructor()) {
            USE_DIRECT_BUFFER_NO_CLEANER = true;
            if (jMaxDirectMemory0 < 0) {
                jMaxDirectMemory0 = maxDirectMemory0();
                if (jMaxDirectMemory0 <= 0) {
                    DIRECT_MEMORY_COUNTER = null;
                } else {
                    DIRECT_MEMORY_COUNTER = new AtomicLong();
                }
            } else {
                DIRECT_MEMORY_COUNTER = new AtomicLong();
            }
        } else {
            USE_DIRECT_BUFFER_NO_CLEANER = false;
            DIRECT_MEMORY_COUNTER = null;
        }
        DIRECT_MEMORY_LIMIT = jMaxDirectMemory0;
        internalLoggerFactory.debug("io.netty.maxDirectMemory: {} bytes", Long.valueOf(jMaxDirectMemory0));
    }

    private PlatformDependent() {
    }

    public static int addressSize() {
        return ADDRESS_SIZE;
    }

    private static int addressSize0() {
        if (hasUnsafe()) {
            return PlatformDependent0.addressSize();
        }
        return -1;
    }

    public static ByteBuffer allocateDirectNoCleaner(int i) throws Throwable {
        incrementMemoryCounter(i);
        try {
            return PlatformDependent0.allocateDirectNoCleaner(i);
        } catch (Throwable th) {
            decrementMemoryCounter(i);
            throwException(th);
            return null;
        }
    }

    public static long allocateMemory(long j) {
        return PlatformDependent0.allocateMemory(j);
    }

    public static int bitMode() {
        return BIT_MODE;
    }

    private static int bitMode0() {
        int i = SystemPropertyUtil.getInt("io.netty.bitMode", 0);
        if (i > 0) {
            logger.debug("-Dio.netty.bitMode: {}", Integer.valueOf(i));
            return i;
        }
        int i2 = SystemPropertyUtil.getInt("sun.arch.data.model", 0);
        if (i2 > 0) {
            logger.debug("-Dio.netty.bitMode: {} (sun.arch.data.model)", Integer.valueOf(i2));
            return i2;
        }
        int i3 = SystemPropertyUtil.getInt("com.ibm.vm.bitmode", 0);
        if (i3 > 0) {
            logger.debug("-Dio.netty.bitMode: {} (com.ibm.vm.bitmode)", Integer.valueOf(i3));
            return i3;
        }
        String str = SystemPropertyUtil.get("os.arch", "");
        Locale locale = Locale.US;
        String strTrim = str.toLowerCase(locale).trim();
        if ("amd64".equals(strTrim) || "x86_64".equals(strTrim)) {
            i3 = 64;
        } else if ("i386".equals(strTrim) || "i486".equals(strTrim) || "i586".equals(strTrim) || "i686".equals(strTrim)) {
            i3 = 32;
        }
        if (i3 > 0) {
            logger.debug("-Dio.netty.bitMode: {} (os.arch: {})", Integer.valueOf(i3), strTrim);
        }
        Matcher matcher = Pattern.compile("([1-9][0-9]+)-?bit").matcher(SystemPropertyUtil.get("java.vm.name", "").toLowerCase(locale));
        if (matcher.find()) {
            return Integer.parseInt(matcher.group(1));
        }
        return 64;
    }

    public static boolean canEnableTcpNoDelayByDefault() {
        return CAN_ENABLE_TCP_NODELAY_BY_DEFAULT;
    }

    public static void copyMemory(long j, long j2, long j3) {
        PlatformDependent0.copyMemory(j, j2, j3);
    }

    private static void decrementMemoryCounter(int i) {
        AtomicLong atomicLong = DIRECT_MEMORY_COUNTER;
        if (atomicLong != null) {
            atomicLong.addAndGet(-i);
        }
    }

    public static long directBufferAddress(ByteBuffer byteBuffer) {
        return PlatformDependent0.directBufferAddress(byteBuffer);
    }

    public static boolean directBufferPreferred() {
        return DIRECT_BUFFER_PREFERRED;
    }

    public static boolean equals(byte[] bArr, int i, byte[] bArr2, int i2, int i3) {
        return (hasUnsafe() && PlatformDependent0.unalignedAccess()) ? PlatformDependent0.equals(bArr, i, bArr2, i2, i3) : equalsSafe(bArr, i, bArr2, i2, i3);
    }

    public static int equalsConstantTime(byte[] bArr, int i, byte[] bArr2, int i2, int i3) {
        return (hasUnsafe() && PlatformDependent0.unalignedAccess()) ? PlatformDependent0.equalsConstantTime(bArr, i, bArr2, i2, i3) : ConstantTimeUtils.equalsConstantTime(bArr, i, bArr2, i2, i3);
    }

    private static boolean equalsSafe(byte[] bArr, int i, byte[] bArr2, int i2, int i3) {
        int i4 = i3 + i;
        while (i < i4) {
            if (bArr[i] != bArr2[i2]) {
                return false;
            }
            i++;
            i2++;
        }
        return true;
    }

    public static void freeDirectBuffer(ByteBuffer byteBuffer) {
        if (!hasUnsafe() || isAndroid()) {
            return;
        }
        PlatformDependent0.freeDirectBuffer(byteBuffer);
    }

    public static void freeDirectNoCleaner(ByteBuffer byteBuffer) {
        int iCapacity = byteBuffer.capacity();
        PlatformDependent0.freeMemory(PlatformDependent0.directBufferAddress(byteBuffer));
        decrementMemoryCounter(iCapacity);
    }

    public static void freeMemory(long j) {
        PlatformDependent0.freeMemory(j);
    }

    public static byte getByte(long j) {
        return PlatformDependent0.getByte(j);
    }

    public static ClassLoader getClassLoader(Class<?> cls) {
        return PlatformDependent0.getClassLoader(cls);
    }

    public static ClassLoader getContextClassLoader() {
        return PlatformDependent0.getContextClassLoader();
    }

    public static int getInt(Object obj, long j) {
        return PlatformDependent0.getInt(obj, j);
    }

    private static int getIntSafe(byte[] bArr, int i) {
        int i2;
        int i3;
        if (BIG_ENDIAN_NATIVE_ORDER) {
            i2 = (bArr[i] << SDKKeyboardCode.FUNCTION_KEY_BOARD_U) | ((bArr[i + 1] & IMcuConstants.DEFAULT_VALUE) << 16) | ((bArr[i + 2] & IMcuConstants.DEFAULT_VALUE) << 8);
            i3 = bArr[i + 3] & IMcuConstants.DEFAULT_VALUE;
        } else {
            i2 = (bArr[i] & IMcuConstants.DEFAULT_VALUE) | ((bArr[i + 1] & IMcuConstants.DEFAULT_VALUE) << 8) | ((bArr[i + 2] & IMcuConstants.DEFAULT_VALUE) << 16);
            i3 = bArr[i + 3] << SDKKeyboardCode.FUNCTION_KEY_BOARD_U;
        }
        return i3 | i2;
    }

    public static long getLong(long j) {
        return PlatformDependent0.getLong(j);
    }

    private static long getLongSafe(byte[] bArr, int i) {
        if (BIG_ENDIAN_NATIVE_ORDER) {
            return (((long) bArr[i + 7]) & 255) | (((long) bArr[i]) << 56) | ((((long) bArr[i + 1]) & 255) << 48) | ((((long) bArr[i + 2]) & 255) << 40) | ((((long) bArr[i + 3]) & 255) << 32) | ((((long) bArr[i + 4]) & 255) << 24) | ((((long) bArr[i + 5]) & 255) << 16) | ((((long) bArr[i + 6]) & 255) << 8);
        }
        return ((((long) bArr[i + 7]) & 255) << 56) | ((((long) bArr[i + 2]) & 255) << 16) | (((long) bArr[i]) & 255) | ((((long) bArr[i + 1]) & 255) << 8) | ((((long) bArr[i + 3]) & 255) << 24) | ((((long) bArr[i + 4]) & 255) << 32) | ((((long) bArr[i + 5]) & 255) << 40) | ((((long) bArr[i + 6]) & 255) << 48);
    }

    public static Object getObject(Object obj, long j) {
        return PlatformDependent0.getObject(obj, j);
    }

    public static Object getObjectVolatile(Object obj, long j) {
        return PlatformDependent0.getObjectVolatile(obj, j);
    }

    public static short getShort(long j) {
        return PlatformDependent0.getShort(j);
    }

    private static short getShortSafe(byte[] bArr, int i) {
        int i2;
        int i3;
        if (BIG_ENDIAN_NATIVE_ORDER) {
            i2 = bArr[i] << 8;
            i3 = bArr[i + 1] & IMcuConstants.DEFAULT_VALUE;
        } else {
            i2 = bArr[i] & IMcuConstants.DEFAULT_VALUE;
            i3 = bArr[i + 1] << 8;
        }
        return (short) (i3 | i2);
    }

    public static ClassLoader getSystemClassLoader() {
        return PlatformDependent0.getSystemClassLoader();
    }

    public static boolean hasJavassist() {
        return HAS_JAVASSIST;
    }

    private static boolean hasJavassist0() {
        if (isAndroid()) {
            return false;
        }
        boolean z = SystemPropertyUtil.getBoolean("io.netty.noJavassist", false);
        InternalLogger internalLogger = logger;
        internalLogger.debug("-Dio.netty.noJavassist: {}", Boolean.valueOf(z));
        if (z) {
            internalLogger.debug("Javassist: unavailable (io.netty.noJavassist)");
            return false;
        }
        try {
            JavassistTypeParameterMatcherGenerator.generate(Object.class, getClassLoader(PlatformDependent.class));
            internalLogger.debug("Javassist: available");
            return true;
        } catch (Throwable unused) {
            InternalLogger internalLogger2 = logger;
            internalLogger2.debug("Javassist: unavailable");
            internalLogger2.debug("You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes.  Please check the configuration for better performance.");
            return false;
        }
    }

    public static boolean hasUnsafe() {
        return HAS_UNSAFE;
    }

    private static boolean hasUnsafe0() {
        boolean z = SystemPropertyUtil.getBoolean("io.netty.noUnsafe", false);
        InternalLogger internalLogger = logger;
        internalLogger.debug("-Dio.netty.noUnsafe: {}", Boolean.valueOf(z));
        if (isAndroid()) {
            internalLogger.debug("sun.misc.Unsafe: unavailable (Android)");
            return false;
        }
        if (z) {
            internalLogger.debug("sun.misc.Unsafe: unavailable (io.netty.noUnsafe)");
            return false;
        }
        if (!(SystemPropertyUtil.contains("io.netty.tryUnsafe") ? SystemPropertyUtil.getBoolean("io.netty.tryUnsafe", true) : SystemPropertyUtil.getBoolean("org.jboss.netty.tryUnsafe", true))) {
            internalLogger.debug("sun.misc.Unsafe: unavailable (io.netty.tryUnsafe/org.jboss.netty.tryUnsafe)");
            return false;
        }
        try {
            boolean zHasUnsafe = PlatformDependent0.hasUnsafe();
            internalLogger.debug("sun.misc.Unsafe: {}", zHasUnsafe ? "available" : "unavailable");
            return zHasUnsafe;
        } catch (Throwable unused) {
            return false;
        }
    }

    public static int hashCodeAscii(byte[] bArr, int i, int i2) {
        return (hasUnsafe() && PlatformDependent0.unalignedAccess()) ? PlatformDependent0.hashCodeAscii(bArr, i, i2) : hashCodeAsciiSafe(bArr, i, i2);
    }

    private static int hashCodeAsciiCompute(CharSequence charSequence, int i, int i2) {
        return (i2 * 461845907) + (hashCodeAsciiSanitizeInt(charSequence, i) * 461845907) + hashCodeAsciiSanitizeInt(charSequence, i + 4);
    }

    static int hashCodeAsciiSafe(byte[] bArr, int i, int i2) {
        int iHashCodeAsciiSanitize;
        int iHashCodeAsciiSanitize2;
        int i3 = i2 & 7;
        int i4 = i + i3;
        int iHashCodeAsciiCompute = -1028477387;
        for (int i5 = (i - 8) + i2; i5 >= i4; i5 -= 8) {
            iHashCodeAsciiCompute = PlatformDependent0.hashCodeAsciiCompute(getLongSafe(bArr, i5), iHashCodeAsciiCompute);
        }
        switch (i3) {
            case 1:
                iHashCodeAsciiSanitize = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(bArr[i]);
                break;
            case 2:
                iHashCodeAsciiSanitize = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getShortSafe(bArr, i));
                break;
            case 3:
                iHashCodeAsciiSanitize = ((iHashCodeAsciiCompute * 461845907) + PlatformDependent0.hashCodeAsciiSanitize(bArr[i])) * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getShortSafe(bArr, i + 1));
                break;
            case 4:
                iHashCodeAsciiSanitize = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getIntSafe(bArr, i));
                break;
            case 5:
                iHashCodeAsciiSanitize = ((iHashCodeAsciiCompute * 461845907) + PlatformDependent0.hashCodeAsciiSanitize(bArr[i])) * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getIntSafe(bArr, i + 1));
                break;
            case 6:
                iHashCodeAsciiSanitize = ((iHashCodeAsciiCompute * 461845907) + PlatformDependent0.hashCodeAsciiSanitize(getShortSafe(bArr, i))) * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getIntSafe(bArr, i + 2));
                break;
            case 7:
                iHashCodeAsciiSanitize = ((((iHashCodeAsciiCompute * 461845907) + PlatformDependent0.hashCodeAsciiSanitize(bArr[i])) * 461845907) + PlatformDependent0.hashCodeAsciiSanitize(getShortSafe(bArr, i + 1))) * 461845907;
                iHashCodeAsciiSanitize2 = PlatformDependent0.hashCodeAsciiSanitize(getIntSafe(bArr, i + 3));
                break;
            default:
                return iHashCodeAsciiCompute;
        }
        return iHashCodeAsciiSanitize + iHashCodeAsciiSanitize2;
    }

    private static int hashCodeAsciiSanitizeInt(CharSequence charSequence, int i) {
        int iCharAt;
        int iCharAt2;
        if (BIG_ENDIAN_NATIVE_ORDER) {
            iCharAt = (charSequence.charAt(i) & 31) | ((charSequence.charAt(i + 2) & 31) << 8) | ((charSequence.charAt(i + 1) & 31) << 16);
            iCharAt2 = (charSequence.charAt(i) & 31) << 24;
        } else {
            iCharAt = ((charSequence.charAt(i + 3) & 31) << 24) | ((charSequence.charAt(i + 2) & 31) << 16) | ((charSequence.charAt(i + 1) & 31) << 8);
            iCharAt2 = charSequence.charAt(i) & 31;
        }
        return iCharAt2 | iCharAt;
    }

    private static int hashCodeAsciiSanitizeShort(CharSequence charSequence, int i) {
        int iCharAt;
        int iCharAt2;
        if (BIG_ENDIAN_NATIVE_ORDER) {
            iCharAt = charSequence.charAt(i + 1) & 31;
            iCharAt2 = (charSequence.charAt(i) & 31) << 8;
        } else {
            iCharAt = (charSequence.charAt(i + 1) & 31) << 8;
            iCharAt2 = charSequence.charAt(i) & 31;
        }
        return iCharAt2 | iCharAt;
    }

    private static int hashCodeAsciiSanitizsByte(char c2) {
        return c2 & 31;
    }

    private static void incrementMemoryCounter(int i) {
        AtomicLong atomicLong;
        long j;
        long j2;
        if (DIRECT_MEMORY_COUNTER != null) {
            do {
                atomicLong = DIRECT_MEMORY_COUNTER;
                j = atomicLong.get();
                j2 = ((long) i) + j;
                long j3 = DIRECT_MEMORY_LIMIT;
                if (j2 > j3) {
                    throw new OutOfDirectMemoryError("failed to allocate " + i + " byte(s) of direct memory (used: " + j + ", max: " + j3 + ')');
                }
            } while (!atomicLong.compareAndSet(j, j2));
        }
    }

    public static boolean isAndroid() {
        return IS_ANDROID;
    }

    private static boolean isAndroid0() {
        boolean z = false;
        try {
            Class.forName("android.app.Application", false, getSystemClassLoader());
            z = true;
        } catch (Throwable unused) {
        }
        if (z) {
            logger.debug("Platform: Android");
        }
        return z;
    }

    public static boolean isRoot() {
        if (IS_ROOT == null) {
            synchronized (PlatformDependent.class) {
                if (IS_ROOT == null) {
                    IS_ROOT = Boolean.valueOf(isRoot0());
                }
            }
        }
        return IS_ROOT.booleanValue();
    }

    /* JADX WARN: Can't wrap try/catch for region: R(6:8|(4:93|9|89|10)|(6:95|11|(3:83|12|103)|(1:15)|74|16)|91|17|(2:102|30)(3:100|28|29)) */
    /* JADX WARN: Removed duplicated region for block: B:78:0x00e6 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private static boolean isRoot0() throws java.lang.Throwable {
        /*
            Method dump skipped, instruction units count: 242
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: io.netty.util.internal.PlatformDependent.isRoot0():boolean");
    }

    public static boolean isUnaligned() {
        return PlatformDependent0.isUnaligned();
    }

    public static boolean isWindows() {
        return IS_WINDOWS;
    }

    private static boolean isWindows0() {
        boolean zContains = SystemPropertyUtil.get("os.name", "").toLowerCase(Locale.US).contains("win");
        if (zContains) {
            logger.debug("Platform: Windows");
        }
        return zContains;
    }

    public static int javaVersion() {
        return JAVA_VERSION;
    }

    private static int javaVersion0() {
        int iIntValue = 6;
        if (!isAndroid()) {
            try {
                try {
                    try {
                        Object objInvoke = Runtime.class.getMethod("version", new Class[0]).invoke(null, new Object[0]);
                        iIntValue = ((Integer) objInvoke.getClass().getMethod("major", new Class[0]).invoke(objInvoke, new Object[0])).intValue();
                    } catch (Throwable unused) {
                        Class.forName("java.util.concurrent.LinkedTransferQueue", false, getClassLoader(BlockingQueue.class));
                        iIntValue = 7;
                    }
                } catch (Throwable unused2) {
                    Class.forName("java.time.Clock", false, getClassLoader(Object.class));
                    iIntValue = 8;
                }
            } catch (Throwable unused3) {
            }
        }
        InternalLogger internalLogger = logger;
        if (internalLogger.isDebugEnabled()) {
            internalLogger.debug("Java version: {}", Integer.valueOf(iIntValue));
        }
        return iIntValue;
    }

    public static long maxDirectMemory() {
        return MAX_DIRECT_MEMORY;
    }

    /* JADX WARN: Code restructure failed: missing block: B:14:0x0078, code lost:
    
        r5 = java.lang.Long.parseLong(r8.group(1));
        r0 = r8.group(2).charAt(0);
     */
    /* JADX WARN: Code restructure failed: missing block: B:16:0x008b, code lost:
    
        if (r0 == 'G') goto L30;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x008f, code lost:
    
        if (r0 == 'K') goto L29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:20:0x0093, code lost:
    
        if (r0 == 'M') goto L28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x0097, code lost:
    
        if (r0 == 'g') goto L30;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x009b, code lost:
    
        if (r0 == 'k') goto L29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x009f, code lost:
    
        if (r0 == 'm') goto L28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x00a2, code lost:
    
        r3 = 1048576;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x00a6, code lost:
    
        r3 = 1024;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x00a9, code lost:
    
        r3 = 1073741824;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x00ac, code lost:
    
        r5 = r5 * r3;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private static long maxDirectMemory0() {
        /*
            Method dump skipped, instruction units count: 209
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: io.netty.util.internal.PlatformDependent.maxDirectMemory0():long");
    }

    public static <T> AtomicIntegerFieldUpdater<T> newAtomicIntegerFieldUpdater(Class<? super T> cls, String str) {
        if (!hasUnsafe()) {
            return null;
        }
        try {
            return PlatformDependent0.newAtomicIntegerFieldUpdater(cls, str);
        } catch (Throwable unused) {
            return null;
        }
    }

    public static <T> AtomicLongFieldUpdater<T> newAtomicLongFieldUpdater(Class<? super T> cls, String str) {
        if (!hasUnsafe()) {
            return null;
        }
        try {
            return PlatformDependent0.newAtomicLongFieldUpdater(cls, str);
        } catch (Throwable unused) {
            return null;
        }
    }

    public static <U, W> AtomicReferenceFieldUpdater<U, W> newAtomicReferenceFieldUpdater(Class<? super U> cls, String str) {
        if (!hasUnsafe()) {
            return null;
        }
        try {
            return PlatformDependent0.newAtomicReferenceFieldUpdater(cls, str);
        } catch (Throwable unused) {
            return null;
        }
    }

    public static <C> Deque<C> newConcurrentDeque() {
        return javaVersion() < 7 ? new LinkedBlockingDeque() : new ConcurrentLinkedDeque();
    }

    public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap() {
        return CAN_USE_CHM_V8 ? new ConcurrentHashMapV8() : new ConcurrentHashMap();
    }

    public static <T> Queue<T> newFixedMpscQueue(int i) {
        return hasUnsafe() ? new MpscArrayQueue(i) : new MpscAtomicArrayQueue(i);
    }

    public static LongCounter newLongCounter() {
        return HAS_UNSAFE ? new LongAdderV8() : new AtomicLongCounter();
    }

    public static <T> Queue<T> newMpscQueue() {
        return newMpscQueue(DEFAULT_MAX_MPSC_CAPACITY);
    }

    public static <T> Queue<T> newSpscQueue() {
        return hasUnsafe() ? new SpscLinkedQueue() : new SpscLinkedAtomicQueue();
    }

    public static long objectFieldOffset(Field field) {
        return PlatformDependent0.objectFieldOffset(field);
    }

    public static void putByte(long j, byte b2) {
        PlatformDependent0.putByte(j, b2);
    }

    public static void putInt(long j, int i) {
        PlatformDependent0.putInt(j, i);
    }

    public static void putLong(long j, long j2) {
        PlatformDependent0.putLong(j, j2);
    }

    public static void putOrderedObject(Object obj, long j, Object obj2) {
        PlatformDependent0.putOrderedObject(obj, j, obj2);
    }

    public static void putShort(long j, short s) {
        PlatformDependent0.putShort(j, s);
    }

    public static ByteBuffer reallocateDirectNoCleaner(ByteBuffer byteBuffer, int i) throws Throwable {
        int iCapacity = i - byteBuffer.capacity();
        incrementMemoryCounter(iCapacity);
        try {
            return PlatformDependent0.reallocateDirectNoCleaner(byteBuffer, i);
        } catch (Throwable th) {
            decrementMemoryCounter(iCapacity);
            throwException(th);
            return null;
        }
    }

    public static void setMemory(byte[] bArr, int i, long j, byte b2) {
        PlatformDependent0.setMemory(bArr, BYTE_ARRAY_BASE_OFFSET + ((long) i), j, b2);
    }

    public static void throwException(Throwable th) throws Throwable {
        if (hasUnsafe()) {
            PlatformDependent0.throwException(th);
        } else {
            throwException0(th);
        }
    }

    private static <E extends Throwable> void throwException0(Throwable th) throws Throwable {
        throw th;
    }

    public static File tmpdir() {
        return TMPDIR;
    }

    private static File tmpdir0() {
        File directory;
        try {
            directory = toDirectory(SystemPropertyUtil.get("io.netty.tmpdir"));
        } catch (Throwable unused) {
        }
        if (directory != null) {
            logger.debug("-Dio.netty.tmpdir: {}", directory);
            return directory;
        }
        File directory2 = toDirectory(SystemPropertyUtil.get("java.io.tmpdir"));
        if (directory2 != null) {
            logger.debug("-Dio.netty.tmpdir: {} (java.io.tmpdir)", directory2);
            return directory2;
        }
        if (isWindows()) {
            File directory3 = toDirectory(System.getenv("TEMP"));
            if (directory3 != null) {
                logger.debug("-Dio.netty.tmpdir: {} (%TEMP%)", directory3);
                return directory3;
            }
            String str = System.getenv("USERPROFILE");
            if (str != null) {
                File directory4 = toDirectory(str + "\\AppData\\Local\\Temp");
                if (directory4 != null) {
                    logger.debug("-Dio.netty.tmpdir: {} (%USERPROFILE%\\AppData\\Local\\Temp)", directory4);
                    return directory4;
                }
                File directory5 = toDirectory(str + "\\Local Settings\\Temp");
                if (directory5 != null) {
                    logger.debug("-Dio.netty.tmpdir: {} (%USERPROFILE%\\Local Settings\\Temp)", directory5);
                    return directory5;
                }
            }
        } else {
            File directory6 = toDirectory(System.getenv("TMPDIR"));
            if (directory6 != null) {
                logger.debug("-Dio.netty.tmpdir: {} ($TMPDIR)", directory6);
                return directory6;
            }
        }
        File file = isWindows() ? new File("C:\\Windows\\Temp") : new File("/tmp");
        logger.warn("Failed to get the temporary directory; falling back to: {}", file);
        return file;
    }

    private static File toDirectory(String str) {
        if (str == null) {
            return null;
        }
        File file = new File(str);
        file.mkdirs();
        if (!file.isDirectory()) {
            return null;
        }
        try {
            return file.getAbsoluteFile();
        } catch (Exception unused) {
            return file;
        }
    }

    public static boolean useDirectBufferNoCleaner() {
        return USE_DIRECT_BUFFER_NO_CLEANER;
    }

    public static void copyMemory(byte[] bArr, int i, long j, long j2) {
        PlatformDependent0.copyMemory(bArr, BYTE_ARRAY_BASE_OFFSET + ((long) i), null, j, j2);
    }

    public static byte getByte(byte[] bArr, int i) {
        return PlatformDependent0.getByte(bArr, i);
    }

    public static int getInt(long j) {
        return PlatformDependent0.getInt(j);
    }

    public static long getLong(byte[] bArr, int i) {
        return PlatformDependent0.getLong(bArr, i);
    }

    public static short getShort(byte[] bArr, int i) {
        return PlatformDependent0.getShort(bArr, i);
    }

    public static int hashCodeAscii(CharSequence charSequence) {
        int iHashCodeAsciiSanitizsByte;
        int iHashCodeAsciiSanitizsByte2;
        int length = charSequence.length() & 7;
        int iHashCodeAsciiCompute = -1028477387;
        switch (charSequence.length()) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                break;
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
                iHashCodeAsciiCompute = hashCodeAsciiCompute(charSequence, charSequence.length() - 8, -1028477387);
                break;
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
                iHashCodeAsciiCompute = hashCodeAsciiCompute(charSequence, charSequence.length() - 16, hashCodeAsciiCompute(charSequence, charSequence.length() - 8, -1028477387));
                break;
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
                iHashCodeAsciiCompute = hashCodeAsciiCompute(charSequence, charSequence.length() - 24, hashCodeAsciiCompute(charSequence, charSequence.length() - 16, hashCodeAsciiCompute(charSequence, charSequence.length() - 8, -1028477387)));
                break;
            default:
                for (int length2 = charSequence.length() - 8; length2 >= length; length2 -= 8) {
                    iHashCodeAsciiCompute = hashCodeAsciiCompute(charSequence, length2, iHashCodeAsciiCompute);
                }
                break;
        }
        switch (length) {
            case 1:
                iHashCodeAsciiSanitizsByte = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizsByte(charSequence.charAt(0));
                break;
            case 2:
                iHashCodeAsciiSanitizsByte = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeShort(charSequence, 0);
                break;
            case 3:
                iHashCodeAsciiSanitizsByte = ((iHashCodeAsciiCompute * 461845907) + hashCodeAsciiSanitizsByte(charSequence.charAt(0))) * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeShort(charSequence, 1);
                break;
            case 4:
                iHashCodeAsciiSanitizsByte = iHashCodeAsciiCompute * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeInt(charSequence, 0);
                break;
            case 5:
                iHashCodeAsciiSanitizsByte = ((iHashCodeAsciiCompute * 461845907) + hashCodeAsciiSanitizsByte(charSequence.charAt(0))) * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeInt(charSequence, 1);
                break;
            case 6:
                iHashCodeAsciiSanitizsByte = ((iHashCodeAsciiCompute * 461845907) + hashCodeAsciiSanitizeShort(charSequence, 0)) * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeInt(charSequence, 2);
                break;
            case 7:
                iHashCodeAsciiSanitizsByte = ((((iHashCodeAsciiCompute * 461845907) + hashCodeAsciiSanitizsByte(charSequence.charAt(0))) * 461845907) + hashCodeAsciiSanitizeShort(charSequence, 1)) * 461845907;
                iHashCodeAsciiSanitizsByte2 = hashCodeAsciiSanitizeInt(charSequence, 3);
                break;
            default:
                return iHashCodeAsciiCompute;
        }
        return iHashCodeAsciiSanitizsByte + iHashCodeAsciiSanitizsByte2;
    }

    public static <T> Queue<T> newMpscQueue(int i) {
        return hasUnsafe() ? new MpscChunkedArrayQueue(1024, Math.max(Math.min(i, 1073741824), 2048), true) : new MpscLinkedAtomicQueue();
    }

    public static void putByte(byte[] bArr, int i, byte b2) {
        PlatformDependent0.putByte(bArr, i, b2);
    }

    public static void putInt(byte[] bArr, int i, int i2) {
        PlatformDependent0.putInt(bArr, i, i2);
    }

    public static void putLong(byte[] bArr, int i, long j) {
        PlatformDependent0.putLong(bArr, i, j);
    }

    public static void putShort(byte[] bArr, int i, short s) {
        PlatformDependent0.putShort(bArr, i, s);
    }

    public static void setMemory(long j, long j2, byte b2) {
        PlatformDependent0.setMemory(j, j2, b2);
    }

    public static void copyMemory(long j, byte[] bArr, int i, long j2) {
        PlatformDependent0.copyMemory(null, j, bArr, BYTE_ARRAY_BASE_OFFSET + ((long) i), j2);
    }

    public static int getInt(byte[] bArr, int i) {
        return PlatformDependent0.getInt(bArr, i);
    }

    public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap(int i) {
        if (CAN_USE_CHM_V8) {
            return new ConcurrentHashMapV8(i);
        }
        return new ConcurrentHashMap(i);
    }

    public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap(int i, float f2) {
        if (CAN_USE_CHM_V8) {
            return new ConcurrentHashMapV8(i, f2);
        }
        return new ConcurrentHashMap(i, f2);
    }

    public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap(int i, float f2, int i2) {
        if (CAN_USE_CHM_V8) {
            return new ConcurrentHashMapV8(i, f2, i2);
        }
        return new ConcurrentHashMap(i, f2, i2);
    }

    public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap(Map<? extends K, ? extends V> map) {
        if (CAN_USE_CHM_V8) {
            return new ConcurrentHashMapV8(map);
        }
        return new ConcurrentHashMap(map);
    }
}
