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

; 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.vmath::vec3" = type { float, float, float }
%class.AABB = type { %"class.vmath::vec3", double, double, double }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4AABB11_axisTestY1EN5vmath4vec3ES1_dddd(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, ptr noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6) #2 align 2 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store double %3, ptr %12, align 8, !tbaa !9
  store double %4, ptr %13, align 8, !tbaa !9
  store double %5, ptr %14, align 8, !tbaa !9
  store double %6, ptr %15, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %23 = load double, ptr %12, align 8, !tbaa !9
  %24 = fneg double %23
  %25 = fptrunc double %24 to float
  %26 = getelementptr inbounds %"class.vmath::vec3", ptr %1, i32 0, i32 0
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = load double, ptr %13, align 8, !tbaa !9
  %29 = fptrunc double %28 to float
  %30 = getelementptr inbounds %"class.vmath::vec3", ptr %1, i32 0, i32 2
  %31 = load float, ptr %30, align 4, !tbaa !14
  %32 = fmul float %29, %31
  %33 = call float @llvm.fmuladd.f32(float %25, float %27, float %32)
  %34 = fpext float %33 to double
  store double %34, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %35 = load double, ptr %12, align 8, !tbaa !9
  %36 = fneg double %35
  %37 = fptrunc double %36 to float
  %38 = getelementptr inbounds %"class.vmath::vec3", ptr %2, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !11
  %40 = load double, ptr %13, align 8, !tbaa !9
  %41 = fptrunc double %40 to float
  %42 = getelementptr inbounds %"class.vmath::vec3", ptr %2, i32 0, i32 2
  %43 = load float, ptr %42, align 4, !tbaa !14
  %44 = fmul float %41, %43
  %45 = call float @llvm.fmuladd.f32(float %37, float %39, float %44)
  %46 = fpext float %45 to double
  store double %46, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %47 = load double, ptr %16, align 8, !tbaa !9
  %48 = load double, ptr %17, align 8, !tbaa !9
  %49 = fcmp olt double %47, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %7
  %51 = load double, ptr %16, align 8, !tbaa !9
  store double %51, ptr %18, align 8, !tbaa !9
  %52 = load double, ptr %17, align 8, !tbaa !9
  store double %52, ptr %19, align 8, !tbaa !9
  br label %56

53:                                               ; preds = %7
  %54 = load double, ptr %17, align 8, !tbaa !9
  store double %54, ptr %18, align 8, !tbaa !9
  %55 = load double, ptr %16, align 8, !tbaa !9
  store double %55, ptr %19, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %53, %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %57 = getelementptr inbounds %class.AABB, ptr %22, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = fmul double 5.000000e-01, %58
  %60 = load double, ptr %14, align 8, !tbaa !9
  %61 = getelementptr inbounds %class.AABB, ptr %22, i32 0, i32 3
  %62 = load double, ptr %61, align 8, !tbaa !17
  %63 = fmul double 5.000000e-01, %62
  %64 = load double, ptr %15, align 8, !tbaa !9
  %65 = fmul double %63, %64
  %66 = call double @llvm.fmuladd.f64(double %59, double %60, double %65)
  store double %66, ptr %20, align 8, !tbaa !9
  %67 = load double, ptr %18, align 8, !tbaa !9
  %68 = load double, ptr %20, align 8, !tbaa !9
  %69 = fcmp ogt double %67, %68
  br i1 %69, label %75, label %70

70:                                               ; preds = %56
  %71 = load double, ptr %19, align 8, !tbaa !9
  %72 = load double, ptr %20, align 8, !tbaa !9
  %73 = fneg double %72
  %74 = fcmp olt double %71, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %70, %56
  store i1 false, ptr %8, align 1
  store i32 1, ptr %21, align 4
  br label %77

76:                                               ; preds = %70
  store i1 true, ptr %8, align 1
  store i32 1, ptr %21, align 4
  br label %77

77:                                               ; preds = %76, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %78 = load i1, ptr %8, align 1
  ret i1 %78
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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" }
attributes #3 = { 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 = !{!"_ZTSN5vmath4vec3E", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!16, !10, i64 16}
!16 = !{!"_ZTS4AABB", !12, i64 0, !10, i64 16, !10, i64 24, !10, i64 32}
!17 = !{!16, !10, i64 32}


; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_ZN4AABB11_axisTestY1EN5vmath4vec3ES1_dddd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6) local_unnamed_addr #1 align 2 {
  %8 = fptrunc double %3 to float
  %9 = fneg float %8
  %10 = load float, ptr %1, align 4, !tbaa !5
  %11 = fptrunc double %4 to float
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load float, ptr %12, align 4, !tbaa !10
  %14 = load float, ptr %2, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  %16 = load float, ptr %15, align 4, !tbaa !10
  %17 = insertelement <2 x float> poison, float %13, i64 0
  %18 = insertelement <2 x float> %17, float %16, i64 1
  %19 = insertelement <2 x float> poison, float %11, i64 0
  %20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
  %21 = fmul <2 x float> %18, %20
  %22 = insertelement <2 x float> poison, float %9, i64 0
  %23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
  %24 = insertelement <2 x float> poison, float %10, i64 0
  %25 = insertelement <2 x float> %24, float %14, i64 1
  %26 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %23, <2 x float> %25, <2 x float> %21)
  %27 = extractelement <2 x float> %26, i64 0
  %28 = fpext float %27 to double
  %29 = extractelement <2 x float> %26, i64 1
  %30 = fpext float %29 to double
  %31 = fcmp olt float %27, %29
  %. = select i1 %31, double %28, double %30
  %.24 = select i1 %31, double %30, double %28
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = fmul double %33, 5.000000e-01
  %35 = getelementptr inbounds i8, ptr %0, i64 32
  %36 = load double, ptr %35, align 8, !tbaa !14
  %37 = fmul double %36, 5.000000e-01
  %38 = fmul double %37, %6
  %39 = tail call double @llvm.fmuladd.f64(double %34, double %5, double %38)
  %40 = fcmp ule double %., %39
  %41 = fneg double %39
  %42 = fcmp uge double %.24, %41
  %or.cond.not = and i1 %40, %42
  ret i1 %or.cond.not
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"_ZTSN5vmath4vec3E", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !13, i64 16}
!12 = !{!"_ZTS4AABB", !6, i64 0, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"double", !8, i64 0}
!14 = !{!12, !13, i64 32}


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