package okhttp3.internal;

import c.h;
import c.l.f;
import c.l.k;
import c.l.r;
import c.l.w;
import c.q.c.a;
import c.q.d.j;
import c.q.d.t;
import c.r.g;
import c.u.c;
import c.u.e;
import c.u.o;
import d.a0;
import d.i;
import d.q;
import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http2.Header;

/* JADX INFO: compiled from: Util.kt */
/* JADX INFO: loaded from: classes.dex */
public final class Util {
    public static final TimeZone UTC;
    private static final e VERIFY_AS_IP_ADDRESS;
    public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
    public static final Headers EMPTY_HEADERS = Headers.Companion.of(new String[0]);
    public static final ResponseBody EMPTY_RESPONSE = ResponseBody.Companion.create$default(ResponseBody.Companion, EMPTY_BYTE_ARRAY, (MediaType) null, 1, (Object) null);
    public static final RequestBody EMPTY_REQUEST = RequestBody.Companion.create$default(RequestBody.Companion, EMPTY_BYTE_ARRAY, (MediaType) null, 0, 0, 7, (Object) null);
    private static final q UNICODE_BOMS = q.f1589d.d(i.f1573f.b("efbbbf"), i.f1573f.b("feff"), i.f1573f.b("fffe"), i.f1573f.b("0000ffff"), i.f1573f.b("ffff0000"));

    /* JADX INFO: renamed from: okhttp3.internal.Util$execute$1, reason: invalid class name and case insensitive filesystem */
    /* JADX INFO: compiled from: Util.kt */
    public static final class RunnableC00411 implements Runnable {
        final /* synthetic */ a $block;
        final /* synthetic */ String $name;

        public RunnableC00411(String str, a aVar) {
            this.$name = str;
            this.$block = aVar;
        }

        @Override // java.lang.Runnable
        public final void run() {
            String str = this.$name;
            Thread threadCurrentThread = Thread.currentThread();
            j.b(threadCurrentThread, "currentThread");
            String name = threadCurrentThread.getName();
            threadCurrentThread.setName(str);
            try {
                this.$block.invoke();
            } finally {
                threadCurrentThread.setName(name);
            }
        }
    }

    static {
        TimeZone timeZone = TimeZone.getTimeZone("GMT");
        if (timeZone == null) {
            j.g();
            throw null;
        }
        UTC = timeZone;
        VERIFY_AS_IP_ADDRESS = new e("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
    }

    public static final int and(byte b2, int i) {
        return b2 & i;
    }

    public static final int and(short s, int i) {
        return s & i;
    }

    public static final long and(int i, long j) {
        return ((long) i) & j;
    }

    public static final EventListener.Factory asFactory(final EventListener eventListener) {
        j.c(eventListener, "$this$asFactory");
        return new EventListener.Factory() { // from class: okhttp3.internal.Util.asFactory.1
            @Override // okhttp3.EventListener.Factory
            public EventListener create(Call call) {
                j.c(call, "call");
                return eventListener;
            }
        };
    }

    public static final boolean canParseAsIpAddress(String str) {
        j.c(str, "$this$canParseAsIpAddress");
        return VERIFY_AS_IP_ADDRESS.a(str);
    }

    public static final boolean canReuseConnectionFor(HttpUrl httpUrl, HttpUrl httpUrl2) {
        j.c(httpUrl, "$this$canReuseConnectionFor");
        j.c(httpUrl2, "other");
        return j.a(httpUrl.host(), httpUrl2.host()) && httpUrl.port() == httpUrl2.port() && j.a(httpUrl.scheme(), httpUrl2.scheme());
    }

    public static final int checkDuration(String str, long j, TimeUnit timeUnit) {
        j.c(str, "name");
        boolean z = true;
        if (!(j >= 0)) {
            throw new IllegalStateException((str + " < 0").toString());
        }
        if (!(timeUnit != null)) {
            throw new IllegalStateException("unit == null".toString());
        }
        long millis = timeUnit.toMillis(j);
        if (!(millis <= ((long) Integer.MAX_VALUE))) {
            throw new IllegalArgumentException((str + " too large.").toString());
        }
        if (millis == 0 && j > 0) {
            z = false;
        }
        if (z) {
            return (int) millis;
        }
        throw new IllegalArgumentException((str + " too small.").toString());
    }

    public static final void checkOffsetAndCount(long j, long j2, long j3) {
        if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
            throw new ArrayIndexOutOfBoundsException();
        }
    }

    public static final void closeQuietly(Closeable closeable) {
        j.c(closeable, "$this$closeQuietly");
        try {
            closeable.close();
        } catch (RuntimeException e2) {
            throw e2;
        } catch (Exception unused) {
        }
    }

    public static final String[] concat(String[] strArr, String str) {
        j.c(strArr, "$this$concat");
        j.c(str, "value");
        Object[] objArrCopyOf = Arrays.copyOf(strArr, strArr.length + 1);
        j.b(objArrCopyOf, "java.util.Arrays.copyOf(this, newSize)");
        String[] strArr2 = (String[]) objArrCopyOf;
        strArr2[f.g(strArr2)] = str;
        if (strArr2 != null) {
            return strArr2;
        }
        throw new h("null cannot be cast to non-null type kotlin.Array<kotlin.String>");
    }

    public static final String connectionName(Socket socket) {
        j.c(socket, "$this$connectionName");
        SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
        if (!(remoteSocketAddress instanceof InetSocketAddress)) {
            return remoteSocketAddress.toString();
        }
        String hostName = ((InetSocketAddress) remoteSocketAddress).getHostName();
        j.b(hostName, "address.hostName");
        return hostName;
    }

    public static final int delimiterOffset(String str, String str2, int i, int i2) {
        j.c(str, "$this$delimiterOffset");
        j.c(str2, "delimiters");
        while (i < i2) {
            if (o.x(str2, str.charAt(i), false, 2, null)) {
                return i;
            }
            i++;
        }
        return i2;
    }

    public static /* synthetic */ int delimiterOffset$default(String str, String str2, int i, int i2, int i3, Object obj) {
        if ((i3 & 2) != 0) {
            i = 0;
        }
        if ((i3 & 4) != 0) {
            i2 = str.length();
        }
        return delimiterOffset(str, str2, i, i2);
    }

    public static final boolean discard(a0 a0Var, int i, TimeUnit timeUnit) {
        j.c(a0Var, "$this$discard");
        j.c(timeUnit, "timeUnit");
        try {
            return skipAll(a0Var, i, timeUnit);
        } catch (IOException unused) {
            return false;
        }
    }

    public static final void execute(Executor executor, String str, a<c.j> aVar) {
        j.c(executor, "$this$execute");
        j.c(str, "name");
        j.c(aVar, "block");
        executor.execute(new RunnableC00411(str, aVar));
    }

    public static final String format(String str, Object... objArr) {
        j.c(str, "format");
        j.c(objArr, "args");
        t tVar = t.f1451a;
        Locale locale = Locale.US;
        j.b(locale, "Locale.US");
        Object[] objArrCopyOf = Arrays.copyOf(objArr, objArr.length);
        String str2 = String.format(locale, str, Arrays.copyOf(objArrCopyOf, objArrCopyOf.length));
        j.b(str2, "java.lang.String.format(locale, format, *args)");
        return str2;
    }

    public static final boolean hasIntersection(String[] strArr, String[] strArr2, Comparator<? super String> comparator) {
        j.c(strArr, "$this$hasIntersection");
        j.c(comparator, "comparator");
        if (!(strArr.length == 0) && strArr2 != null) {
            if (!(strArr2.length == 0)) {
                for (String str : strArr) {
                    for (String str2 : strArr2) {
                        if (comparator.compare(str, str2) == 0) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    public static final long headersContentLength(Response response) {
        j.c(response, "$this$headersContentLength");
        String str = response.headers().get("Content-Length");
        if (str != null) {
            return toLongOrDefault(str, -1L);
        }
        return -1L;
    }

    public static final void ignoreIoExceptions(a<c.j> aVar) {
        j.c(aVar, "block");
        try {
            aVar.invoke();
        } catch (IOException unused) {
        }
    }

    @SafeVarargs
    public static final <T> List<T> immutableListOf(T... tArr) {
        j.c(tArr, "elements");
        Object[] objArr = (Object[]) tArr.clone();
        List<T> listUnmodifiableList = Collections.unmodifiableList(Arrays.asList(Arrays.copyOf(objArr, objArr.length)));
        j.b(listUnmodifiableList, "Collections.unmodifiable…sList(*elements.clone()))");
        return listUnmodifiableList;
    }

    public static final int indexOf(String[] strArr, String str, Comparator<String> comparator) {
        j.c(strArr, "$this$indexOf");
        j.c(str, "value");
        j.c(comparator, "comparator");
        int length = strArr.length;
        for (int i = 0; i < length; i++) {
            if (comparator.compare(strArr[i], str) == 0) {
                return i;
            }
        }
        return -1;
    }

    public static final int indexOfControlOrNonAscii(String str) {
        j.c(str, "$this$indexOfControlOrNonAscii");
        int length = str.length();
        for (int i = 0; i < length; i++) {
            char cCharAt = str.charAt(i);
            if (cCharAt <= 31 || cCharAt >= 127) {
                return i;
            }
        }
        return -1;
    }

    public static final int indexOfFirstNonAsciiWhitespace(String str, int i, int i2) {
        j.c(str, "$this$indexOfFirstNonAsciiWhitespace");
        while (i < i2) {
            char cCharAt = str.charAt(i);
            if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\f' && cCharAt != '\r' && cCharAt != ' ') {
                return i;
            }
            i++;
        }
        return i2;
    }

    public static /* synthetic */ int indexOfFirstNonAsciiWhitespace$default(String str, int i, int i2, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            i = 0;
        }
        if ((i3 & 2) != 0) {
            i2 = str.length();
        }
        return indexOfFirstNonAsciiWhitespace(str, i, i2);
    }

    public static final int indexOfLastNonAsciiWhitespace(String str, int i, int i2) {
        j.c(str, "$this$indexOfLastNonAsciiWhitespace");
        int i3 = i2 - 1;
        if (i3 >= i) {
            while (true) {
                char cCharAt = str.charAt(i3);
                if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\f' && cCharAt != '\r' && cCharAt != ' ') {
                    return i3 + 1;
                }
                if (i3 == i) {
                    break;
                }
                i3--;
            }
        }
        return i;
    }

    public static /* synthetic */ int indexOfLastNonAsciiWhitespace$default(String str, int i, int i2, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            i = 0;
        }
        if ((i3 & 2) != 0) {
            i2 = str.length();
        }
        return indexOfLastNonAsciiWhitespace(str, i, i2);
    }

    public static final int indexOfNonWhitespace(String str, int i) {
        j.c(str, "$this$indexOfNonWhitespace");
        int length = str.length();
        while (i < length) {
            char cCharAt = str.charAt(i);
            if (cCharAt != ' ' && cCharAt != '\t') {
                return i;
            }
            i++;
        }
        return str.length();
    }

    public static /* synthetic */ int indexOfNonWhitespace$default(String str, int i, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            i = 0;
        }
        return indexOfNonWhitespace(str, i);
    }

    public static final String[] intersect(String[] strArr, String[] strArr2, Comparator<? super String> comparator) {
        j.c(strArr, "$this$intersect");
        j.c(strArr2, "other");
        j.c(comparator, "comparator");
        ArrayList arrayList = new ArrayList();
        for (String str : strArr) {
            int length = strArr2.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                }
                if (comparator.compare(str, strArr2[i]) == 0) {
                    arrayList.add(str);
                    break;
                }
                i++;
            }
        }
        Object[] array = arrayList.toArray(new String[0]);
        if (array != null) {
            return (String[]) array;
        }
        throw new h("null cannot be cast to non-null type kotlin.Array<T>");
    }

    public static final void lockAndWaitNanos(Object obj, long j) throws InterruptedException {
        j.c(obj, "$this$lockAndWaitNanos");
        long j2 = j / 1000000;
        long j3 = j - (1000000 * j2);
        synchronized (obj) {
            waitMillis(obj, j2, (int) j3);
            c.j jVar = c.j.f1417a;
        }
    }

    public static final void notify(Object obj) {
        j.c(obj, "$this$notify");
        obj.notify();
    }

    public static final void notifyAll(Object obj) {
        j.c(obj, "$this$notifyAll");
        obj.notifyAll();
    }

    public static final int parseHexDigit(char c2) {
        if ('0' <= c2 && '9' >= c2) {
            return c2 - '0';
        }
        char c3 = 'a';
        if ('a' > c2 || 'f' < c2) {
            c3 = 'A';
            if ('A' > c2 || 'F' < c2) {
                return -1;
            }
        }
        return (c2 - c3) + 10;
    }

    public static final Charset readBomAsCharset(d.h hVar, Charset charset) throws IOException {
        j.c(hVar, "$this$readBomAsCharset");
        j.c(charset, "default");
        int iE = hVar.E(UNICODE_BOMS);
        if (iE == -1) {
            return charset;
        }
        if (iE == 0) {
            Charset charset2 = StandardCharsets.UTF_8;
            j.b(charset2, "UTF_8");
            return charset2;
        }
        if (iE == 1) {
            Charset charset3 = StandardCharsets.UTF_16BE;
            j.b(charset3, "UTF_16BE");
            return charset3;
        }
        if (iE == 2) {
            Charset charset4 = StandardCharsets.UTF_16LE;
            j.b(charset4, "UTF_16LE");
            return charset4;
        }
        if (iE == 3) {
            return c.f1473d.a();
        }
        if (iE == 4) {
            return c.f1473d.b();
        }
        throw new AssertionError();
    }

    public static final int readMedium(d.h hVar) throws IOException {
        j.c(hVar, "$this$readMedium");
        return and(hVar.readByte(), 255) | (and(hVar.readByte(), 255) << 16) | (and(hVar.readByte(), 255) << 8);
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x005b A[PHI: r12
      0x005b: PHI (r12v6 boolean) = (r12v5 boolean), (r12v10 boolean) binds: [B:23:0x007d, B:13:0x0051] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final boolean skipAll(d.a0 r11, int r12, java.util.concurrent.TimeUnit r13) throws java.io.IOException {
        /*
            java.lang.String r0 = "$this$skipAll"
            c.q.d.j.c(r11, r0)
            java.lang.String r0 = "timeUnit"
            c.q.d.j.c(r13, r0)
            long r0 = java.lang.System.nanoTime()
            d.b0 r2 = r11.timeout()
            boolean r2 = r2.hasDeadline()
            r3 = 9223372036854775807(0x7fffffffffffffff, double:NaN)
            if (r2 == 0) goto L27
            d.b0 r2 = r11.timeout()
            long r5 = r2.deadlineNanoTime()
            long r5 = r5 - r0
            goto L28
        L27:
            r5 = r3
        L28:
            d.b0 r2 = r11.timeout()
            long r7 = (long) r12
            long r12 = r13.toNanos(r7)
            long r12 = java.lang.Math.min(r5, r12)
            long r12 = r12 + r0
            r2.deadlineNanoTime(r12)
            d.f r12 = new d.f     // Catch: java.lang.Throwable -> L64 java.io.InterruptedIOException -> L7a
            r12.<init>()     // Catch: java.lang.Throwable -> L64 java.io.InterruptedIOException -> L7a
        L3e:
            r7 = 8192(0x2000, double:4.0474E-320)
            long r7 = r11.read(r12, r7)     // Catch: java.lang.Throwable -> L64 java.io.InterruptedIOException -> L7a
            r9 = -1
            int r13 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
            if (r13 == 0) goto L4e
            r12.clear()     // Catch: java.lang.Throwable -> L64 java.io.InterruptedIOException -> L7a
            goto L3e
        L4e:
            r12 = 1
            int r13 = (r5 > r3 ? 1 : (r5 == r3 ? 0 : -1))
            if (r13 != 0) goto L5b
        L53:
            d.b0 r11 = r11.timeout()
            r11.clearDeadline()
            goto L80
        L5b:
            d.b0 r11 = r11.timeout()
            long r0 = r0 + r5
            r11.deadlineNanoTime(r0)
            goto L80
        L64:
            r12 = move-exception
            int r13 = (r5 > r3 ? 1 : (r5 == r3 ? 0 : -1))
            if (r13 != 0) goto L71
            d.b0 r11 = r11.timeout()
            r11.clearDeadline()
            goto L79
        L71:
            d.b0 r11 = r11.timeout()
            long r0 = r0 + r5
            r11.deadlineNanoTime(r0)
        L79:
            throw r12
        L7a:
            r12 = 0
            int r13 = (r5 > r3 ? 1 : (r5 == r3 ? 0 : -1))
            if (r13 != 0) goto L5b
            goto L53
        L80:
            return r12
        */
        throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.Util.skipAll(d.a0, int, java.util.concurrent.TimeUnit):boolean");
    }

    public static final ThreadFactory threadFactory(final String str, final boolean z) {
        j.c(str, "name");
        return new ThreadFactory() { // from class: okhttp3.internal.Util.threadFactory.1
            @Override // java.util.concurrent.ThreadFactory
            public final Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable, str);
                thread.setDaemon(z);
                return thread;
            }
        };
    }

    public static final void threadName(String str, a<c.j> aVar) {
        j.c(str, "name");
        j.c(aVar, "block");
        Thread threadCurrentThread = Thread.currentThread();
        j.b(threadCurrentThread, "currentThread");
        String name = threadCurrentThread.getName();
        threadCurrentThread.setName(str);
        try {
            aVar.invoke();
        } finally {
            c.q.d.i.b(1);
            threadCurrentThread.setName(name);
            c.q.d.i.a(1);
        }
    }

    public static final List<Header> toHeaderList(Headers headers) {
        j.c(headers, "$this$toHeaderList");
        c.r.c cVarG = g.g(0, headers.size());
        ArrayList arrayList = new ArrayList(k.m(cVarG, 10));
        Iterator<Integer> it = cVarG.iterator();
        while (it.hasNext()) {
            int iB = ((w) it).b();
            arrayList.add(new Header(headers.name(iB), headers.value(iB)));
        }
        return arrayList;
    }

    public static final Headers toHeaders(List<Header> list) {
        j.c(list, "$this$toHeaders");
        Headers.Builder builder = new Headers.Builder();
        for (Header header : list) {
            builder.addLenient$okhttp(header.component1().v(), header.component2().v());
        }
        return builder.build();
    }

    public static final String toHexString(long j) {
        String hexString = Long.toHexString(j);
        j.b(hexString, "java.lang.Long.toHexString(this)");
        return hexString;
    }

    public static final String toHostHeader(HttpUrl httpUrl, boolean z) {
        String strHost;
        j.c(httpUrl, "$this$toHostHeader");
        if (o.y(httpUrl.host(), ":", false, 2, null)) {
            strHost = '[' + httpUrl.host() + ']';
        } else {
            strHost = httpUrl.host();
        }
        if (!z && httpUrl.port() == HttpUrl.Companion.defaultPort(httpUrl.scheme())) {
            return strHost;
        }
        return strHost + ':' + httpUrl.port();
    }

    public static /* synthetic */ String toHostHeader$default(HttpUrl httpUrl, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        return toHostHeader(httpUrl, z);
    }

    public static final <T> List<T> toImmutableList(List<? extends T> list) {
        j.c(list, "$this$toImmutableList");
        List<T> listUnmodifiableList = Collections.unmodifiableList(r.A(list));
        j.b(listUnmodifiableList, "Collections.unmodifiableList(toMutableList())");
        return listUnmodifiableList;
    }

    public static final <K, V> Map<K, V> toImmutableMap(Map<K, ? extends V> map) {
        j.c(map, "$this$toImmutableMap");
        if (map.isEmpty()) {
            return c.l.a0.a();
        }
        Map<K, V> mapUnmodifiableMap = Collections.unmodifiableMap(new LinkedHashMap(map));
        j.b(mapUnmodifiableMap, "Collections.unmodifiableMap(LinkedHashMap(this))");
        return mapUnmodifiableMap;
    }

    public static final long toLongOrDefault(String str, long j) {
        j.c(str, "$this$toLongOrDefault");
        try {
            return Long.parseLong(str);
        } catch (NumberFormatException unused) {
            return j;
        }
    }

    public static final int toNonNegativeInt(String str, int i) {
        if (str != null) {
            try {
                long j = Long.parseLong(str);
                if (j > Integer.MAX_VALUE) {
                    return Integer.MAX_VALUE;
                }
                if (j < 0) {
                    return 0;
                }
                return (int) j;
            } catch (NumberFormatException unused) {
            }
        }
        return i;
    }

    public static final String trimSubstring(String str, int i, int i2) {
        j.c(str, "$this$trimSubstring");
        int iIndexOfFirstNonAsciiWhitespace = indexOfFirstNonAsciiWhitespace(str, i, i2);
        String strSubstring = str.substring(iIndexOfFirstNonAsciiWhitespace, indexOfLastNonAsciiWhitespace(str, iIndexOfFirstNonAsciiWhitespace, i2));
        j.b(strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    public static /* synthetic */ String trimSubstring$default(String str, int i, int i2, int i3, Object obj) {
        if ((i3 & 1) != 0) {
            i = 0;
        }
        if ((i3 & 2) != 0) {
            i2 = str.length();
        }
        return trimSubstring(str, i, i2);
    }

    public static final void tryExecute(Executor executor, String str, a<c.j> aVar) {
        j.c(executor, "$this$tryExecute");
        j.c(str, "name");
        j.c(aVar, "block");
        try {
            executor.execute(new RunnableC00411(str, aVar));
        } catch (RejectedExecutionException unused) {
        }
    }

    public static final void wait(Object obj) throws InterruptedException {
        j.c(obj, "$this$wait");
        obj.wait();
    }

    public static final void waitMillis(Object obj, long j, int i) throws InterruptedException {
        j.c(obj, "$this$waitMillis");
        if (j > 0 || i > 0) {
            obj.wait(j, i);
        }
    }

    public static /* synthetic */ void waitMillis$default(Object obj, long j, int i, int i2, Object obj2) throws InterruptedException {
        if ((i2 & 2) != 0) {
            i = 0;
        }
        waitMillis(obj, j, i);
    }

    public static final void writeMedium(d.g gVar, int i) throws IOException {
        j.c(gVar, "$this$writeMedium");
        gVar.z((i >>> 16) & 255);
        gVar.z((i >>> 8) & 255);
        gVar.z(i & 255);
    }

    public static final int delimiterOffset(String str, char c2, int i, int i2) {
        j.c(str, "$this$delimiterOffset");
        while (i < i2) {
            if (str.charAt(i) == c2) {
                return i;
            }
            i++;
        }
        return i2;
    }

    public static /* synthetic */ int delimiterOffset$default(String str, char c2, int i, int i2, int i3, Object obj) {
        if ((i3 & 2) != 0) {
            i = 0;
        }
        if ((i3 & 4) != 0) {
            i2 = str.length();
        }
        return delimiterOffset(str, c2, i, i2);
    }

    public static final String toHexString(int i) {
        String hexString = Integer.toHexString(i);
        j.b(hexString, "Integer.toHexString(this)");
        return hexString;
    }

    public static final void closeQuietly(Socket socket) {
        j.c(socket, "$this$closeQuietly");
        try {
            socket.close();
        } catch (AssertionError e2) {
            throw e2;
        } catch (RuntimeException e3) {
            throw e3;
        } catch (Exception unused) {
        }
    }

    public static final void closeQuietly(ServerSocket serverSocket) {
        j.c(serverSocket, "$this$closeQuietly");
        try {
            serverSocket.close();
        } catch (RuntimeException e2) {
            throw e2;
        } catch (Exception unused) {
        }
    }

    public static final int skipAll(d.f fVar, byte b2) throws EOFException {
        j.c(fVar, "$this$skipAll");
        int i = 0;
        while (!fVar.y() && fVar.K(0L) == b2) {
            i++;
            fVar.readByte();
        }
        return i;
    }
}
