; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/aabb.ll (ZN4AABB11_findminmaxEdddPdS0_)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4AABB11_findminmaxEdddPdS0_(ptr noundef nonnull align 8 dereferenceable(40) %0, double noundef %1, double noundef %2, double noundef %3, ptr noundef %4, ptr noundef %5) #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !9
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8
  %14 = load double, ptr %8, align 8, !tbaa !9
  %15 = load ptr, ptr %12, align 8, !tbaa !5
  store double %14, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  store double %14, ptr %16, align 8, !tbaa !9
  %17 = load double, ptr %9, align 8, !tbaa !9
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fcmp olt double %17, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %6
  %22 = load double, ptr %9, align 8, !tbaa !9
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  store double %22, ptr %23, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %21, %6
  %25 = load double, ptr %9, align 8, !tbaa !9
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fcmp ogt double %25, %27
  br i1 %28, label %29, label %32

29:                                               ; preds = %24
  %30 = load double, ptr %9, align 8, !tbaa !9
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  store double %30, ptr %31, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %29, %24
  %33 = load double, ptr %10, align 8, !tbaa !9
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fcmp olt double %33, %35
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  store double %38, ptr %39, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %37, %32
  %41 = load double, ptr %10, align 8, !tbaa !9
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fcmp ogt double %41, %43
  br i1 %44, label %45, label %48

45:                                               ; preds = %40
  %46 = load double, ptr %10, align 8, !tbaa !9
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  store double %46, ptr %47, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %45, %40
  ret void
}

attributes #0 = { mustprogress 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, !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}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4AABB11_findminmaxEdddPdS0_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(40) %0, double noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef %4, ptr nocapture noundef %5) local_unnamed_addr #0 align 2 {
  store double %1, ptr %5, align 8, !tbaa !5
  %7 = fcmp olt double %2, %1
  %storemerge = select i1 %7, double %2, double %1
  store double %storemerge, ptr %4, align 8, !tbaa !5
  %8 = load double, ptr %5, align 8, !tbaa !5
  %9 = fcmp olt double %8, %2
  br i1 %9, label %10, label %11

10:                                               ; preds = %6
  store double %2, ptr %5, align 8, !tbaa !5
  %.pre = load double, ptr %4, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %6
  %12 = phi double [ %2, %10 ], [ %8, %6 ]
  %13 = phi double [ %.pre, %10 ], [ %storemerge, %6 ]
  %14 = fcmp ogt double %13, %3
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  store double %3, ptr %4, align 8, !tbaa !5
  %.pre22 = load double, ptr %5, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %11
  %17 = phi double [ %.pre22, %15 ], [ %12, %11 ]
  %18 = fcmp olt double %17, %3
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store double %3, ptr %5, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %19, %16
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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