package defpackage;

import java.io.Closeable;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;

/* JADX INFO: renamed from: ʻﹳ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0036 implements Closeable {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final FileInputStream f1180;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public byte[] f1181;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final Charset f1182;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public int f1183;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public int f1184;

    public C0036(FileInputStream fileInputStream, Charset charset) {
        if (charset == null) {
            throw null;
        }
        if (!charset.equals(AbstractC4756.f18131)) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Unsupported encoding");
            throw null;
        }
        this.f1180 = fileInputStream;
        this.f1182 = charset;
        this.f1181 = new byte[8192];
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        synchronized (this.f1180) {
            try {
                if (this.f1181 != null) {
                    this.f1181 = null;
                    this.f1180.close();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0040  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final String m1022() {
        int i;
        synchronized (this.f1180) {
            try {
                byte[] bArr = this.f1181;
                if (bArr == null) {
                    throw new IOException("LineReader is closed");
                }
                if (this.f1183 >= this.f1184) {
                    int i2 = this.f1180.read(bArr, 0, bArr.length);
                    if (i2 == -1) {
                        throw new EOFException();
                    }
                    this.f1183 = 0;
                    this.f1184 = i2;
                }
                for (int i3 = this.f1183; i3 != this.f1184; i3++) {
                    byte[] bArr2 = this.f1181;
                    if (bArr2[i3] == 10) {
                        int i4 = this.f1183;
                        if (i3 != i4) {
                            i = i3 - 1;
                            if (bArr2[i] != 13) {
                                i = i3;
                            }
                        }
                        String str = new String(bArr2, i4, i - i4, this.f1182.name());
                        this.f1183 = i3 + 1;
                        return str;
                    }
                }
                C0164 c0164 = new C0164(this, (this.f1184 - this.f1183) + 80);
                while (true) {
                    byte[] bArr3 = this.f1181;
                    int i5 = this.f1183;
                    c0164.write(bArr3, i5, this.f1184 - i5);
                    this.f1184 = -1;
                    FileInputStream fileInputStream = this.f1180;
                    byte[] bArr4 = this.f1181;
                    int i6 = fileInputStream.read(bArr4, 0, bArr4.length);
                    if (i6 == -1) {
                        throw new EOFException();
                    }
                    this.f1183 = 0;
                    this.f1184 = i6;
                    for (int i7 = 0; i7 != this.f1184; i7++) {
                        byte[] bArr5 = this.f1181;
                        if (bArr5[i7] == 10) {
                            int i8 = this.f1183;
                            if (i7 != i8) {
                                c0164.write(bArr5, i8, i7 - i8);
                            }
                            this.f1183 = i7 + 1;
                            return c0164.toString();
                        }
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
