; 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.treeset1 = type { ptr, i64, i32, ptr, ptr }
%struct.treeset1_node = type { %struct.struct_s, i8, ptr, ptr, ptr }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.treeset1_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.cmc_alloc_node = type { ptr, ptr, ptr, ptr }

; 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: nounwind uwtable
define dso_local void @ts1_clear(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.treeset1, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %112, %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %113

13:                                               ; preds = %10
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.treeset1_node, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %27

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.treeset1_node, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  store ptr %21, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.treeset1_node, ptr %23, i32 0, i32 3
  store ptr %22, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %25, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %26, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %112

27:                                               ; preds = %13
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.treeset1_node, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %43

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.treeset1_node, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  store ptr %35, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.treeset1_node, ptr %37, i32 0, i32 3
  store ptr %36, ptr %38, align 8, !tbaa !13
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.treeset1_node, ptr %39, i32 0, i32 2
  store ptr null, ptr %40, align 8, !tbaa !16
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %41, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %42, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %111

43:                                               ; preds = %27
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %68

46:                                               ; preds = %43
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.treeset1, ptr %47, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = getelementptr inbounds %struct.treeset1_fval, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %61

53:                                               ; preds = %46
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.treeset1, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = getelementptr inbounds %struct.treeset1_fval, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.treeset1_node, ptr %59, i32 0, i32 0
  call void %58(ptr noundef byval(%struct.struct_s) align 8 %60)
  br label %61

61:                                               ; preds = %53, %46
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.treeset1, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !20
  %65 = getelementptr inbounds %struct.cmc_alloc_node, ptr %64, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !21
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  call void %66(ptr noundef %67)
  store ptr null, ptr %3, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %61, %43
  br label %69

69:                                               ; preds = %109, %68
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %110

72:                                               ; preds = %69
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.treeset1, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  %76 = getelementptr inbounds %struct.treeset1_fval, ptr %75, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !18
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %87

79:                                               ; preds = %72
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.treeset1, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  %83 = getelementptr inbounds %struct.treeset1_fval, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !18
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.treeset1_node, ptr %85, i32 0, i32 0
  call void %84(ptr noundef byval(%struct.struct_s) align 8 %86)
  br label %87

87:                                               ; preds = %79, %72
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.treeset1, ptr %88, i32 0, i32 4
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  %91 = getelementptr inbounds %struct.cmc_alloc_node, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  call void %92(ptr noundef %93)
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.treeset1_node, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = icmp ne ptr %96, null
  br i1 %97, label %98, label %104

98:                                               ; preds = %87
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.treeset1_node, ptr %99, i32 0, i32 2
  %101 = load ptr, ptr %100, align 8, !tbaa !16
  store ptr %101, ptr %3, align 8, !tbaa !5
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.treeset1_node, ptr %102, i32 0, i32 2
  store ptr null, ptr %103, align 8, !tbaa !16
  br label %110

104:                                              ; preds = %87
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %105, ptr %3, align 8, !tbaa !5
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.treeset1_node, ptr %106, i32 0, i32 3
  %108 = load ptr, ptr %107, align 8, !tbaa !13
  store ptr %108, ptr %4, align 8, !tbaa !5
  br label %109

109:                                              ; preds = %104
  br label %69, !llvm.loop !23

110:                                              ; preds = %98, %69
  br label %111

111:                                              ; preds = %110, %32
  br label %112

112:                                              ; preds = %111, %18
  br label %10, !llvm.loop !25

113:                                              ; preds = %10
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.treeset1, ptr %114, i32 0, i32 1
  store i64 0, ptr %115, align 8, !tbaa !26
  %116 = load ptr, ptr %2, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.treeset1, ptr %116, i32 0, i32 0
  store ptr null, ptr %117, align 8, !tbaa !9
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.treeset1, ptr %118, i32 0, i32 2
  store i32 0, ptr %119, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !6, i64 0}
!10 = !{!"treeset1", !6, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 120}
!14 = !{!"treeset1_node", !15, i64 0, !7, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!15 = !{!"struct_s", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!16 = !{!14, !6, i64 112}
!17 = !{!10, !6, i64 24}
!18 = !{!19, !6, i64 24}
!19 = !{!"treeset1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!10, !6, i64 32}
!21 = !{!22, !6, i64 24}
!22 = !{!"cmc_alloc_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!10, !11, i64 8}
!27 = !{!10, !12, i64 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: nounwind uwtable
define dso_local void @ts1_clear(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not55 = icmp eq ptr %2, null
  br i1 %.not55, label %._crit_edge, label %.lr.ph58

.lr.ph58:                                         ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  br label %5

5:                                                ; preds = %.loopexit, %.lr.ph58
  %.057 = phi ptr [ %2, %.lr.ph58 ], [ %.3, %.loopexit ]
  %.03556 = phi ptr [ null, %.lr.ph58 ], [ %.237, %.loopexit ]
  %6 = getelementptr inbounds i8, ptr %.057, i64 120
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %.not43 = icmp eq ptr %7, null
  br i1 %.not43, label %9, label %8

8:                                                ; preds = %5
  store ptr %.03556, ptr %6, align 8, !tbaa !12
  br label %.loopexit

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %.057, i64 112
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %.not44 = icmp eq ptr %11, null
  br i1 %.not44, label %13, label %12

12:                                               ; preds = %9
  store ptr %.03556, ptr %6, align 8, !tbaa !12
  store ptr null, ptr %10, align 8, !tbaa !15
  br label %.loopexit

13:                                               ; preds = %9
  %14 = icmp eq ptr %.03556, null
  br i1 %14, label %15, label %.lr.ph

15:                                               ; preds = %13
  %16 = load ptr, ptr %3, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %.not45 = icmp eq ptr %18, null
  br i1 %.not45, label %._crit_edge.loopexit, label %19

19:                                               ; preds = %15
  tail call void %18(ptr noundef nonnull byval(%struct.struct_s) align 8 %.057) #2
  br label %._crit_edge.loopexit

.lr.ph:                                           ; preds = %13, %32
  %.254 = phi ptr [ %.13653, %32 ], [ %.057, %13 ]
  %.13653 = phi ptr [ %34, %32 ], [ %.03556, %13 ]
  %20 = load ptr, ptr %3, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %.not47 = icmp eq ptr %22, null
  br i1 %.not47, label %24, label %23

23:                                               ; preds = %.lr.ph
  tail call void %22(ptr noundef nonnull byval(%struct.struct_s) align 8 %.254) #2
  br label %24

24:                                               ; preds = %23, %.lr.ph
  %25 = load ptr, ptr %4, align 8, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %25, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  tail call void %27(ptr noundef nonnull %.254) #2
  %28 = getelementptr inbounds i8, ptr %.13653, i64 112
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %.not48 = icmp eq ptr %29, null
  br i1 %.not48, label %32, label %30

30:                                               ; preds = %24
  %31 = getelementptr inbounds i8, ptr %.13653, i64 112
  store ptr null, ptr %31, align 8, !tbaa !15
  br label %.loopexit

32:                                               ; preds = %24
  %33 = getelementptr inbounds i8, ptr %.13653, i64 120
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %.not46 = icmp eq ptr %34, null
  br i1 %.not46, label %.loopexit, label %.lr.ph, !llvm.loop !22

.loopexit:                                        ; preds = %32, %12, %30, %8
  %.237 = phi ptr [ %.057, %8 ], [ %.057, %12 ], [ %.13653, %30 ], [ null, %32 ]
  %.3 = phi ptr [ %7, %8 ], [ %11, %12 ], [ %29, %30 ], [ %.13653, %32 ]
  br label %5, !llvm.loop !24

._crit_edge.loopexit:                             ; preds = %15, %19
  %35 = load ptr, ptr %4, align 8, !tbaa !19
  %36 = getelementptr inbounds i8, ptr %35, i64 24
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  tail call void %37(ptr noundef nonnull %.057) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %0, i8 0, i64 20, i1 false)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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, !7, i64 0}
!6 = !{!"treeset1", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !7, i64 120}
!13 = !{!"treeset1_node", !14, i64 0, !8, i64 104, !7, i64 112, !7, i64 120, !7, i64 128}
!14 = !{!"struct_s", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!15 = !{!13, !7, i64 112}
!16 = !{!6, !7, i64 24}
!17 = !{!18, !7, i64 24}
!18 = !{!"treeset1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!19 = !{!6, !7, i64 32}
!20 = !{!21, !7, i64 24}
!21 = !{!"cmc_alloc_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


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