def label_length(buf, label_index):
    """ Calculate label length including compression.
        Returns a tuple: the total length and a boolean value indicating whether wrap-around condition has occurred.
        Note that this function incorrectly handles the case of a starting 0 length.
        This is intended, because the goal is to emulate the real-deal :)
        
        Example:
         print(label_length(b'\x03www\x06google\x03com\x00', 0)) # 15, False
    """
    wraparound = False
    total_length = 0
    
    i = label_index
    length = buf[i]
    non_zero_length = True
    while non_zero_length:

        if (length & 0xc0) == 0:
            total_length = total_length + 1 + length
            wraparound = wraparound or total_length > 0xffff
            total_length &= 0xffff

            i = i + 1 + length
            i &= 0xffff
        else:
            new_index = (length & 0x3f) + buf[i+1]

            if new_index >= label_index:
                # bad compression
                return 0, False
            
            label_index = new_index
            i = label_index

        length = buf[i]
        non_zero_length = length != 0
    
    return total_length, wraparound