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

; 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.CgmCapsule3d = type { %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 } @CgmCapsule3d_get_projected_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_sphere_vs_capsule(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 %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
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.CgmSphere, ptr %14, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %15, i64 12, i1 false)
  %16 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 0
  %17 = load <2 x float>, ptr %16, align 4
  %18 = getelementptr inbounds { <2 x float>, float }, ptr %10, i32 0, i32 1
  %19 = load float, ptr %18, align 4
  %20 = call { <2 x float>, float } @CgmCapsule3d_get_projected_pt(ptr noundef %13, <2 x float> %17, float %19)
  %21 = getelementptr inbounds %union.CgmVec3, ptr %9, i32 0, i32 0
  store { <2 x float>, float } %20, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 8 %11, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %22 = getelementptr inbounds %struct.CgmSphere, ptr %12, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %9, i64 12, i1 false), !tbaa.struct !9
  %23 = getelementptr inbounds %struct.CgmSphere, ptr %12, i32 0, i32 1
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CgmCapsule3d, ptr %24, i32 0, i32 3
  %26 = load float, ptr %25, align 4, !tbaa !11
  store float %26, ptr %23, align 4, !tbaa !14
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call zeroext i8 @cgm_3d_sphere_vs_sphere(ptr noundef %27, ptr noundef %12, ptr noundef %28, ptr noundef %29)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #3
  ret i8 %30
}

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 28}
!12 = !{!"CgmCapsule3d", !7, i64 0, !7, i64 12, !13, i64 24, !13, i64 28}
!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 } @CgmCapsule3d_get_projected_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_sphere_vs_capsule(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.CgmSphere, align 8
  %.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
  %6 = tail call { <2 x float>, float } @CgmCapsule3d_get_projected_pt(ptr noundef %1, <2 x float> %.sroa.01.0.copyload, float %.sroa.22.0.copyload)
  %.fca.0.extract = extractvalue { <2 x float>, float } %6, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %6, 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  store <2 x float> %.fca.0.extract, ptr %5, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 12
  %8 = getelementptr inbounds i8, ptr %1, i64 28
  %9 = load float, ptr %8, align 4, !tbaa !8
  store float %9, ptr %7, align 4, !tbaa !11
  %10 = call zeroext i8 @cgm_3d_sphere_vs_sphere(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  ret i8 %10
}

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 28}
!9 = !{!"CgmCapsule3d", !6, i64 0, !6, i64 12, !10, i64 24, !10, i64 28}
!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