; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z17test_aabb_vs_aabbRK6Aabb2dS1_)

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

%struct.Aabb2d = type { %union.Vec2, [2 x float] }
%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z17test_aabb_vs_aabbRK6Aabb2dS1_(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Aabb2d, ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds %struct.anon.1, ptr %7, i32 0, i32 0
  %9 = load float, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Aabb2d, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = fsub float %9, %13
  %15 = call float @llvm.fabs.f32(float %14)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Aabb2d, ptr %16, i32 0, i32 1
  %18 = getelementptr inbounds [2 x float], ptr %17, i64 0, i64 0
  %19 = load float, ptr %18, align 4, !tbaa !10
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Aabb2d, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds [2 x float], ptr %21, i64 0, i64 0
  %23 = load float, ptr %22, align 4, !tbaa !10
  %24 = fadd float %19, %23
  %25 = fcmp ogt float %15, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %50

27:                                               ; preds = %2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Aabb2d, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.anon.1, ptr %29, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Aabb2d, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.anon.1, ptr %33, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !9
  %36 = fsub float %31, %35
  %37 = call float @llvm.fabs.f32(float %36)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Aabb2d, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds [2 x float], ptr %39, i64 0, i64 1
  %41 = load float, ptr %40, align 4, !tbaa !10
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Aabb2d, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds [2 x float], ptr %43, i64 0, i64 1
  %45 = load float, ptr %44, align 4, !tbaa !10
  %46 = fadd float %41, %45
  %47 = fcmp ogt float %37, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %27
  store i1 false, ptr %3, align 1
  br label %50

49:                                               ; preds = %27
  store i1 true, ptr %3, align 1
  br label %50

50:                                               ; preds = %49, %48, %26
  %51 = load i1, ptr %3, align 1
  ret i1 %51
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_Z17test_aabb_vs_aabbRK6Aabb2dS1_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1) local_unnamed_addr #1 {
  %3 = load float, ptr %0, align 4, !tbaa !5
  %4 = load float, ptr %1, align 4, !tbaa !5
  %5 = fsub float %3, %4
  %6 = tail call float @llvm.fabs.f32(float %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load float, ptr %7, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load float, ptr %9, align 4, !tbaa !8
  %11 = fadd float %8, %10
  %12 = fcmp ogt float %6, %11
  br i1 %12, label %26, label %13

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 4
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = fsub float %15, %17
  %19 = tail call float @llvm.fabs.f32(float %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 12
  %21 = load float, ptr %20, align 4, !tbaa !8
  %22 = getelementptr inbounds i8, ptr %1, i64 12
  %23 = load float, ptr %22, align 4, !tbaa !8
  %24 = fadd float %21, %23
  %25 = fcmp ule float %19, %24
  br label %26

26:                                               ; preds = %13, %2
  %.0 = phi i1 [ false, %2 ], [ %25, %13 ]
  ret i1 %.0
}

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

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


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