; LLVM IR from nikitakaraevv/ray-tracing-engine :: source/AABB.ll (ZNK4AABB12isInsideTestERK4Vec3IfE)

; 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.AABB = type { %class.Vec3, %class.Vec3 }
%class.Vec3 = type { [3 x float] }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK4AABB12isInsideTestERK4Vec3IfE(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %37, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 3
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %40

13:                                               ; preds = %9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %14, i32 noundef %15)
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = getelementptr inbounds %class.AABB, ptr %8, i32 0, i32 0
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %18, i32 noundef %19)
  %21 = load float, ptr %20, align 4, !tbaa !11
  %22 = fsub float %21, 0x3EB4000000000000
  %23 = fcmp olt float %17, %22
  br i1 %23, label %35, label %24

24:                                               ; preds = %13
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %25, i32 noundef %26)
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = getelementptr inbounds %class.AABB, ptr %8, i32 0, i32 1
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %29, i32 noundef %30)
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = fadd float %32, 0x3EB4000000000000
  %34 = fcmp ogt float %28, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %24, %13
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %40

36:                                               ; preds = %24
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !13

40:                                               ; preds = %35, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %41 = load i32, ptr %7, align 4
  switch i32 %41, label %45 [
    i32 2, label %42
    i32 1, label %43
  ]

42:                                               ; preds = %40
  store i1 true, ptr %3, align 1
  br label %43

43:                                               ; preds = %42, %40
  %44 = load i1, ptr %3, align 1
  ret i1 %44

45:                                               ; preds = %40
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4AABB12isInsideTestERK4Vec3IfE(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 0)
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = fadd float %7, 0xBEB4000000000000
  %9 = fcmp olt float %5, %8
  br i1 %9, label %46, label %39

10:                                               ; preds = %39
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 1)
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = fadd float %14, 0xBEB4000000000000
  %16 = fcmp olt float %12, %15
  br i1 %16, label %46, label %17

17:                                               ; preds = %10
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 1)
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %3, i32 noundef 1)
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = fadd float %21, 0x3EB4000000000000
  %23 = fcmp ogt float %19, %22
  br i1 %23, label %46, label %24

24:                                               ; preds = %17
  %25 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 2)
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = fadd float %28, 0xBEB4000000000000
  %30 = fcmp olt float %26, %29
  br i1 %30, label %46, label %31

31:                                               ; preds = %24
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 2)
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %3, i32 noundef 2)
  %35 = load float, ptr %34, align 4, !tbaa !5
  %36 = fadd float %35, 0x3EB4000000000000
  %37 = fcmp ogt float %33, %36
  br i1 %37, label %46, label %38

38:                                               ; preds = %31
  br label %46

39:                                               ; preds = %2
  %40 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 0)
  %41 = load float, ptr %40, align 4, !tbaa !5
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %3, i32 noundef 0)
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = fadd float %43, 0x3EB4000000000000
  %45 = fcmp ogt float %41, %44
  br i1 %45, label %46, label %10

46:                                               ; preds = %38, %31, %24, %17, %10, %2, %39
  %.lcssa = phi i1 [ false, %2 ], [ false, %39 ], [ false, %10 ], [ false, %17 ], [ false, %24 ], [ false, %31 ], [ true, %38 ]
  ret i1 %.lcssa
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK4Vec3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

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" }
attributes #1 = { inlinehint 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass