; LLVM IR from heroseh/cgm :: cgm (cgm_2d_aabb_vs_aabb)

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

%union.CgmAabb2d = type { %struct.anon.2 }
%struct.anon.2 = type { float, float, float, float }
%union.CgmVec2 = type { %struct.anon }
%struct.anon = type { float, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @CgmAabb2d_half_size(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @CgmAabb2d_center(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_2d_aabb_vs_aabb(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %union.CgmAabb2d, align 4
  %10 = alloca %union.CgmVec2, align 4
  %11 = alloca %union.CgmVec2, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %12, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call <2 x float> @CgmAabb2d_half_size(ptr noundef %13)
  %15 = getelementptr inbounds %union.CgmVec2, ptr %10, i32 0, i32 0
  store <2 x float> %14, ptr %15, align 4
  %16 = getelementptr inbounds %struct.anon, ptr %10, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !10
  %18 = getelementptr inbounds %struct.anon.2, ptr %9, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !10
  %20 = fsub float %19, %17
  store float %20, ptr %18, align 4, !tbaa !10
  %21 = getelementptr inbounds %struct.anon, ptr %10, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !10
  %23 = getelementptr inbounds %struct.anon.2, ptr %9, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !10
  %25 = fsub float %24, %22
  store float %25, ptr %23, align 4, !tbaa !10
  %26 = getelementptr inbounds %struct.anon, ptr %10, i32 0, i32 0
  %27 = load float, ptr %26, align 4, !tbaa !10
  %28 = getelementptr inbounds %struct.anon.2, ptr %9, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !10
  %30 = fadd float %29, %27
  store float %30, ptr %28, align 4, !tbaa !10
  %31 = getelementptr inbounds %struct.anon, ptr %10, i32 0, i32 1
  %32 = load float, ptr %31, align 4, !tbaa !10
  %33 = getelementptr inbounds %struct.anon.2, ptr %9, i32 0, i32 3
  %34 = load float, ptr %33, align 4, !tbaa !10
  %35 = fadd float %34, %32
  store float %35, ptr %33, align 4, !tbaa !10
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call <2 x float> @CgmAabb2d_center(ptr noundef %36)
  %38 = getelementptr inbounds %union.CgmVec2, ptr %11, i32 0, i32 0
  store <2 x float> %37, ptr %38, align 4
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %union.CgmVec2, ptr %11, i32 0, i32 0
  %42 = load <2 x float>, ptr %41, align 4
  %43 = call zeroext i8 @cgm_2d_aabb_vs_pt(ptr noundef %9, <2 x float> %42, ptr noundef %39, ptr noundef %40)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  ret i8 %43
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @cgm_2d_aabb_vs_pt(ptr noundef, <2 x float>, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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/C++ TBAA"}
!9 = !{i64 0, i64 16, !10}
!10 = !{!7, !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"

%union.CgmAabb2d = type { %struct.anon.2 }
%struct.anon.2 = type { float, float, float, float }

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @CgmAabb2d_half_size(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @CgmAabb2d_center(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_2d_aabb_vs_aabb(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca %union.CgmAabb2d, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(16) %1, i64 16, i1 false), !tbaa.struct !5
  %6 = tail call <2 x float> @CgmAabb2d_half_size(ptr noundef %0)
  %7 = shufflevector <2 x float> %6, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %8 = load <4 x float>, ptr %5, align 16, !tbaa !6
  %9 = fsub <4 x float> %8, %7
  %10 = fadd <4 x float> %8, %7
  %11 = shufflevector <4 x float> %9, <4 x float> %10, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
  store <4 x float> %11, ptr %5, align 16, !tbaa !6
  %12 = tail call <2 x float> @CgmAabb2d_center(ptr noundef %0)
  %13 = call zeroext i8 @cgm_2d_aabb_vs_pt(ptr noundef nonnull %5, <2 x float> %12, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  ret i8 %13
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @cgm_2d_aabb_vs_pt(ptr noundef, <2 x float>, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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 = !{i64 0, i64 16, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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