; LLVM IR from Samson-Mano/Truss_static_analysis_cpp :: Truss_static_analysis_cpp/src/geometry_store (bst_sorted_list)

; 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.bst_Node = type { i32, i64, i64, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN15bst_sorted_list7newNodeERKiRKlS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %20

15:                                               ; preds = %5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = call noundef ptr @_ZN15bst_sorted_list7newNodeERKiRKlS3_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %18)
  store ptr %19, ptr %6, align 8
  br label %93

20:                                               ; preds = %5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.bst_Node, ptr %23, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = icmp slt i64 %22, %25
  br i1 %26, label %27, label %37

27:                                               ; preds = %20
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.bst_Node, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %30, ptr noundef nonnull align 4 dereferenceable(4) %31, ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef nonnull align 8 dereferenceable(8) %33)
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bst_Node, ptr %35, i32 0, i32 3
  store ptr %34, ptr %36, align 8, !tbaa !14
  br label %91

37:                                               ; preds = %20
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.bst_Node, ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !11
  %43 = icmp sgt i64 %39, %42
  br i1 %43, label %44, label %54

44:                                               ; preds = %37
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.bst_Node, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %47, ptr noundef nonnull align 4 dereferenceable(4) %48, ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef nonnull align 8 dereferenceable(8) %50)
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.bst_Node, ptr %52, i32 0, i32 4
  store ptr %51, ptr %53, align 8, !tbaa !15
  br label %90

54:                                               ; preds = %37
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.bst_Node, ptr %57, i32 0, i32 2
  %59 = load i64, ptr %58, align 8, !tbaa !16
  %60 = icmp slt i64 %56, %59
  br i1 %60, label %61, label %71

61:                                               ; preds = %54
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.bst_Node, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %64, ptr noundef nonnull align 4 dereferenceable(4) %65, ptr noundef nonnull align 8 dereferenceable(8) %66, ptr noundef nonnull align 8 dereferenceable(8) %67)
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.bst_Node, ptr %69, i32 0, i32 3
  store ptr %68, ptr %70, align 8, !tbaa !14
  br label %89

71:                                               ; preds = %54
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.bst_Node, ptr %74, i32 0, i32 2
  %76 = load i64, ptr %75, align 8, !tbaa !16
  %77 = icmp sgt i64 %73, %76
  br i1 %77, label %78, label %88

78:                                               ; preds = %71
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.bst_Node, ptr %79, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %81, ptr noundef nonnull align 4 dereferenceable(4) %82, ptr noundef nonnull align 8 dereferenceable(8) %83, ptr noundef nonnull align 8 dereferenceable(8) %84)
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.bst_Node, ptr %86, i32 0, i32 4
  store ptr %85, ptr %87, align 8, !tbaa !15
  br label %88

88:                                               ; preds = %78, %71
  br label %89

89:                                               ; preds = %88, %61
  br label %90

90:                                               ; preds = %89, %44
  br label %91

91:                                               ; preds = %90, %27
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %92, ptr %6, align 8
  br label %93

93:                                               ; preds = %91, %15
  %94 = load ptr, ptr %6, align 8
  ret ptr %94
}

attributes #0 = { mustprogress 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS8bst_Node", !13, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 32}
!16 = !{!12, !10, 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN15bst_sorted_list7newNodeERKiRKlS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) local_unnamed_addr #0 align 2 {
  %6 = icmp eq ptr %1, null
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call noundef ptr @_ZN15bst_sorted_list7newNodeERKiRKlS3_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br label %common.ret40

9:                                                ; preds = %5
  %10 = load i64, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = icmp slt i64 %10, %12
  br i1 %13, label %14, label %18

common.ret40:                                     ; preds = %33, %7, %35, %29, %20, %14
  %common.ret40.op = phi ptr [ %1, %14 ], [ %1, %20 ], [ %1, %29 ], [ %1, %35 ], [ %8, %7 ], [ %1, %33 ]
  ret ptr %common.ret40.op

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = tail call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %16, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %17, ptr %15, align 8, !tbaa !13
  br label %common.ret40

18:                                               ; preds = %9
  %19 = icmp sgt i64 %10, %12
  br i1 %19, label %20, label %24

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = tail call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %22, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %23, ptr %21, align 8, !tbaa !14
  br label %common.ret40

24:                                               ; preds = %18
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 16
  %27 = load i64, ptr %26, align 8, !tbaa !15
  %28 = icmp slt i64 %25, %27
  br i1 %28, label %29, label %33

29:                                               ; preds = %24
  %30 = getelementptr inbounds i8, ptr %1, i64 24
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = tail call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %31, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %32, ptr %30, align 8, !tbaa !13
  br label %common.ret40

33:                                               ; preds = %24
  %34 = icmp sgt i64 %25, %27
  br i1 %34, label %35, label %common.ret40

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %1, i64 32
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = tail call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %37, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  store ptr %38, ptr %36, align 8, !tbaa !14
  br label %common.ret40
}

attributes #0 = { mustprogress 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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS8bst_Node", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !12, i64 24}
!14 = !{!10, !12, i64 32}
!15 = !{!10, !6, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass