## 5 Case Study: Applying CVMan to Analyze Clones in Ubuntu
### Answering PQ1
#### 5.2.1 Clone Surface  
In Ubuntu 18.04, the number of clone LoCs is 18,592,560. The clone surface of Ubuntu 18.04 is 0.18. Among the 704 programs, 627 programs contain clones, with a 0.07 median clone surface (i.e., one half of the programs have a clone surface that is higher than 0.07).  
Table 2 lists the top ten programs with the largest clone surface in Ubuntu 18.04. Among these, the program with the largest clone surface value is Fftw3, a C subroutine library utilized for computing the discrete Fourier transform. The clone surface value for Fftw3 is 0.83, which can be attributed to the presence of several similar procedures designed to handle arbitrary input sizes as well as real and complex data. Similarly, SuiteSparse, a library utilized for sparse matrix computations, has a clone surface value of 0.66. Clones in Fftw3 and SuiteSparse are primarily found within the program, which we term as intra-program clones. These clones arise due to the presence of functionally similar procedures within a program, such as polymorphism mechanisms in the C++ language or similar algorithms. Consequently, these functionally similar programs contain the same syntax structures and variables.  
Another type of clone occurs between programs, which we term as inter-program clones. Clones in Libffi, Libart-lgpl, Bzip2, Libogg, Ldb, Libvpx, and Hunspell programs are mainly inter-program clones. The shared code repository is the cause of several inter-program clones. For example, the presence of several inter-program clones in Mozilla Application Suite, which encompasses Firefox, Thunderbird, and SpiderMonkey (Mozjs), can be attributed to the use of the same Mozilla source code repository. Additionally, the reuse of libraries is another contributing factor. For instance, Libffi 3.2.1 is available as a separate program in Ubuntu 18.04 and is included in Python 2.7, GCC-7, and GCC-8, whereas another version of Libffi 3.1 is included in Python 3.6, Thunderbird, Firefox, and Mozjs52.  
Figure 4a presents the cumulative distribution function (CDF) of the clone surfaces for programs in Ubuntu 18.04. It shows that 35% of programs have a clone surface larger than 0.10, and some programs even have a clone surface greater than 0.50. Such high levels of code cloning can adversely affect the maintainability of the codebase. Figure 4 also illustrates the CDF of inter-program clone surface, revealing that 36% of programs have no inter-program clones, while 20% of the programs have an inter-program clone surface  
\begin{table}
\begin{tabular}{c r r r} \hline \hline
**Program** & **LoC** & **Clone LoC** & **Clone Surface** \\ \hline Fftw3 & 264,365 & 219,272 & 0.83 \\ M2300w & 2260 & 1685 & 0.75 \\ Libffi & 25,498 & 17,070 & 0.67 \\ Libart-lgpl & 10,754 & 7245 & 0.67 \\ Bzip2 & 5837 & 3824 & 0.66 \\ SuiteSparse & 539,437 & 358,110 & 0.66 \\ Libogg & 2637 & 1588 & 0.60 \\ Ldb & 67,599 & 39,641 & 0.59 \\ Libvpx & 296,977 & 166,979 & 0.56 \\ Hunspell & 18,520 & 10,362 & 0.56 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Top 10 programs in Ubuntu 18.04 ranked by the clone surface.  
larger than 0.10. When addressing bugs in these programs, developers should check for the presence of clones in other programs.  
Furthermore, the clone surface for each version of Ubuntu was acquired by utilizing eight Ubuntu versions as input. As depicted in Figure 4a, the clone surfaces for each Ubuntu version are shown, and the changes in the clone surface and inter-program clone surface remain consistent. Notably, the clone surface in Ubuntu version.04 is larger than the clone surface in Ubuntu version.10, mainly due to the existence of two or more versions of GCC in Ubuntu version.04. This suggests that clones in Ubuntu are relatively stable, with the exception of Ubuntu 21.10, where the absence of Firefox source code in Ubuntu 21.10 results in a lower clone surface and inter-program clone surface.