; 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] }
%struct.treeset1 = type { ptr, i64, i32, ptr, ptr }
%struct.treeset1_node = type { %struct.struct_s, i8, ptr, ptr, ptr }
%struct.treeset1_fval = type { ptr, ptr, 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: 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
declare dso_local ptr @ts1_new_custom(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ts1_insert(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @ts1_copy_of(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca %struct.struct_s, align 8
  %9 = alloca %struct.struct_s, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.treeset1, ptr %10, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.treeset1, ptr %13, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = call ptr @ts1_new_custom(ptr noundef %12, ptr noundef %15, ptr noundef null)
  store ptr %16, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %22, label %19

19:                                               ; preds = %1
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.treeset1, ptr %20, i32 0, i32 2
  store i32 7, ptr %21, align 8, !tbaa !14
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %117

22:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.treeset1, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  store ptr %25, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !16
  br label %26

26:                                               ; preds = %112, %22
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %113

29:                                               ; preds = %26
  %30 = load i8, ptr %7, align 1, !tbaa !16, !range !18, !noundef !19
  %31 = trunc i8 %30 to i1
  br i1 %31, label %43, label %32

32:                                               ; preds = %29
  br label %33

33:                                               ; preds = %38, %32
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.treeset1_node, ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %42

38:                                               ; preds = %33
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.treeset1_node, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  store ptr %41, ptr %6, align 8, !tbaa !5
  br label %33, !llvm.loop !23

42:                                               ; preds = %33
  br label %43

43:                                               ; preds = %42, %29
  call void @llvm.lifetime.start.p0(i64 104, ptr %8) #3
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.treeset1, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.treeset1_fval, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !25
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %58

50:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 104, ptr %9) #3
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.treeset1, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.treeset1_fval, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !25
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.treeset1_node, ptr %56, i32 0, i32 0
  call void %55(ptr dead_on_unwind writable sret(%struct.struct_s) align 8 %9, ptr noundef byval(%struct.struct_s) align 8 %57)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %9, i64 104, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 104, ptr %9) #3
  br label %61

58:                                               ; preds = %43
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.treeset1_node, ptr %59, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %60, i64 104, i1 false), !tbaa.struct !27
  br label %61

61:                                               ; preds = %58, %50
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call zeroext i1 @ts1_insert(ptr noundef %62, ptr noundef byval(%struct.struct_s) align 8 %8)
  store i8 1, ptr %7, align 1, !tbaa !16
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.treeset1_node, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !30
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %72

68:                                               ; preds = %61
  store i8 0, ptr %7, align 1, !tbaa !16
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.treeset1_node, ptr %69, i32 0, i32 2
  %71 = load ptr, ptr %70, align 8, !tbaa !30
  store ptr %71, ptr %6, align 8, !tbaa !5
  br label %109

72:                                               ; preds = %61
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.treeset1_node, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !31
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %107

77:                                               ; preds = %72
  br label %78

78:                                               ; preds = %93, %77
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.treeset1_node, ptr %79, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !31
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %91

83:                                               ; preds = %78
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.treeset1_node, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !31
  %88 = getelementptr inbounds %struct.treeset1_node, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !30
  %90 = icmp eq ptr %84, %89
  br label %91

91:                                               ; preds = %83, %78
  %92 = phi i1 [ false, %78 ], [ %90, %83 ]
  br i1 %92, label %93, label %97

93:                                               ; preds = %91
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.treeset1_node, ptr %94, i32 0, i32 4
  %96 = load ptr, ptr %95, align 8, !tbaa !31
  store ptr %96, ptr %6, align 8, !tbaa !5
  br label %78, !llvm.loop !32

97:                                               ; preds = %91
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.treeset1_node, ptr %98, i32 0, i32 4
  %100 = load ptr, ptr %99, align 8, !tbaa !31
  %101 = icmp ne ptr %100, null
  br i1 %101, label %103, label %102

102:                                              ; preds = %97
  store i32 3, ptr %5, align 4
  br label %110

103:                                              ; preds = %97
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.treeset1_node, ptr %104, i32 0, i32 4
  %106 = load ptr, ptr %105, align 8, !tbaa !31
  store ptr %106, ptr %6, align 8, !tbaa !5
  br label %108

107:                                              ; preds = %72
  store i32 3, ptr %5, align 4
  br label %110

108:                                              ; preds = %103
  br label %109

109:                                              ; preds = %108, %68
  store i32 0, ptr %5, align 4
  br label %110

110:                                              ; preds = %109, %107, %102
  call void @llvm.lifetime.end.p0(i64 104, ptr %8) #3
  %111 = load i32, ptr %5, align 4
  switch i32 %111, label %119 [
    i32 0, label %112
    i32 3, label %113
  ]

112:                                              ; preds = %110
  br label %26, !llvm.loop !33

113:                                              ; preds = %110, %26
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.treeset1, ptr %114, i32 0, i32 2
  store i32 0, ptr %115, align 8, !tbaa !14
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %116, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %117

117:                                              ; preds = %113, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %118 = load ptr, ptr %2, align 8
  ret ptr %118

119:                                              ; preds = %110
  unreachable
}

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, !6, i64 24}
!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 = !{!10, !6, i64 32}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !6, i64 120}
!21 = !{!"treeset1_node", !22, i64 0, !7, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!22 = !{!"struct_s", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !6, i64 8}
!26 = !{!"treeset1_fval", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!27 = !{i64 0, i64 4, !28, i64 4, i64 4, !28, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !29}
!28 = !{!12, !12, i64 0}
!29 = !{!7, !7, i64 0}
!30 = !{!21, !6, i64 112}
!31 = !{!21, !6, i64 128}
!32 = distinct !{!32, !24}
!33 = distinct !{!33, !24}


; 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
declare dso_local ptr @ts1_new_custom(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ts1_insert(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @ts1_copy_of(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.struct_s, align 8
  %3 = alloca %struct.struct_s, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = tail call ptr @ts1_new_custom(ptr noundef %5, ptr noundef %7, ptr noundef null)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %.loopexit48, label %9

9:                                                ; preds = %1
  %10 = load ptr, ptr %0, align 8, !tbaa !13
  %.not3651 = icmp eq ptr %10, null
  br i1 %.not3651, label %.loopexit48, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.critedge
  %.053 = phi i1 [ %22, %.critedge ], [ false, %9 ]
  %.02652 = phi ptr [ %.5, %.critedge ], [ %10, %9 ]
  br i1 %.053, label %.loopexit, label %.preheader47

.preheader47:                                     ; preds = %.lr.ph, %.preheader47
  %.127 = phi ptr [ %12, %.preheader47 ], [ %.02652, %.lr.ph ]
  %11 = getelementptr inbounds i8, ptr %.127, i64 120
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.not37 = icmp eq ptr %12, null
  br i1 %.not37, label %.loopexit, label %.preheader47, !llvm.loop !17

.loopexit:                                        ; preds = %.preheader47, %.lr.ph
  %.228 = phi ptr [ %.02652, %.lr.ph ], [ %.127, %.preheader47 ]
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %2) #3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %.not38 = icmp eq ptr %15, null
  br i1 %.not38, label %17, label %16

16:                                               ; preds = %.loopexit
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %3) #3
  call void %15(ptr dead_on_unwind nonnull writable sret(%struct.struct_s) align 8 %3, ptr noundef nonnull byval(%struct.struct_s) align 8 %.228) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %2, ptr noundef nonnull align 8 dereferenceable(104) %3, i64 104, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #3
  br label %18

17:                                               ; preds = %.loopexit
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %2, ptr noundef nonnull align 8 dereferenceable(104) %.228, i64 104, i1 false), !tbaa.struct !21
  br label %18

18:                                               ; preds = %17, %16
  %19 = call zeroext i1 @ts1_insert(ptr noundef nonnull %8, ptr noundef nonnull byval(%struct.struct_s) align 8 %2)
  %20 = getelementptr inbounds i8, ptr %.228, i64 112
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %.critedge

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %.228, i64 128
  %25 = load ptr, ptr %24, align 8, !tbaa !26
  %.not39 = icmp eq ptr %25, null
  br i1 %.not39, label %.critedge.thread42, label %.preheader

.preheader:                                       ; preds = %23, %28
  %.3 = phi ptr [ %27, %28 ], [ %.228, %23 ]
  %26 = getelementptr inbounds i8, ptr %.3, i64 128
  %27 = load ptr, ptr %26, align 8, !tbaa !26
  %.not40 = icmp eq ptr %27, null
  br i1 %.not40, label %.critedge.thread42, label %28

28:                                               ; preds = %.preheader
  %29 = getelementptr inbounds i8, ptr %27, i64 112
  %30 = load ptr, ptr %29, align 8, !tbaa !25
  %31 = icmp eq ptr %.3, %30
  br i1 %31, label %.preheader, label %.critedge, !llvm.loop !27

.critedge.thread42:                               ; preds = %23, %.preheader
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %2) #3
  br label %.loopexit48

.critedge:                                        ; preds = %28, %18
  %.5 = phi ptr [ %21, %18 ], [ %27, %28 ]
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %2) #3
  br label %.lr.ph

.loopexit48:                                      ; preds = %.critedge.thread42, %9, %1
  %.sink = phi i32 [ 7, %1 ], [ 0, %9 ], [ 0, %.critedge.thread42 ]
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %.sink, ptr %32, align 8, !tbaa !28
  ret ptr %8
}

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 = !{!6, !7, i64 24}
!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 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !7, i64 120}
!15 = !{!"treeset1_node", !16, i64 0, !8, i64 104, !7, i64 112, !7, i64 120, !7, i64 128}
!16 = !{!"struct_s", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !7, i64 8}
!20 = !{!"treeset1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !22, i64 8, i64 8, !23, i64 16, i64 8, !23, i64 24, i64 80, !24}
!22 = !{!11, !11, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!8, !8, i64 0}
!25 = !{!15, !7, i64 112}
!26 = !{!15, !7, i64 128}
!27 = distinct !{!27, !18}
!28 = !{!6, !11, i64 16}


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