; 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_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.treeset1_node = type { %struct.struct_s, i8, 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 zeroext i1 @ts1_insert(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call zeroext i1 @ts1_empty(ptr noundef %9)
  br i1 %10, label %11, label %24

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call ptr @ts1_impl_new_node(ptr noundef %12, ptr noundef byval(%struct.struct_s) align 8 %1)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.treeset1, ptr %14, i32 0, i32 0
  store ptr %13, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.treeset1, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %23, label %20

20:                                               ; preds = %11
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.treeset1, ptr %21, i32 0, i32 2
  store i32 1, ptr %22, align 8, !tbaa !13
  store i1 false, ptr %3, align 1
  br label %132

23:                                               ; preds = %11
  br label %125

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.treeset1, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  store ptr %27, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %28, ptr %6, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %65, %24
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %66

32:                                               ; preds = %29
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.treeset1, ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds %struct.treeset1_fval, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.treeset1_node, ptr %39, i32 0, i32 0
  %41 = call i32 %38(ptr noundef byval(%struct.struct_s) align 8 %40, ptr noundef byval(%struct.struct_s) align 8 %1)
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %47

43:                                               ; preds = %32
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.treeset1_node, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  store ptr %46, ptr %5, align 8, !tbaa !5
  br label %65

47:                                               ; preds = %32
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.treeset1, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds %struct.treeset1_fval, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.treeset1_node, ptr %53, i32 0, i32 0
  %55 = call i32 %52(ptr noundef byval(%struct.struct_s) align 8 %54, ptr noundef byval(%struct.struct_s) align 8 %1)
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %61

57:                                               ; preds = %47
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.treeset1_node, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  store ptr %60, ptr %5, align 8, !tbaa !5
  br label %64

61:                                               ; preds = %47
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.treeset1, ptr %62, i32 0, i32 2
  store i32 6, ptr %63, align 8, !tbaa !13
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %122

64:                                               ; preds = %57
  br label %65

65:                                               ; preds = %64, %43
  br label %29, !llvm.loop !21

66:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.treeset1, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !14
  %70 = getelementptr inbounds %struct.treeset1_fval, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !15
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.treeset1_node, ptr %72, i32 0, i32 0
  %74 = call i32 %71(ptr noundef byval(%struct.struct_s) align 8 %73, ptr noundef byval(%struct.struct_s) align 8 %1)
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %76, label %97

76:                                               ; preds = %66
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = call ptr @ts1_impl_new_node(ptr noundef %77, ptr noundef byval(%struct.struct_s) align 8 %1)
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.treeset1_node, ptr %79, i32 0, i32 3
  store ptr %78, ptr %80, align 8, !tbaa !17
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.treeset1_node, ptr %81, i32 0, i32 3
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  %84 = icmp ne ptr %83, null
  br i1 %84, label %88, label %85

85:                                               ; preds = %76
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.treeset1, ptr %86, i32 0, i32 2
  store i32 1, ptr %87, align 8, !tbaa !13
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %121

88:                                               ; preds = %76
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.treeset1_node, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = getelementptr inbounds %struct.treeset1_node, ptr %92, i32 0, i32 4
  store ptr %89, ptr %93, align 8, !tbaa !23
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.treeset1_node, ptr %94, i32 0, i32 3
  %96 = load ptr, ptr %95, align 8, !tbaa !17
  store ptr %96, ptr %8, align 8, !tbaa !5
  br label %118

97:                                               ; preds = %66
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = call ptr @ts1_impl_new_node(ptr noundef %98, ptr noundef byval(%struct.struct_s) align 8 %1)
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.treeset1_node, ptr %100, i32 0, i32 2
  store ptr %99, ptr %101, align 8, !tbaa !20
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.treeset1_node, ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !20
  %105 = icmp ne ptr %104, null
  br i1 %105, label %109, label %106

106:                                              ; preds = %97
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.treeset1, ptr %107, i32 0, i32 2
  store i32 1, ptr %108, align 8, !tbaa !13
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %121

109:                                              ; preds = %97
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.treeset1_node, ptr %111, i32 0, i32 2
  %113 = load ptr, ptr %112, align 8, !tbaa !20
  %114 = getelementptr inbounds %struct.treeset1_node, ptr %113, i32 0, i32 4
  store ptr %110, ptr %114, align 8, !tbaa !23
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.treeset1_node, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  store ptr %117, ptr %8, align 8, !tbaa !5
  br label %118

118:                                              ; preds = %109, %88
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ts1_impl_rebalance(ptr noundef %119, ptr noundef %120)
  store i32 0, ptr %7, align 4
  br label %121

121:                                              ; preds = %118, %106, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %122

122:                                              ; preds = %121, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  %123 = load i32, ptr %7, align 4
  switch i32 %123, label %134 [
    i32 0, label %124
    i32 1, label %132
  ]

124:                                              ; preds = %122
  br label %125

125:                                              ; preds = %124, %23
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.treeset1, ptr %126, i32 0, i32 1
  %128 = load i64, ptr %127, align 8, !tbaa !24
  %129 = add i64 %128, 1
  store i64 %129, ptr %127, align 8, !tbaa !24
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.treeset1, ptr %130, i32 0, i32 2
  store i32 0, ptr %131, align 8, !tbaa !13
  store i1 true, ptr %3, align 1
  br label %132

132:                                              ; preds = %125, %122, %20
  %133 = load i1, ptr %3, align 1
  ret i1 %133

134:                                              ; preds = %122
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ts1_empty(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @ts1_impl_new_node(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #1

; Function Attrs: nounwind uwtable
declare hidden void @ts1_impl_rebalance(ptr noundef, ptr noundef) #1

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


; 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 noundef zeroext i1 @ts1_insert(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @ts1_empty(ptr noundef %0)
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call ptr @ts1_impl_new_node(ptr noundef %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %1)
  store ptr %5, ptr %0, align 8, !tbaa !5
  %.not47 = icmp eq ptr %5, null
  br i1 %.not47, label %.thread, label %33

6:                                                ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %.not51 = icmp eq ptr %7, null
  br i1 %.not51, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  br label %9

9:                                                ; preds = %.lr.ph, %19
  %.03952 = phi ptr [ %7, %.lr.ph ], [ %.140, %19 ]
  %10 = load ptr, ptr %8, align 8, !tbaa !12
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = tail call i32 %11(ptr noundef nonnull byval(%struct.struct_s) align 8 %.03952, ptr noundef nonnull byval(%struct.struct_s) align 8 %1) #1
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %19, label %14

14:                                               ; preds = %9
  %15 = load ptr, ptr %8, align 8, !tbaa !12
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = tail call i32 %16(ptr noundef nonnull byval(%struct.struct_s) align 8 %.03952, ptr noundef nonnull byval(%struct.struct_s) align 8 %1) #1
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %.thread

19:                                               ; preds = %14, %9
  %.sink = phi i64 [ 120, %9 ], [ 112, %14 ]
  %20 = getelementptr inbounds i8, ptr %.03952, i64 %.sink
  %.140 = load ptr, ptr %20, align 8, !tbaa !15
  %.not = icmp eq ptr %.140, null
  br i1 %.not, label %._crit_edge, label %9, !llvm.loop !16

._crit_edge:                                      ; preds = %19, %6
  %.038.lcssa = phi ptr [ null, %6 ], [ %.03952, %19 ]
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = tail call i32 %23(ptr noundef byval(%struct.struct_s) align 8 %.038.lcssa, ptr noundef nonnull byval(%struct.struct_s) align 8 %1) #1
  %25 = icmp sgt i32 %24, 0
  %26 = tail call ptr @ts1_impl_new_node(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.struct_s) align 8 %1)
  %.not46 = icmp eq ptr %26, null
  br i1 %25, label %27, label %29

27:                                               ; preds = %._crit_edge
  %28 = getelementptr inbounds i8, ptr %.038.lcssa, i64 120
  store ptr %26, ptr %28, align 8, !tbaa !18
  br i1 %.not46, label %.thread, label %31

29:                                               ; preds = %._crit_edge
  %30 = getelementptr inbounds i8, ptr %.038.lcssa, i64 112
  store ptr %26, ptr %30, align 8, !tbaa !21
  br i1 %.not46, label %.thread, label %31

31:                                               ; preds = %29, %27
  %.0.in = phi ptr [ %28, %27 ], [ %30, %29 ]
  %32 = getelementptr inbounds i8, ptr %26, i64 128
  store ptr %.038.lcssa, ptr %32, align 8, !tbaa !22
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !15
  tail call void @ts1_impl_rebalance(ptr noundef nonnull %0, ptr noundef %.0)
  br label %33

33:                                               ; preds = %31, %4
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !23
  %36 = add i64 %35, 1
  store i64 %36, ptr %34, align 8, !tbaa !23
  br label %.thread

.thread:                                          ; preds = %14, %29, %27, %4, %33
  %.sink56 = phi i32 [ 0, %33 ], [ 1, %4 ], [ 1, %27 ], [ 1, %29 ], [ 6, %14 ]
  %.2 = phi i1 [ true, %33 ], [ false, %4 ], [ false, %27 ], [ false, %29 ], [ false, %14 ]
  %37 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %.sink56, ptr %37, align 8, !tbaa !24
  ret i1 %.2
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ts1_empty(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @ts1_impl_new_node(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @ts1_impl_rebalance(ptr noundef, ptr noundef) local_unnamed_addr #0

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


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