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

%class.bst_sorted_list = type { i32, i32, 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: mustprogress uwtable
declare dso_local noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15bst_sorted_list8add_NodeERKiRKdd(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, double noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = sitofp i32 %15 to double
  %17 = fmul double %13, %16
  %18 = fptosi double %17 to i32
  %19 = sext i32 %18 to i64
  store i64 %19, ptr %9, align 8, !tbaa !14
  %20 = load double, ptr %8, align 8, !tbaa !9
  %21 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = sitofp i32 %22 to double
  %24 = fmul double %20, %23
  %25 = fptosi double %24 to i32
  %26 = sext i32 %25 to i64
  store i64 %26, ptr %10, align 8, !tbaa !14
  %27 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %36

30:                                               ; preds = %4
  %31 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef %32, ptr noundef nonnull align 4 dereferenceable(4) %33, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %35 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 3
  store ptr %34, ptr %35, align 8, !tbaa !17
  br label %41

36:                                               ; preds = %4
  %37 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef %38, ptr noundef nonnull align 4 dereferenceable(4) %39, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  br label %41

41:                                               ; preds = %36, %30
  %42 = getelementptr inbounds %class.bst_sorted_list, ptr %11, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !16
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %42, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS15bst_sorted_list", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !13, i64 4}
!17 = !{!12, !6, 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 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 uwtable
declare dso_local noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15bst_sorted_list8add_NodeERKiRKdd(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %2, double noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #2
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = load i32, ptr %0, align 8, !tbaa !9
  %9 = sitofp i32 %8 to double
  %10 = fmul double %7, %9
  %11 = fptosi double %10 to i32
  %12 = sext i32 %11 to i64
  store i64 %12, ptr %5, align 8, !tbaa !13
  %13 = fmul double %9, %3
  %14 = fptosi double %13 to i32
  %15 = sext i32 %14 to i64
  store i64 %15, ptr %6, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %18 = icmp eq i32 %17, 0
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = call noundef ptr @_ZN15bst_sorted_list6insertEP8bst_NodeRKiRKlS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %20, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %18, label %22, label %23

22:                                               ; preds = %4
  store ptr %21, ptr %19, align 8, !tbaa !16
  br label %23

23:                                               ; preds = %4, %22
  %24 = load i32, ptr %16, align 4, !tbaa !15
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %16, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #2
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS15bst_sorted_list", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !11, i64 4}
!16 = !{!10, !12, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass