; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #5

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

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: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3P3D6two_piIfEET_v() #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry20generateSphericalUVsERNS0_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 %"struct.P3D::Vector.7", align 4
  %13 = alloca %"class.std::shared_ptr.4", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #9
  %16 = 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) %16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.P3D::MeshPrototype", ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %20, i64 8)
  %22 = extractvalue { i64, i1 } %21, 1
  %23 = extractvalue { i64, i1 } %21, 0
  %24 = select i1 %22, i64 -1, i64 %23
  %25 = call noalias noundef nonnull ptr @_Znam(i64 noundef %24) #10
  %26 = icmp eq i64 %20, 0
  br i1 %26, label %33, label %27

27:                                               ; preds = %1
  %28 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %25, i64 %20
  br label %29

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

33:                                               ; preds = %29, %1
  store ptr %25, 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 %34

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

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

41:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #9
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !14
  %44 = call { <2 x float>, float } @_ZNK3P3D13MeshPrototype9getVertexEi(ptr noundef nonnull align 8 dereferenceable(24) %42, i32 noundef %43)
  %45 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %46 = getelementptr inbounds %union.anon, ptr %45, i32 0, i32 0
  store { <2 x float>, float } %44, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %46, ptr align 8 %7, i64 12, i1 false)
  %47 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getWidthEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %48 = fptrunc double %47 to float
  %49 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %50 = getelementptr inbounds %struct.anon, ptr %49, i32 0, i32 0
  %51 = load float, ptr %50, align 4, !tbaa !15
  %52 = fdiv float %51, %48
  store float %52, ptr %50, align 4, !tbaa !15
  %53 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %54 = fptrunc double %53 to float
  %55 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon, ptr %55, i32 0, i32 1
  %57 = load float, ptr %56, align 4, !tbaa !15
  %58 = fdiv float %57, %54
  store float %58, ptr %56, align 4, !tbaa !15
  %59 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE8getDepthEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %60 = fptrunc double %59 to float
  %61 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %62 = getelementptr inbounds %struct.anon, ptr %61, i32 0, i32 2
  %63 = load float, ptr %62, align 4, !tbaa !15
  %64 = fdiv float %63, %60
  store float %64, ptr %62, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  %65 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %66 = getelementptr inbounds %struct.anon, ptr %65, i32 0, i32 0
  %67 = load float, ptr %66, align 4, !tbaa !15
  %68 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %69 = getelementptr inbounds %struct.anon, ptr %68, i32 0, i32 2
  %70 = load float, ptr %69, align 4, !tbaa !15
  %71 = call noundef float @_ZSt5atan2ff(float noundef %67, float noundef %70)
  store float %71, ptr %8, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %72 = getelementptr inbounds %"struct.P3D::Vector", ptr %6, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 1
  %74 = load float, ptr %73, align 4, !tbaa !15
  %75 = call noundef float @_ZSt4acosf(float noundef %74)
  store float %75, ptr %9, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %76 = load float, ptr %8, align 4, !tbaa !16
  %77 = call noundef float @_ZN3P3D6two_piIfEET_v()
  %78 = fdiv float %76, %77
  store float %78, ptr %10, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  %79 = load float, ptr %9, align 4, !tbaa !16
  %80 = call noundef float @_ZN3P3D2piIfEET_v()
  %81 = fneg float %79
  %82 = call float @llvm.fmuladd.f32(float %81, float %80, float 1.000000e+00)
  store float %82, ptr %11, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %83 = load float, ptr %10, align 4, !tbaa !16
  %84 = load float, ptr %11, align 4, !tbaa !16
  call void @_ZN3P3D6VectorIfLm2EEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %12, float noundef %83, float noundef %84) #9
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i32, ptr %5, align 4, !tbaa !14
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %85, i64 %87
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %88, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 8, 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 %89

89:                                               ; preds = %41
  %90 = load i32, ptr %5, align 4, !tbaa !14
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %5, align 4, !tbaa !14
  br label %34, !llvm.loop !19

92:                                               ; preds = %40
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #9
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt10shared_ptrIA_KN3P3D6VectorIfLm2EEEEC2IS2_vEEPT_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef %94)
  invoke void @_ZN3P3D8Graphics20ExtendedTriangleMesh11setUVBufferERKSt10shared_ptrIA_KNS_6VectorIfLm2EEEE(ptr noundef nonnull align 8 dereferenceable(88) %93, ptr noundef nonnull align 8 dereferenceable(16) %13)
          to label %95 unwind label %96

95:                                               ; preds = %92
  call void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #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

96:                                               ; preds = %92
  %97 = landingpad { ptr, i32 }
          cleanup
  %98 = extractvalue { ptr, i32 } %97, 0
  store ptr %98, ptr %14, align 8
  %99 = extractvalue { ptr, i32 } %97, 1
  store i32 %99, ptr %15, align 4
  call void @_ZNSt12__shared_ptrIA_KN3P3D6VectorIfLm2EEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #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 %100

100:                                              ; preds = %96
  %101 = load ptr, ptr %14, align 8
  %102 = load i32, ptr %15, align 4
  %103 = insertvalue { ptr, i32 } poison, ptr %101, 0
  %104 = insertvalue { ptr, i32 } %103, i32 %102, 1
  resume { ptr, i32 } %104
}

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

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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5atan2ff(float noundef, float noundef) local_unnamed_addr #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: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3P3D6two_piIfEET_v() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D8Graphics12MeshRegistry20generateSphericalUVsERNS0_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.04.0.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 0
  %24 = fdiv float %.sroa.04.0.vec.extract, %23
  %25 = call noundef double @_ZNK3P3D19BoundingBoxTemplateIdE9getHeightEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %26 = fptrunc double %25 to float
  %.sroa.04.4.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 1
  %27 = fdiv float %.sroa.04.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 @_ZSt5atan2ff(float noundef %24, float noundef %30)
  %32 = call noundef float @_ZSt4acosf(float noundef %27)
  %33 = call noundef float @_ZN3P3D6two_piIfEET_v()
  %34 = fdiv float %31, %33
  %35 = call noundef float @_ZN3P3D2piIfEET_v()
  %36 = fneg float %32
  %37 = call float @llvm.fmuladd.f32(float %36, float %35, float 1.000000e+00)
  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 %34, float noundef %37) #8
  %38 = getelementptr inbounds %"struct.P3D::Vector.7", ptr %11, i64 %indvars.iv
  %39 = load i64, ptr %3, align 8, !tbaa !13
  store i64 %39, ptr %38, 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
  %40 = load i32, ptr %5, align 8, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next, %41
  br i1 %42, label %.lr.ph, label %._crit_edge, !llvm.loop !14
}

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #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