; LLVM IR from ThePhysicsGuys/Physics3D :: graphics (meshRegistry)

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

%"struct.P3D::BoundingBoxTemplate" = type { %"struct.P3D::Vector.13", %"struct.P3D::Vector.13" }
%"struct.P3D::Vector.13" = type { %union.anon.14 }
%union.anon.14 = type { [3 x double] }
%"struct.P3D::Vector" = type { %union.anon }
%union.anon = type { [3 x float] }
%"struct.P3D::Vector.7" = type { %union.anon.8 }
%union.anon.8 = type { [2 x float] }
%"class.std::shared_ptr.4" = type { %"class.std::__shared_ptr.5" }
%"class.std::__shared_ptr.5" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.P3D::MeshPrototype" = type { %"class.P3D::UniqueAlignedPointer", %"class.P3D::UniqueAlignedPointer.3", i32, i32 }
%"class.P3D::UniqueAlignedPointer" = type { ptr }
%"class.P3D::UniqueAlignedPointer.3" = type { ptr }
%struct.anon = 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D6VectorIfLm2EEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics20ExtendedTriangleMesh11setUVBufferERKSt10shared_ptrIA_KNS_6VectorIfLm2EEEE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10shared_ptrIA_KN3P3D6VectorIfLm2EEEEC2IS2_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3P3D2piIfEET_v() #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D6VectorIfLm2EEC2Ev(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #5

declare { <2 x float>, float } @_ZNK3P3D13MeshPrototype9getVertexEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #7

declare void @_ZNK3P3D12TriangleMesh9getBoundsEv(ptr dead_on_unwind writable sret(%"struct.P3D::BoundingBoxTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #7

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getWidthEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getDepthEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4acosf(float noundef) #6

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry21generateLightProbeUVsERNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(88) %0) #8 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.P3D::BoundingBoxTemplate", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.P3D::Vector", align 4
  %7 = alloca { <2 x float>, float }, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca %"struct.P3D::Vector.7", align 4
  %14 = alloca %"class.std::shared_ptr.4", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZNK3P3D12TriangleMesh9getBoundsEv(ptr dead_on_unwind writable sret(%"struct.P3D::BoundingBoxTemplate") align 8 %3, ptr noundef nonnull align 8 dereferenceable(24) %17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #9
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.P3D::MeshPrototype", ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %21, i64 8)
  %23 = extractvalue { i64, i1 } %22, 1
  %24 = extractvalue { i64, i1 } %22, 0
  %25 = select i1 %23, i64 -1, i64 %24
  %26 = call noalias noundef nonnull ptr @_Znam(i64 noundef %25) #10
  %27 = icmp eq i64 %21, 0
  br i1 %27, label %34, label %28

28:                                               ; preds = %1
  %29 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %26, i64 %21
  br label %30

30:                                               ; preds = %30, %28
  %31 = phi ptr [ %26, %28 ], [ %32, %30 ]
  call void @_ZN3P3D6VectorIfLm2EEC2Ev(ptr noundef nonnull align 4 dereferenceable(8) %31) #9
  %32 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %31, i64 1
  %33 = icmp eq ptr %32, %29
  br i1 %33, label %34, label %30

34:                                               ; preds = %30, %1
  store ptr %26, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %35

35:                                               ; preds = %126, %34
  %36 = load i32, ptr %5, align 4, !tbaa !14
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %"class.P3D::MeshPrototype", ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = icmp slt i32 %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  br label %129

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #9
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !14
  %45 = call { <2 x float>, float } @_ZNK3P3D13MeshPrototype9getVertexEi(ptr noundef nonnull align 8 dereferenceable(24) %43, i32 noundef %44)
  %46 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %47 = getelementptr inbounds %union.anon, ptr %46, i32 0, i32 0
  store { <2 x float>, float } %45, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 8 %7, i64 12, i1 false)
  %48 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getWidthEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %49 = fptrunc double %48 to float
  %50 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %51 = getelementptr inbounds %struct.anon, ptr %50, i32 0, i32 0
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = fdiv float %52, %49
  store float %53, ptr %51, align 4, !tbaa !15
  %54 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %55 = fptrunc double %54 to float
  %56 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %57 = getelementptr inbounds %struct.anon, ptr %56, i32 0, i32 1
  %58 = load float, ptr %57, align 4, !tbaa !15
  %59 = fdiv float %58, %55
  store float %59, ptr %57, align 4, !tbaa !15
  %60 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getDepthEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %61 = fptrunc double %60 to float
  %62 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %63 = getelementptr inbounds %struct.anon, ptr %62, i32 0, i32 2
  %64 = load float, ptr %63, align 4, !tbaa !15
  %65 = fdiv float %64, %61
  store float %65, ptr %63, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  %66 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %67 = getelementptr inbounds %struct.anon, ptr %66, i32 0, i32 2
  %68 = load float, ptr %67, align 4, !tbaa !15
  %69 = call noundef float @_ZSt4acosf(float noundef %68)
  store float %69, ptr %8, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %70 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %71 = getelementptr inbounds %struct.anon, ptr %70, i32 0, i32 1
  %72 = load float, ptr %71, align 4, !tbaa !15
  %73 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %74 = getelementptr inbounds %struct.anon, ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !15
  %76 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %77 = getelementptr inbounds %struct.anon, ptr %76, i32 0, i32 0
  %78 = load float, ptr %77, align 4, !tbaa !15
  %79 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %80 = getelementptr inbounds %struct.anon, ptr %79, i32 0, i32 1
  %81 = load float, ptr %80, align 4, !tbaa !15
  %82 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %83 = getelementptr inbounds %struct.anon, ptr %82, i32 0, i32 1
  %84 = load float, ptr %83, align 4, !tbaa !15
  %85 = fmul float %81, %84
  %86 = call float @llvm.fmuladd.f32(float %75, float %78, float %85)
  %87 = call noundef float @_ZSt4sqrtf(float noundef %86)
  %88 = fdiv float %72, %87
  store float %88, ptr %9, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %89 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %90 = getelementptr inbounds %struct.anon, ptr %89, i32 0, i32 0
  %91 = load float, ptr %90, align 4, !tbaa !15
  %92 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %93 = getelementptr inbounds %struct.anon, ptr %92, i32 0, i32 0
  %94 = load float, ptr %93, align 4, !tbaa !15
  %95 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %96 = getelementptr inbounds %struct.anon, ptr %95, i32 0, i32 0
  %97 = load float, ptr %96, align 4, !tbaa !15
  %98 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %99 = getelementptr inbounds %struct.anon, ptr %98, i32 0, i32 1
  %100 = load float, ptr %99, align 4, !tbaa !15
  %101 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %102 = getelementptr inbounds %struct.anon, ptr %101, i32 0, i32 1
  %103 = load float, ptr %102, align 4, !tbaa !15
  %104 = fmul float %100, %103
  %105 = call float @llvm.fmuladd.f32(float %94, float %97, float %104)
  %106 = call noundef float @_ZSt4sqrtf(float noundef %105)
  %107 = fdiv float %91, %106
  store float %107, ptr %10, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %108 = load float, ptr %8, align 4, !tbaa !16
  %109 = call noundef float @_ZN3P3D2piIfEET_v()
  %110 = fdiv float %108, %109
  %111 = load float, ptr %10, align 4, !tbaa !16
  %112 = call float @llvm.fmuladd.f32(float %110, float %111, float 1.000000e+00)
  %113 = fdiv float %112, 2.000000e+00
  store float %113, ptr %11, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  %114 = load float, ptr %8, align 4, !tbaa !16
  %115 = call noundef float @_ZN3P3D2piIfEET_v()
  %116 = fdiv float %114, %115
  %117 = load float, ptr %9, align 4, !tbaa !16
  %118 = call float @llvm.fmuladd.f32(float %116, float %117, float 1.000000e+00)
  %119 = fdiv float %118, 2.000000e+00
  store float %119, ptr %12, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #9
  %120 = load float, ptr %11, align 4, !tbaa !16
  %121 = load float, ptr %12, align 4, !tbaa !16
  call void @_ZN3P3D6VectorIfLm2EEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %13, float noundef %120, float noundef %121) #9
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  %123 = load i32, ptr %5, align 4, !tbaa !14
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %122, i64 %124
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %125, ptr align 4 %13, i64 8, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #9
  br label %126

126:                                              ; preds = %42
  %127 = load i32, ptr %5, align 4, !tbaa !14
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %5, align 4, !tbaa !14
  br label %35, !llvm.loop !19

129:                                              ; preds = %41
  %130 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #9
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt10shared_ptrIA_KN3P3D6VectorIfLm2EEEEC2IS2_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %131)
  invoke void @_ZN3P3D8Graphics20ExtendedTriangleMesh11setUVBufferERKSt10shared_ptrIA_KNS_6VectorIfLm2EEEE(ptr noundef nonnull align 8 dereferenceable(88) %130, ptr noundef nonnull align 8 dereferenceable(16) %14)
          to label %132 unwind label %133

132:                                              ; preds = %129
  call void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #9
  ret void

133:                                              ; preds = %129
  %134 = landingpad { ptr, i32 }
          cleanup
  %135 = extractvalue { ptr, i32 } %134, 0
  store ptr %135, ptr %15, align 8
  %136 = extractvalue { ptr, i32 } %134, 1
  store i32 %136, ptr %16, align 4
  call void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #9
  br label %137

137:                                              ; preds = %133
  %138 = load ptr, ptr %15, align 8
  %139 = load i32, ptr %16, align 4
  %140 = insertvalue { ptr, i32 } poison, ptr %138, 0
  %141 = insertvalue { ptr, i32 } %140, i32 %139, 1
  resume { ptr, i32 } %141
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin allocsize(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 #3 = { mustprogress 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 #4 = { mustprogress 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { inlinehint mustprogress 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 #7 = { "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 #8 = { mustprogress 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }

!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++ TBAA"}
!9 = !{!10, !13, i64 16}
!10 = !{!"_ZTSN3P3D13MeshPrototypeE", !11, i64 0, !12, i64 8, !13, i64 16, !13, i64 20}
!11 = !{!"_ZTSN3P3D20UniqueAlignedPointerIfEE", !6, i64 0}
!12 = !{!"_ZTSN3P3D20UniqueAlignedPointerIiEE", !6, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{i64 0, i64 8, !15}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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.P3D::BoundingBoxTemplate" = type { %"struct.P3D::Vector.13", %"struct.P3D::Vector.13" }
%"struct.P3D::Vector.13" = type { %union.anon.14 }
%union.anon.14 = type { [3 x double] }
%"struct.P3D::Vector.7" = type { %union.anon.8 }
%union.anon.8 = type { [2 x float] }
%"class.std::shared_ptr.4" = type { %"class.std::__shared_ptr.5" }
%"class.std::__shared_ptr.5" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D6VectorIfLm2EEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D8Graphics20ExtendedTriangleMesh11setUVBufferERKSt10shared_ptrIA_KNS_6VectorIfLm2EEEE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10shared_ptrIA_KN3P3D6VectorIfLm2EEEEC2IS2_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3P3D2piIfEET_v() local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3P3D6VectorIfLm2EEC2Ev(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #5

declare { <2 x float>, float } @_ZNK3P3D13MeshPrototype9getVertexEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #6

declare void @_ZNK3P3D12TriangleMesh9getBoundsEv(ptr dead_on_unwind writable sret(%"struct.P3D::BoundingBoxTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getWidthEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getDepthEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4acosf(float noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry21generateLightProbeUVsERNS0_20ExtendedTriangleMeshE(ptr noundef nonnull align 8 dereferenceable(88) %0) local_unnamed_addr #7 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"struct.P3D::BoundingBoxTemplate", align 8
  %3 = alloca %"struct.P3D::Vector.7", align 8
  %4 = alloca %"class.std::shared_ptr.4", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #8
  call void @_ZNK3P3D12TriangleMesh9getBoundsEv(ptr dead_on_unwind nonnull writable sret(%"struct.P3D::BoundingBoxTemplate") align 8 %2, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = icmp slt i32 %6, 0
  %9 = shl nsw i64 %7, 3
  %10 = select i1 %8, i64 -1, i64 %9
  %11 = call noalias noundef nonnull ptr @_Znam(i64 noundef %10) #9
  %12 = icmp eq i32 %6, 0
  br i1 %12, label %._crit_edge, label %13

13:                                               ; preds = %1
  %14 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %11, i64 %7
  br label %15

15:                                               ; preds = %15, %13
  %16 = phi ptr [ %11, %13 ], [ %17, %15 ]
  call void @_ZN3P3D6VectorIfLm2EEC2Ev(ptr noundef nonnull align 4 dereferenceable(8) %16) #8
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = icmp eq ptr %17, %14
  br i1 %18, label %.loopexit, label %15

.loopexit:                                        ; preds = %15
  %.pre = load i32, ptr %5, align 8, !tbaa !5
  %19 = icmp sgt i32 %.pre, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %1, %.loopexit
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  call void @_ZNSt10shared_ptrIA_KN3P3D6VectorIfLm2EEEEC2IS2_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull %11)
  call void @_ZN3P3D8Graphics20ExtendedTriangleMesh11setUVBufferERKSt10shared_ptrIA_KNS_6VectorIfLm2EEEE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #8
  ret void

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.loopexit ]
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  %21 = call { <2 x float>, float } @_ZNK3P3D13MeshPrototype9getVertexEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %20)
  %.fca.0.extract = extractvalue { <2 x float>, float } %21, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %21, 1
  %22 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getWidthEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %23 = fptrunc double %22 to float
  %.sroa.06.0.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 0
  %24 = fdiv float %.sroa.06.0.vec.extract, %23
  %25 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %26 = fptrunc double %25 to float
  %.sroa.06.4.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 1
  %27 = fdiv float %.sroa.06.4.vec.extract, %26
  %28 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getDepthEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %29 = fptrunc double %28 to float
  %30 = fdiv float %.fca.1.extract, %29
  %31 = call noundef float @_ZSt4acosf(float noundef %30)
  %32 = fmul float %27, %27
  %33 = call float @llvm.fmuladd.f32(float %24, float %24, float %32)
  %34 = call noundef float @_ZSt4sqrtf(float noundef %33)
  %35 = fdiv float %27, %34
  %36 = call noundef float @_ZSt4sqrtf(float noundef %33)
  %37 = fdiv float %24, %36
  %38 = call noundef float @_ZN3P3D2piIfEET_v()
  %39 = fdiv float %31, %38
  %40 = call float @llvm.fmuladd.f32(float %39, float %37, float 1.000000e+00)
  %41 = fmul float %40, 5.000000e-01
  %42 = call noundef float @_ZN3P3D2piIfEET_v()
  %43 = fdiv float %31, %42
  %44 = call float @llvm.fmuladd.f32(float %43, float %35, float 1.000000e+00)
  %45 = fmul float %44, 5.000000e-01
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  call void @_ZN3P3D6VectorIfLm2EEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %41, float noundef %45) #8
  %46 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %11, i64 %indvars.iv
  %47 = load i64, ptr %3, align 8, !tbaa !13
  store i64 %47, ptr %46, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = load i32, ptr %5, align 8, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next, %49
  br i1 %50, label %.lr.ph, label %._crit_edge, !llvm.loop !14
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 #2 = { mustprogress 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 #3 = { mustprogress 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 #4 = { inlinehint mustprogress 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 #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { "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 #7 = { mustprogress 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }

!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, !12, i64 16}
!6 = !{!"_ZTSN3P3D13MeshPrototypeE", !7, i64 0, !11, i64 8, !12, i64 16, !12, i64 20}
!7 = !{!"_ZTSN3P3D20UniqueAlignedPointerIfEE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3P3D20UniqueAlignedPointerIiEE", !8, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!9, !9, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass