; 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.treemap1 = type { ptr, i64, i32, ptr, ptr, ptr }
%struct.treemap1_fkey = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.treemap1_node = type { %struct.struct_s, %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 @tm1_insert(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1, ptr noundef byval(%struct.struct_s) align 8 %2) #1 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call zeroext i1 @tm1_empty(ptr noundef %10)
  br i1 %11, label %12, label %25

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

21:                                               ; preds = %12
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.treemap1, ptr %22, i32 0, i32 2
  store i32 1, ptr %23, align 8, !tbaa !13
  store i1 false, ptr %4, align 1
  br label %133

24:                                               ; preds = %12
  br label %126

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

30:                                               ; preds = %66, %25
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %67

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.treemap1, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds %struct.treemap1_fkey, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.treemap1_node, ptr %40, i32 0, i32 0
  %42 = call i32 %39(ptr noundef byval(%struct.struct_s) align 8 %41, ptr noundef byval(%struct.struct_s) align 8 %1)
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %44, label %48

44:                                               ; preds = %33
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.treemap1_node, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  store ptr %47, ptr %6, align 8, !tbaa !5
  br label %66

48:                                               ; preds = %33
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.treemap1, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = getelementptr inbounds %struct.treemap1_fkey, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.treemap1_node, ptr %54, i32 0, i32 0
  %56 = call i32 %53(ptr noundef byval(%struct.struct_s) align 8 %55, ptr noundef byval(%struct.struct_s) align 8 %1)
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %58, label %62

58:                                               ; preds = %48
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.treemap1_node, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  store ptr %61, ptr %6, align 8, !tbaa !5
  br label %65

62:                                               ; preds = %48
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.treemap1, ptr %63, i32 0, i32 2
  store i32 6, ptr %64, align 8, !tbaa !13
  store i1 false, ptr %4, align 1
  store i32 1, ptr %8, align 4
  br label %123

65:                                               ; preds = %58
  br label %66

66:                                               ; preds = %65, %44
  br label %30, !llvm.loop !21

67:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.treemap1, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !14
  %71 = getelementptr inbounds %struct.treemap1_fkey, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.treemap1_node, ptr %73, i32 0, i32 0
  %75 = call i32 %72(ptr noundef byval(%struct.struct_s) align 8 %74, ptr noundef byval(%struct.struct_s) align 8 %1)
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %98

77:                                               ; preds = %67
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = call ptr @tm1_impl_new_node(ptr noundef %78, ptr noundef byval(%struct.struct_s) align 8 %1, ptr noundef byval(%struct.struct_s) align 8 %2)
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.treemap1_node, ptr %80, i32 0, i32 4
  store ptr %79, ptr %81, align 8, !tbaa !17
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.treemap1_node, ptr %82, i32 0, i32 4
  %84 = load ptr, ptr %83, align 8, !tbaa !17
  %85 = icmp ne ptr %84, null
  br i1 %85, label %89, label %86

86:                                               ; preds = %77
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.treemap1, ptr %87, i32 0, i32 2
  store i32 1, ptr %88, align 8, !tbaa !13
  store i1 false, ptr %4, align 1
  store i32 1, ptr %8, align 4
  br label %122

89:                                               ; preds = %77
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.treemap1_node, ptr %91, i32 0, i32 4
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = getelementptr inbounds %struct.treemap1_node, ptr %93, i32 0, i32 5
  store ptr %90, ptr %94, align 8, !tbaa !23
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.treemap1_node, ptr %95, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  store ptr %97, ptr %9, align 8, !tbaa !5
  br label %119

98:                                               ; preds = %67
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call ptr @tm1_impl_new_node(ptr noundef %99, ptr noundef byval(%struct.struct_s) align 8 %1, ptr noundef byval(%struct.struct_s) align 8 %2)
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.treemap1_node, ptr %101, i32 0, i32 3
  store ptr %100, ptr %102, align 8, !tbaa !20
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.treemap1_node, ptr %103, i32 0, i32 3
  %105 = load ptr, ptr %104, align 8, !tbaa !20
  %106 = icmp ne ptr %105, null
  br i1 %106, label %110, label %107

107:                                              ; preds = %98
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.treemap1, ptr %108, i32 0, i32 2
  store i32 1, ptr %109, align 8, !tbaa !13
  store i1 false, ptr %4, align 1
  store i32 1, ptr %8, align 4
  br label %122

110:                                              ; preds = %98
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.treemap1_node, ptr %112, i32 0, i32 3
  %114 = load ptr, ptr %113, align 8, !tbaa !20
  %115 = getelementptr inbounds %struct.treemap1_node, ptr %114, i32 0, i32 5
  store ptr %111, ptr %115, align 8, !tbaa !23
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.treemap1_node, ptr %116, i32 0, i32 3
  %118 = load ptr, ptr %117, align 8, !tbaa !20
  store ptr %118, ptr %9, align 8, !tbaa !5
  br label %119

119:                                              ; preds = %110, %89
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  call void @tm1_impl_rebalance(ptr noundef %120, ptr noundef %121)
  store i32 0, ptr %8, align 4
  br label %122

122:                                              ; preds = %119, %107, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %123

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

125:                                              ; preds = %123
  br label %126

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

133:                                              ; preds = %126, %123, %21
  %134 = load i1, ptr %4, align 1
  ret i1 %134

135:                                              ; preds = %123
  unreachable
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @tm1_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 = !{!"treemap1", !6, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!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 = !{!"treemap1_fkey", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!18, !6, i64 224}
!18 = !{!"treemap1_node", !19, i64 0, !19, i64 104, !7, i64 208, !6, i64 216, !6, i64 224, !6, i64 232}
!19 = !{!"struct_s", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!20 = !{!18, !6, i64 216}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!18, !6, i64 232}
!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 @tm1_insert(ptr noundef %0, ptr noundef byval(%struct.struct_s) align 8 %1, ptr noundef byval(%struct.struct_s) align 8 %2) local_unnamed_addr #0 {
  %4 = tail call zeroext i1 @tm1_empty(ptr noundef %0)
  br i1 %4, label %5, label %7

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

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

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

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

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

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

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

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

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

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

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

.thread:                                          ; preds = %15, %30, %28, %5, %34
  %.sink56 = phi i32 [ 0, %34 ], [ 1, %5 ], [ 1, %28 ], [ 1, %30 ], [ 6, %15 ]
  %.2 = phi i1 [ true, %34 ], [ false, %5 ], [ false, %28 ], [ false, %30 ], [ false, %15 ]
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %.sink56, ptr %38, align 8, !tbaa !24
  ret i1 %.2
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @tm1_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 = !{!"treemap1", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!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 = !{!"treemap1_fkey", !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 224}
!19 = !{!"treemap1_node", !20, i64 0, !20, i64 104, !8, i64 208, !7, i64 216, !7, i64 224, !7, i64 232}
!20 = !{!"struct_s", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!21 = !{!19, !7, i64 216}
!22 = !{!19, !7, i64 232}
!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