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

; 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.CgmVec3 = type { %struct.anon.0 }
%struct.anon.0 = type { float, float, float }
%struct.CgmSphere = type { %union.anon.7, float }
%union.anon.7 = type { %struct.anon.8 }
%struct.anon.8 = type { float, float, float }
%struct.CgmHoop3d = type { %union.CgmVec3, %union.CgmVec3, %union.CgmVec3, 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 } @CgmHoop3d_closest_pt(ptr noundef, <2 x float>, float) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @cgm_3d_sphere_vs_sphere(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

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 12, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 40}
!12 = !{!"CgmHoop3d", !7, i64 0, !7, i64 12, !7, i64 24, !13, i64 36, !13, i64 40}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !13, i64 12}
!15 = !{!"CgmSphere", !7, i64 0, !13, i64 12}


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

%struct.CgmSphere = type { %union.anon.7, float }
%union.anon.7 = type { %struct.anon.8 }
%struct.anon.8 = type { 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 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 } @CgmHoop3d_closest_pt(ptr noundef, <2 x float>, float) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @cgm_3d_sphere_vs_sphere(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_3d_hoop_vs_hoop(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.CgmSphere, align 8
  %6 = alloca %struct.CgmSphere, align 8
  %.sroa.08.0.copyload = load <2 x float>, ptr %1, align 4
  %.sroa.29.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  %.sroa.29.0.copyload = load float, ptr %.sroa.29.0..sroa_idx, align 4
  %7 = tail call { <2 x float>, float } @CgmHoop3d_closest_pt(ptr noundef %0, <2 x float> %.sroa.08.0.copyload, float %.sroa.29.0.copyload)
  %.fca.0.extract4 = extractvalue { <2 x float>, float } %7, 0
  %.fca.1.extract5 = extractvalue { <2 x float>, float } %7, 1
  %.sroa.01.0.copyload = load <2 x float>, ptr %0, align 4
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.22.0.copyload = load float, ptr %.sroa.22.0..sroa_idx, align 4
  %8 = tail call { <2 x float>, float } @CgmHoop3d_closest_pt(ptr noundef nonnull %1, <2 x float> %.sroa.01.0.copyload, float %.sroa.22.0.copyload)
  %.fca.0.extract = extractvalue { <2 x float>, float } %8, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %8, 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  store <2 x float> %.fca.0.extract4, ptr %5, align 8
  %.sroa.411.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract5, ptr %.sroa.411.0..sroa_idx, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %5, i64 12
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load float, ptr %10, align 4, !tbaa !8
  store float %11, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #2
  store <2 x float> %.fca.0.extract, ptr %6, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store float %.fca.1.extract, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %6, i64 12
  %13 = getelementptr inbounds i8, ptr %1, i64 40
  %14 = load float, ptr %13, align 4, !tbaa !8
  store float %14, ptr %12, align 4, !tbaa !11
  %15 = call zeroext i8 @cgm_3d_sphere_vs_sphere(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  ret i8 %15
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 40}
!9 = !{!"CgmHoop3d", !6, i64 0, !6, i64 12, !6, i64 24, !10, i64 36, !10, i64 40}
!10 = !{!"float", !6, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"CgmSphere", !6, i64 0, !10, i64 12}


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