; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/aabb.ll (ZN4AABB11_axisTestX2EN5vmath4vec3ES1_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_axisTestX2EN5vmath4vec3ES1_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 = fptrunc double %23 to float
  %25 = getelementptr inbounds %"class.vmath::vec3", ptr %1, i32 0, i32 1
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = load double, ptr %13, align 8, !tbaa !9
  %28 = fptrunc double %27 to float
  %29 = getelementptr inbounds %"class.vmath::vec3", ptr %1, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = fmul float %28, %30
  %32 = fneg float %31
  %33 = call float @llvm.fmuladd.f32(float %24, float %26, 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 = fptrunc double %35 to float
  %37 = getelementptr inbounds %"class.vmath::vec3", ptr %2, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = load double, ptr %13, align 8, !tbaa !9
  %40 = fptrunc double %39 to float
  %41 = getelementptr inbounds %"class.vmath::vec3", ptr %2, i32 0, i32 2
  %42 = load float, ptr %41, align 4, !tbaa !14
  %43 = fmul float %40, %42
  %44 = fneg float %43
  %45 = call float @llvm.fmuladd.f32(float %36, float %38, 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 2
  %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 4}
!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 24}
!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_axisTestX2EN5vmath4vec3ES1_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 = getelementptr inbounds i8, ptr %1, i64 4
  %10 = load float, ptr %9, 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 = getelementptr inbounds i8, ptr %2, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  %17 = load float, ptr %16, align 4, !tbaa !10
  %18 = insertelement <2 x float> poison, float %13, i64 0
  %19 = insertelement <2 x float> %18, float %17, i64 1
  %20 = fneg <2 x float> %19
  %21 = insertelement <2 x float> poison, float %11, i64 0
  %22 = shufflevector <2 x float> %21, <2 x float> poison, <2 x i32> zeroinitializer
  %23 = fmul <2 x float> %22, %20
  %24 = insertelement <2 x float> poison, float %8, i64 0
  %25 = shufflevector <2 x float> %24, <2 x float> poison, <2 x i32> zeroinitializer
  %26 = insertelement <2 x float> poison, float %10, i64 0
  %27 = insertelement <2 x float> %26, float %15, i64 1
  %28 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %25, <2 x float> %27, <2 x float> %23)
  %29 = extractelement <2 x float> %28, i64 0
  %30 = fpext float %29 to double
  %31 = extractelement <2 x float> %28, i64 1
  %32 = fpext float %31 to double
  %33 = fcmp olt float %29, %31
  %. = select i1 %33, double %30, double %32
  %.24 = select i1 %33, double %32, double %30
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fmul double %35, 5.000000e-01
  %37 = getelementptr inbounds i8, ptr %0, i64 32
  %38 = load double, ptr %37, align 8, !tbaa !14
  %39 = fmul double %38, 5.000000e-01
  %40 = fmul double %39, %6
  %41 = tail call double @llvm.fmuladd.f64(double %36, double %5, double %40)
  %42 = fcmp ule double %., %41
  %43 = fneg double %41
  %44 = fcmp uge double %.24, %43
  %or.cond.not = and i1 %42, %44
  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 4}
!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 24}
!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