import platform


def get_machine(is_32_bit: bool):
    """
    Utility to get string representation of the machine name. Possible return
    values:
    name    | Description           | Aliases
    ----------------------------------------
    x86     | Intel/AMD 32-bit      | i386, i686
    x64     | Intel/AMD 64-bit      | x86_64, amd64
    arm     | ARM 32-bit (very old) | armel, armv5 (or older)
    armv6   | ARM 32-bit (old)      | armhf, armv6l, armv6h
    armv7   | ARM 32-bit            | armhf, armv7l, armv7h
    arm64   | ARM 64-bit            | aarch64, armv8l, armv8 (or newer)
    ppc64le | PowerPC achitecture   | ppc64el (debian terminology)
    s390x   | IBM (big endian)      | None
    Unknown | Architecture could not be determined

    The function can also return other values platform.machine returns, without
    any modifications
    """
    machine = platform.machine()
    machine_lowered = machine.lower()
    if machine.endswith("86"):
        return "x86"

    if machine_lowered in {"x86_64", "amd64", "x64"}:
        return "x86" if is_32_bit else "x64"

    if machine_lowered in {"armv8", "armv8l", "arm64", "aarch64"}:
        return "armv7" if is_32_bit else "arm64"

    if machine_lowered.startswith("arm"):
        if "v7" in machine_lowered or "hf" in machine_lowered:
            return "armv7"

        if "v6" in machine_lowered:
            return "armv6"

        return "arm"

    if machine == "ppc64el":
        return "ppc64le"

    if not machine:
        return "Unknown"

    return machine