; LLVM IR from heroseh/cgm :: cgm (cgm_3d_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.CgmAabb3d = type { %struct.anon.5 }
%struct.anon.5 = type { float, float, float, float, float, float }
%union.CgmVec3 = type { %struct.anon.0 }
%struct.anon.0 = type { float, 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>, float } @CgmAabb3d_half_size(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local { <2 x float>, float } @CgmAabb3d_center(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_3d_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.CgmAabb3d, align 4
  %10 = alloca %union.CgmVec3, align 4
  %11 = alloca { <2 x float>, float }, align 8
  %12 = alloca %union.CgmVec3, align 4
  %13 = alloca { <2 x float>, float }, align 8
  %14 = alloca { <2 x float>, float }, 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 24, ptr %9) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %15, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call { <2 x float>, float } @CgmAabb3d_half_size(ptr noundef %16)
  %18 = getelementptr inbounds %union.CgmVec3, ptr %10, i32 0, i32 0
  store { <2 x float>, float } %17, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 8 %11, i64 12, i1 false)
  %19 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !10
  %21 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !10
  %23 = fsub float %22, %20
  store float %23, ptr %21, align 4, !tbaa !10
  %24 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !10
  %26 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 1
  %27 = load float, ptr %26, align 4, !tbaa !10
  %28 = fsub float %27, %25
  store float %28, ptr %26, align 4, !tbaa !10
  %29 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !10
  %31 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 2
  %32 = load float, ptr %31, align 4, !tbaa !10
  %33 = fsub float %32, %30
  store float %33, ptr %31, align 4, !tbaa !10
  %34 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !10
  %36 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 3
  %37 = load float, ptr %36, align 4, !tbaa !10
  %38 = fadd float %37, %35
  store float %38, ptr %36, align 4, !tbaa !10
  %39 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !10
  %41 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 4
  %42 = load float, ptr %41, align 4, !tbaa !10
  %43 = fadd float %42, %40
  store float %43, ptr %41, align 4, !tbaa !10
  %44 = getelementptr inbounds %struct.anon.0, ptr %10, i32 0, i32 2
  %45 = load float, ptr %44, align 4, !tbaa !10
  %46 = getelementptr inbounds %struct.anon.5, ptr %9, i32 0, i32 5
  %47 = load float, ptr %46, align 4, !tbaa !10
  %48 = fadd float %47, %45
  store float %48, ptr %46, align 4, !tbaa !10
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call { <2 x float>, float } @CgmAabb3d_center(ptr noundef %49)
  %51 = getelementptr inbounds %union.CgmVec3, ptr %12, i32 0, i32 0
  store { <2 x float>, float } %50, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %51, ptr align 8 %13, i64 12, i1 false)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %12, i64 12, i1 false)
  %54 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 0
  %55 = load <2 x float>, ptr %54, align 4
  %56 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 1
  %57 = load float, ptr %56, align 4
  %58 = call zeroext i8 @cgm_3d_aabb_vs_pt(ptr noundef %9, <2 x float> %55, float %57, ptr noundef %52, ptr noundef %53)
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  ret i8 %58
}

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 24, !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.CgmAabb3d = type { %struct.anon.5 }
%struct.anon.5 = type { float, float, 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>, float } @CgmAabb3d_half_size(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_3d_aabb_vs_aabb(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca %union.CgmAabb3d, align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %5, ptr noundef nonnull align 4 dereferenceable(24) %1, i64 24, i1 false), !tbaa.struct !5
  %6 = tail call { <2 x float>, float } @CgmAabb3d_half_size(ptr noundef %0)
  %.fca.0.extract5 = extractvalue { <2 x float>, float } %6, 0
  %.fca.1.extract6 = extractvalue { <2 x float>, float } %6, 1
  %7 = load <4 x float>, ptr %5, align 16, !tbaa !6
  %8 = shufflevector <2 x float> %.fca.0.extract5, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 0>
  %9 = insertelement <4 x float> %8, float %.fca.1.extract6, i64 2
  %10 = fsub <4 x float> %7, %9
  %11 = fadd <4 x float> %7, %9
  %12 = shufflevector <4 x float> %10, <4 x float> %11, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
  store <4 x float> %12, ptr %5, align 16, !tbaa !6
  %13 = getelementptr inbounds i8, ptr %5, i64 16
  %14 = load <2 x float>, ptr %13, align 16, !tbaa !6
  %15 = shufflevector <2 x float> %.fca.0.extract5, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %16 = insertelement <2 x float> %15, float %.fca.1.extract6, i64 1
  %17 = fadd <2 x float> %16, %14
  store <2 x float> %17, ptr %13, align 16, !tbaa !6
  %18 = tail call { <2 x float>, float } @CgmAabb3d_center(ptr noundef %0)
  %.fca.0.extract = extractvalue { <2 x float>, float } %18, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %18, 1
  %19 = call zeroext i8 @cgm_3d_aabb_vs_pt(ptr noundef nonnull %5, <2 x float> %.fca.0.extract, float %.fca.1.extract, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  ret i8 %19
}

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 24, !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