; LLVM IR from LeoVen/C-Macro-Collections :: tests (types)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @sl1_impl_sort_quicksort(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %struct.struct_s, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca %struct.struct_s, align 8
  %13 = alloca %struct.struct_s, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %102, %4
  %15 = load i64, ptr %7, align 8, !tbaa !9
  %16 = load i64, ptr %8, align 8, !tbaa !9
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %18, label %103

18:                                               ; preds = %14
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = sub i64 %19, %20
  %22 = icmp ult i64 %21, 10
  br i1 %22, label %23, label %28

23:                                               ; preds = %18
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = load i64, ptr %8, align 8, !tbaa !9
  call void @sl1_impl_sort_insertion(ptr noundef %24, ptr noundef %25, i64 noundef %26, i64 noundef %27)
  br label %103

28:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 104, ptr %9) #3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.struct_s, ptr %29, i64 %30
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %31, i64 104, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %32 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %32, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %33 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %33, ptr %11, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %62, %28
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %65

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i64, ptr %11, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.struct_s, ptr %41, i64 %42
  %44 = call i32 %40(ptr noundef byval(%struct.struct_s) align 8 %43, ptr noundef byval(%struct.struct_s) align 8 %9)
  %45 = icmp sle i32 %44, 0
  br i1 %45, label %46, label %61

46:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 104, ptr %12) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.struct_s, ptr %47, i64 %48
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %49, i64 104, i1 false), !tbaa.struct !11
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i64, ptr %11, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.struct_s, ptr %50, i64 %51
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.struct_s, ptr %53, i64 %54
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %55, i64 104, i1 false), !tbaa.struct !11
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i64, ptr %10, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.struct_s, ptr %56, i64 %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %58, ptr align 8 %12, i64 104, i1 false), !tbaa.struct !11
  %59 = load i64, ptr %10, align 8, !tbaa !9
  %60 = add i64 %59, 1
  store i64 %60, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 104, ptr %12) #3
  br label %61

61:                                               ; preds = %46, %39
  br label %62

62:                                               ; preds = %61
  %63 = load i64, ptr %11, align 8, !tbaa !9
  %64 = add i64 %63, 1
  store i64 %64, ptr %11, align 8, !tbaa !9
  br label %34, !llvm.loop !15

65:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 104, ptr %13) #3
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.struct_s, ptr %66, i64 %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %68, i64 104, i1 false), !tbaa.struct !11
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load i64, ptr %10, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.struct_s, ptr %69, i64 %70
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i64, ptr %8, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.struct_s, ptr %72, i64 %73
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %71, ptr align 8 %74, i64 104, i1 false), !tbaa.struct !11
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = load i64, ptr %8, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.struct_s, ptr %75, i64 %76
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %77, ptr align 8 %13, i64 104, i1 false), !tbaa.struct !11
  %78 = load i64, ptr %10, align 8, !tbaa !9
  %79 = load i64, ptr %7, align 8, !tbaa !9
  %80 = sub i64 %78, %79
  %81 = load i64, ptr %8, align 8, !tbaa !9
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = sub i64 %81, %82
  %84 = icmp ult i64 %80, %83
  br i1 %84, label %85, label %93

85:                                               ; preds = %65
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = load i64, ptr %7, align 8, !tbaa !9
  %89 = load i64, ptr %10, align 8, !tbaa !9
  %90 = sub i64 %89, 1
  call void @sl1_impl_sort_quicksort(ptr noundef %86, ptr noundef %87, i64 noundef %88, i64 noundef %90)
  %91 = load i64, ptr %10, align 8, !tbaa !9
  %92 = add i64 %91, 1
  store i64 %92, ptr %7, align 8, !tbaa !9
  br label %101

93:                                               ; preds = %65
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = load i64, ptr %10, align 8, !tbaa !9
  %97 = add i64 %96, 1
  %98 = load i64, ptr %8, align 8, !tbaa !9
  call void @sl1_impl_sort_quicksort(ptr noundef %94, ptr noundef %95, i64 noundef %97, i64 noundef %98)
  %99 = load i64, ptr %10, align 8, !tbaa !9
  %100 = sub i64 %99, 1
  store i64 %100, ptr %8, align 8, !tbaa !9
  br label %101

101:                                              ; preds = %93, %85
  call void @llvm.lifetime.end.p0(i64 104, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 104, ptr %9) #3
  br label %102

102:                                              ; preds = %101
  br label %14, !llvm.loop !17

103:                                              ; preds = %23, %14
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @sl1_impl_sort_insertion(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @sl1_impl_sort_quicksort(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.struct_s, align 8
  %6 = alloca %struct.struct_s, align 8
  %7 = alloca %struct.struct_s, align 8
  %8 = icmp ult i64 %2, %3
  br i1 %8, label %.lr.ph60, label %.loopexit

.lr.ph60:                                         ; preds = %4, %32
  %.04958 = phi i64 [ %.150, %32 ], [ %3, %4 ]
  %.05157 = phi i64 [ %.152, %32 ], [ %2, %4 ]
  %9 = sub i64 %.04958, %.05157
  %10 = icmp ult i64 %9, 10
  br i1 %10, label %11, label %12

11:                                               ; preds = %.lr.ph60
  tail call void @sl1_impl_sort_insertion(ptr noundef %0, ptr noundef %1, i64 noundef %.05157, i64 noundef %.04958)
  br label %.loopexit

12:                                               ; preds = %.lr.ph60
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %5) #3
  %13 = getelementptr inbounds %struct.struct_s, ptr %0, i64 %.04958
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %5, ptr noundef nonnull align 8 dereferenceable(104) %13, i64 104, i1 false), !tbaa.struct !5
  %14 = icmp ult i64 %.05157, %.04958
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %24
  %.pre = sub i64 %.04958, %.1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %12
  %.pre-phi = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %9, %12 ]
  %.048.lcssa = phi i64 [ %.1, %._crit_edge.loopexit ], [ %.05157, %12 ]
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %7)
  %15 = getelementptr inbounds %struct.struct_s, ptr %0, i64 %.048.lcssa
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %7, ptr noundef nonnull align 8 dereferenceable(104) %15, i64 104, i1 false), !tbaa.struct !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %15, ptr noundef nonnull align 8 dereferenceable(104) %13, i64 104, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %13, ptr noundef nonnull align 8 dereferenceable(104) %7, i64 104, i1 false), !tbaa.struct !5
  %16 = sub i64 %.048.lcssa, %.05157
  %17 = icmp ult i64 %16, %.pre-phi
  br i1 %17, label %26, label %29

.lr.ph:                                           ; preds = %12, %24
  %.056 = phi i64 [ %25, %24 ], [ %.05157, %12 ]
  %.04855 = phi i64 [ %.1, %24 ], [ %.05157, %12 ]
  %18 = getelementptr inbounds %struct.struct_s, ptr %0, i64 %.056
  %19 = tail call i32 %1(ptr noundef byval(%struct.struct_s) align 8 %18, ptr noundef nonnull byval(%struct.struct_s) align 8 %5) #3
  %20 = icmp slt i32 %19, 1
  br i1 %20, label %21, label %24

21:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %6)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %6, ptr noundef nonnull align 8 dereferenceable(104) %18, i64 104, i1 false), !tbaa.struct !5
  %22 = getelementptr inbounds %struct.struct_s, ptr %0, i64 %.04855
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %18, ptr noundef nonnull align 8 dereferenceable(104) %22, i64 104, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %22, ptr noundef nonnull align 8 dereferenceable(104) %6, i64 104, i1 false), !tbaa.struct !5
  %23 = add i64 %.04855, 1
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %6)
  br label %24

24:                                               ; preds = %.lr.ph, %21
  %.1 = phi i64 [ %23, %21 ], [ %.04855, %.lr.ph ]
  %25 = add i64 %.056, 1
  %exitcond.not = icmp eq i64 %25, %.04958
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !13

26:                                               ; preds = %._crit_edge
  %27 = add i64 %.048.lcssa, -1
  tail call void @sl1_impl_sort_quicksort(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %.05157, i64 noundef %27)
  %28 = add i64 %.048.lcssa, 1
  br label %32

29:                                               ; preds = %._crit_edge
  %30 = add i64 %.048.lcssa, 1
  tail call void @sl1_impl_sort_quicksort(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %30, i64 noundef %.04958)
  %31 = add i64 %.048.lcssa, -1
  br label %32

32:                                               ; preds = %29, %26
  %.152 = phi i64 [ %28, %26 ], [ %.05157, %29 ]
  %.150 = phi i64 [ %.04958, %26 ], [ %31, %29 ]
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %7)
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #3
  %33 = icmp ult i64 %.152, %.150
  br i1 %33, label %.lr.ph60, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %32, %4, %11
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @sl1_impl_sort_insertion(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 8, !10, i64 16, i64 8, !10, i64 24, i64 80, !12}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass