<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def derive_source_offset(self, offset, is_end=False):
 """ Given a post-preprocessed coordinate, derives the corresponding coordinate in the original source file. Returns result in the following tuple: (src_offset, src_path, include_ref) where: - src_offset is the translated coordinate If the input offset lands on a macro expansion, then src_offset returns the start or end coordinate according to is_end - src_path points to the original source file - include_ref describes any `include lineage using a IncludeRef object Is none if file was not referenced via include """

        for segment in self.segments:
            if offset <= segment.end:
                if isinstance(segment, MacroSegment):
                    if is_end:
                        return (
                            segment.src_end,
                            segment.src,
                            segment.incl_ref
                        )
                    else:
                        return (
                            segment.src_start,
                            segment.src,
                            segment.incl_ref
                        )
                else:
                    return (
                        segment.src_start + (offset - segment.start),
                        segment.src,
                        segment.incl_ref
                    )

        # Reached end. Assume end of last segment
        return (
            self.segments[-1].src_end,
            self.segments[-1].src,
            self.segments[-1].incl_ref
        )