; LLVM IR from heroseh/cgm :: cgm (cgm_3d_pt_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: nounwind uwtable
declare dso_local float @cgm_clamp(float noundef, float noundef, float noundef) #0

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

; 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) #2

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local float @CgmVec3_dot(<2 x float>, float, <2 x float>, float) #3

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_3d_pt_vs_capsule(<2 x float> %0, float %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca %union.CgmVec3, align 4
  %7 = alloca { <2 x float>, float }, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %union.CgmVec3, align 4
  %12 = alloca { <2 x float>, float }, align 4
  %13 = alloca { <2 x float>, float }, align 4
  %14 = alloca { <2 x float>, float }, align 8
  %15 = alloca float, align 4
  %16 = alloca { <2 x float>, float }, align 4
  %17 = alloca { <2 x float>, float }, align 4
  %18 = alloca %union.CgmVec3, align 4
  %19 = alloca %union.CgmVec3, align 4
  %20 = alloca { <2 x float>, float }, align 4
  %21 = alloca { <2 x float>, float }, align 8
  %22 = alloca { <2 x float>, float }, align 4
  %23 = alloca { <2 x float>, float }, align 4
  %24 = alloca { <2 x float>, float }, align 8
  %25 = alloca %struct.CgmSphere, align 4
  %26 = alloca { <2 x float>, float }, align 4
  %27 = getelementptr inbounds { <2 x float>, float }, ptr %7, i32 0, i32 0
  store <2 x float> %0, ptr %27, align 4
  %28 = getelementptr inbounds { <2 x float>, float }, ptr %7, i32 0, i32 1
  store float %1, ptr %28, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 12, i1 false)
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #4
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.CgmCapsule3d, ptr %29, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %6, i64 12, i1 false)
  %31 = getelementptr inbounds { <2 x float>, float }, ptr %12, i32 0, i32 0
  %32 = load <2 x float>, ptr %31, align 4
  %33 = getelementptr inbounds { <2 x float>, float }, ptr %12, i32 0, i32 1
  %34 = load float, ptr %33, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %30, i64 12, i1 false)
  %35 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 0
  %36 = load <2 x float>, ptr %35, align 4
  %37 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 1
  %38 = load float, ptr %37, align 4
  %39 = call { <2 x float>, float } @CgmVec3_sub(<2 x float> %32, float %34, <2 x float> %36, float %38)
  %40 = getelementptr inbounds %union.CgmVec3, ptr %11, i32 0, i32 0
  store { <2 x float>, float } %39, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %40, ptr align 8 %14, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.CgmCapsule3d, ptr %41, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %42, i64 12, i1 false)
  %43 = getelementptr inbounds { <2 x float>, float }, ptr %16, i32 0, i32 0
  %44 = load <2 x float>, ptr %43, align 4
  %45 = getelementptr inbounds { <2 x float>, float }, ptr %16, i32 0, i32 1
  %46 = load float, ptr %45, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %11, i64 12, i1 false)
  %47 = getelementptr inbounds { <2 x float>, float }, ptr %17, i32 0, i32 0
  %48 = load <2 x float>, ptr %47, align 4
  %49 = getelementptr inbounds { <2 x float>, float }, ptr %17, i32 0, i32 1
  %50 = load float, ptr %49, align 4
  %51 = call float @CgmVec3_dot(<2 x float> %44, float %46, <2 x float> %48, float %50)
  store float %51, ptr %15, align 4, !tbaa !9
  %52 = load float, ptr %15, align 4, !tbaa !9
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.CgmCapsule3d, ptr %53, i32 0, i32 2
  %55 = load float, ptr %54, align 4, !tbaa !11
  %56 = fneg float %55
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.CgmCapsule3d, ptr %57, i32 0, i32 2
  %59 = load float, ptr %58, align 4, !tbaa !11
  %60 = call float @cgm_clamp(float noundef %52, float noundef %56, float noundef %59)
  store float %60, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #4
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.CgmCapsule3d, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.CgmCapsule3d, ptr %63, i32 0, i32 1
  %65 = load float, ptr %15, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %64, i64 12, i1 false)
  %66 = getelementptr inbounds { <2 x float>, float }, ptr %20, i32 0, i32 0
  %67 = load <2 x float>, ptr %66, align 4
  %68 = getelementptr inbounds { <2 x float>, float }, ptr %20, i32 0, i32 1
  %69 = load float, ptr %68, align 4
  %70 = call { <2 x float>, float } @CgmVec3_mul_scalar(<2 x float> %67, float %69, float noundef %65)
  %71 = getelementptr inbounds %union.CgmVec3, ptr %19, i32 0, i32 0
  store { <2 x float>, float } %70, ptr %21, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %71, ptr align 8 %21, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %62, i64 12, i1 false)
  %72 = getelementptr inbounds { <2 x float>, float }, ptr %22, i32 0, i32 0
  %73 = load <2 x float>, ptr %72, align 4
  %74 = getelementptr inbounds { <2 x float>, float }, ptr %22, i32 0, i32 1
  %75 = load float, ptr %74, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %19, i64 12, i1 false)
  %76 = getelementptr inbounds { <2 x float>, float }, ptr %23, i32 0, i32 0
  %77 = load <2 x float>, ptr %76, align 4
  %78 = getelementptr inbounds { <2 x float>, float }, ptr %23, i32 0, i32 1
  %79 = load float, ptr %78, align 4
  %80 = call { <2 x float>, float } @CgmVec3_add(<2 x float> %73, float %75, <2 x float> %77, float %79)
  %81 = getelementptr inbounds %union.CgmVec3, ptr %18, i32 0, i32 0
  store { <2 x float>, float } %80, ptr %24, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %81, ptr align 8 %24, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %25) #4
  %82 = getelementptr inbounds %struct.CgmSphere, ptr %25, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %82, ptr align 4 %18, i64 12, i1 false), !tbaa.struct !13
  %83 = getelementptr inbounds %struct.CgmSphere, ptr %25, i32 0, i32 1
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.CgmCapsule3d, ptr %84, i32 0, i32 3
  %86 = load float, ptr %85, align 4, !tbaa !15
  store float %86, ptr %83, align 4, !tbaa !16
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %6, i64 12, i1 false)
  %89 = getelementptr inbounds { <2 x float>, float }, ptr %26, i32 0, i32 0
  %90 = load <2 x float>, ptr %89, align 4
  %91 = getelementptr inbounds { <2 x float>, float }, ptr %26, i32 0, i32 1
  %92 = load float, ptr %91, align 4
  %93 = call zeroext i8 @cgm_3d_pt_vs_sphere(<2 x float> %90, float %92, ptr noundef %25, ptr noundef %87, ptr noundef %88)
  call void @llvm.lifetime.end.p0(i64 16, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #4
  ret i8 %93
}

attributes #0 = { 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"CgmCapsule3d", !7, i64 0, !7, i64 12, !10, i64 24, !10, i64 28}
!13 = !{i64 0, i64 12, !14}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !10, i64 28}
!16 = !{!17, !10, i64 12}
!17 = !{!"CgmSphere", !7, i64 0, !10, 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: nounwind uwtable
declare dso_local float @cgm_clamp(float noundef, float noundef, float noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local float @CgmVec3_dot(<2 x float>, float, <2 x float>, float) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @cgm_3d_pt_vs_capsule(<2 x float> %0, float %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.CgmSphere, align 8
  %.sroa.025.0.copyload = load <2 x float>, ptr %2, align 4
  %.sroa.226.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.226.0.copyload = load float, ptr %.sroa.226.0..sroa_idx, align 4
  %7 = tail call { <2 x float>, float } @CgmVec3_sub(<2 x float> %0, float %1, <2 x float> %.sroa.025.0.copyload, float %.sroa.226.0.copyload)
  %.fca.0.extract21 = extractvalue { <2 x float>, float } %7, 0
  %.fca.1.extract22 = extractvalue { <2 x float>, float } %7, 1
  %8 = getelementptr inbounds i8, ptr %2, i64 12
  %.sroa.018.0.copyload = load <2 x float>, ptr %8, align 4
  %.sroa.219.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 20
  %.sroa.219.0.copyload = load float, ptr %.sroa.219.0..sroa_idx, align 4
  %9 = tail call float @CgmVec3_dot(<2 x float> %.sroa.018.0.copyload, float %.sroa.219.0.copyload, <2 x float> %.fca.0.extract21, float %.fca.1.extract22)
  %10 = getelementptr inbounds i8, ptr %2, i64 24
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fneg float %11
  %13 = tail call float @cgm_clamp(float noundef %9, float noundef %12, float noundef %11)
  %.sroa.011.0.copyload = load <2 x float>, ptr %8, align 4
  %.sroa.212.0.copyload = load float, ptr %.sroa.219.0..sroa_idx, align 4
  %14 = tail call { <2 x float>, float } @CgmVec3_mul_scalar(<2 x float> %.sroa.011.0.copyload, float %.sroa.212.0.copyload, float noundef %13)
  %.fca.0.extract7 = extractvalue { <2 x float>, float } %14, 0
  %.fca.1.extract8 = extractvalue { <2 x float>, float } %14, 1
  %.sroa.05.0.copyload = load <2 x float>, ptr %2, align 4
  %.sroa.26.0.copyload = load float, ptr %.sroa.226.0..sroa_idx, align 4
  %15 = tail call { <2 x float>, float } @CgmVec3_add(<2 x float> %.sroa.05.0.copyload, float %.sroa.26.0.copyload, <2 x float> %.fca.0.extract7, float %.fca.1.extract8)
  %.fca.0.extract = extractvalue { <2 x float>, float } %15, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %15, 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #3
  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 !10
  %16 = getelementptr inbounds i8, ptr %6, i64 12
  %17 = getelementptr inbounds i8, ptr %2, i64 28
  %18 = load float, ptr %17, align 4, !tbaa !11
  store float %18, ptr %16, align 4, !tbaa !12
  %19 = call zeroext i8 @cgm_3d_pt_vs_sphere(<2 x float> %0, float %1, ptr noundef nonnull %6, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #3
  ret i8 %19
}

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nosync 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, !9, i64 24}
!6 = !{!"CgmCapsule3d", !7, i64 0, !7, i64 12, !9, i64 24, !9, i64 28}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"float", !7, i64 0}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !9, i64 28}
!12 = !{!13, !9, i64 12}
!13 = !{!"CgmSphere", !7, i64 0, !9, i64 12}


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