1 // RUN: %clangxx -O2 %s -o %t
2 
3 #include <algorithm>
4 #include <assert.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <vector>
8 
compare_ints(const void * a,const void * b)9 static int compare_ints(const void *a, const void *b) {
10   return *(const int *)b - *(const int *)a;
11 }
12 
main()13 int main() {
14   std::vector<int> nums(100000);
15   for (auto &n : nums)
16     n = rand();
17 
18   std::vector<int> to_qsort = nums;
19   qsort(to_qsort.data(), to_qsort.size(), sizeof(to_qsort[0]), &compare_ints);
20 
21   std::sort(nums.begin(), nums.end());
22 
23   assert(nums == to_qsort);
24 }
25