; 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 }

; 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
declare hidden ptr @ts1_impl_get_node(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) #1

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

21:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %103

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

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

29:                                               ; preds = %26
  %30 = load i8, ptr %7, align 1, !tbaa !15, !range !17, !noundef !18
  %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 !19
  %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 !19
  store ptr %41, ptr %6, align 8, !tbaa !5
  br label %33, !llvm.loop !22

42:                                               ; preds = %33
  br label %43

43:                                               ; preds = %42, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.treeset1_node, ptr %45, i32 0, i32 0
  %47 = call ptr @ts1_impl_get_node(ptr noundef %44, ptr noundef byval(%struct.struct_s) align 8 %46)
  store ptr %47, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

50:                                               ; preds = %43
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %98

51:                                               ; preds = %43
  store i8 1, ptr %7, align 1, !tbaa !15
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.treeset1_node, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !24
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %60

56:                                               ; preds = %51
  store i8 0, ptr %7, align 1, !tbaa !15
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.treeset1_node, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !24
  store ptr %59, ptr %6, align 8, !tbaa !5
  br label %97

60:                                               ; preds = %51
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.treeset1_node, ptr %61, i32 0, i32 4
  %63 = load ptr, ptr %62, align 8, !tbaa !25
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %95

65:                                               ; preds = %60
  br label %66

66:                                               ; preds = %81, %65
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.treeset1_node, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !25
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %79

71:                                               ; preds = %66
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %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 !25
  %76 = getelementptr inbounds %struct.treeset1_node, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %76, align 8, !tbaa !24
  %78 = icmp eq ptr %72, %77
  br label %79

79:                                               ; preds = %71, %66
  %80 = phi i1 [ false, %66 ], [ %78, %71 ]
  br i1 %80, label %81, label %85

81:                                               ; preds = %79
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.treeset1_node, ptr %82, i32 0, i32 4
  %84 = load ptr, ptr %83, align 8, !tbaa !25
  store ptr %84, ptr %6, align 8, !tbaa !5
  br label %66, !llvm.loop !26

85:                                               ; preds = %79
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.treeset1_node, ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !25
  %89 = icmp ne ptr %88, null
  br i1 %89, label %91, label %90

90:                                               ; preds = %85
  store i32 3, ptr %9, align 4
  br label %98

91:                                               ; preds = %85
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.treeset1_node, ptr %92, i32 0, i32 4
  %94 = load ptr, ptr %93, align 8, !tbaa !25
  store ptr %94, ptr %6, align 8, !tbaa !5
  br label %96

95:                                               ; preds = %60
  store i32 3, ptr %9, align 4
  br label %98

96:                                               ; preds = %91
  br label %97

97:                                               ; preds = %96, %56
  store i32 0, ptr %9, align 4
  br label %98

98:                                               ; preds = %97, %95, %90, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %99 = load i32, ptr %9, align 4
  switch i32 %99, label %102 [
    i32 0, label %100
    i32 3, label %101
  ]

100:                                              ; preds = %98
  br label %26, !llvm.loop !27

101:                                              ; preds = %98, %26
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %102

102:                                              ; preds = %101, %98
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %103

103:                                              ; preds = %102, %21
  %104 = load i1, ptr %3, align 1
  ret i1 %104
}

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


; 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
declare hidden ptr @ts1_impl_get_node(ptr noundef, ptr noundef byval(%struct.struct_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @ts1_equals(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %.not = icmp eq i64 %6, %8
  br i1 %.not, label %9, label %.thread44

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

.lr.ph:                                           ; preds = %9, %.lr.ph.backedge
  %.02354 = phi i1 [ %.not36, %.lr.ph.backedge ], [ false, %9 ]
  %.02653 = phi ptr [ %.02653.be, %.lr.ph.backedge ], [ %10, %9 ]
  br i1 %.02354, label %.loopexit, label %.preheader49

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

.loopexit:                                        ; preds = %.preheader49, %.lr.ph
  %.228 = phi ptr [ %.02653, %.lr.ph ], [ %.127, %.preheader49 ]
  %13 = tail call ptr @ts1_impl_get_node(ptr noundef %1, ptr noundef nonnull byval(%struct.struct_s) align 8 %.228)
  %.not63 = icmp ne ptr %13, null
  br i1 %.not63, label %14, label %.thread44

14:                                               ; preds = %.loopexit
  %15 = getelementptr inbounds i8, ptr %.228, i64 112
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %.not36 = icmp eq ptr %16, null
  br i1 %.not36, label %17, label %.lr.ph.backedge

.lr.ph.backedge:                                  ; preds = %22, %14
  %.02653.be = phi ptr [ %16, %14 ], [ %21, %22 ]
  br label %.lr.ph

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %.228, i64 128
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %.not37 = icmp eq ptr %19, null
  br i1 %.not37, label %.thread44, label %.preheader

.preheader:                                       ; preds = %17, %22
  %.329 = phi ptr [ %21, %22 ], [ %.228, %17 ]
  %20 = getelementptr inbounds i8, ptr %.329, i64 128
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  %.not38 = icmp eq ptr %21, null
  br i1 %.not38, label %.thread44, label %22

22:                                               ; preds = %.preheader
  %23 = getelementptr inbounds i8, ptr %21, i64 112
  %24 = load ptr, ptr %23, align 8, !tbaa !19
  %25 = icmp eq ptr %.329, %24
  br i1 %25, label %.preheader, label %.lr.ph.backedge, !llvm.loop !21

.thread44:                                        ; preds = %.loopexit, %17, %.preheader, %9, %2
  %.3 = phi i1 [ false, %2 ], [ true, %9 ], [ true, %.preheader ], [ %.not63, %17 ], [ %.not63, %.loopexit ]
  ret i1 %.3
}

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" }

!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, !11, i64 16}
!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, !10, i64 8}
!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 = !{!15, !7, i64 112}
!20 = !{!15, !7, i64 128}
!21 = distinct !{!21, !18}


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