; LLVM IR from Slingshot-Physics/slingshot-community :: common/geometry/src (gauss_map)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.data_gaussMapMesh_s = type { i32, [1000 x %struct.data_leanNeighborTriangle_s], i32, [500 x %struct.vector3], i32, [1000 x %struct.data_gaussMapFace_s] }
%struct.data_leanNeighborTriangle_s = type { [3 x i32], [3 x i32] }
%struct.vector3 = type { [3 x float] }
%struct.data_gaussMapFace_s = type { %struct.vector3, i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry4mesh16loadGaussMapDataENS_5types11enumShape_tE(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4 %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca %struct.data_gaussMapMesh_s, align 4
  %5 = alloca %struct.data_gaussMapMesh_s, align 4
  %6 = alloca %struct.data_gaussMapMesh_s, align 4
  %7 = alloca %struct.data_gaussMapMesh_s, align 4
  %8 = alloca %struct.data_gaussMapMesh_s, align 4
  store i32 %1, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %9, label %14 [
    i32 0, label %10
    i32 1, label %11
    i32 4, label %12
    i32 7, label %13
  ]

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 50012, ptr %4) #6
  call void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind writable sret(%struct.data_gaussMapMesh_s) align 4 %4)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %4, i64 50012, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 50012, ptr %4) #6
  br label %19

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 50012, ptr %5) #6
  call void @_ZN8geometry4meshL21loadCylinderGaussMeshEv(ptr dead_on_unwind writable sret(%struct.data_gaussMapMesh_s) align 4 %5)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %5, i64 50012, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 50012, ptr %5) #6
  br label %19

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 50012, ptr %6) #6
  call void @_ZN8geometry4meshL19loadSphereGaussMeshEv(ptr dead_on_unwind writable sret(%struct.data_gaussMapMesh_s) align 4 %6)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %6, i64 50012, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 50012, ptr %6) #6
  br label %19

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 50012, ptr %7) #6
  call void @_ZN8geometry4meshL20loadCapsuleGaussMeshEv(ptr dead_on_unwind writable sret(%struct.data_gaussMapMesh_s) align 4 %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %7, i64 50012, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 50012, ptr %7) #6
  br label %19

14:                                               ; preds = %2
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef %16)
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 50012, ptr %8) #6
  call void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind writable sret(%struct.data_gaussMapMesh_s) align 4 %8)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %8, i64 50012, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 50012, ptr %8) #6
  br label %19

19:                                               ; preds = %14, %13, %12, %11, %10
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL21loadCylinderGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL19loadSphereGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL20loadCapsuleGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 = { "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 = { 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 = !{!"_ZTSN8geometry5types11enumShape_tE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 24000, !12, i64 24004, i64 4, !10, i64 24008, i64 6000, !12, i64 30008, i64 4, !10, i64 30012, i64 20000, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.data_gaussMapMesh_s = type { i32, [1000 x %struct.data_leanNeighborTriangle_s], i32, [500 x %struct.vector3], i32, [1000 x %struct.data_gaussMapFace_s] }
%struct.data_leanNeighborTriangle_s = type { [3 x i32], [3 x i32] }
%struct.vector3 = type { [3 x float] }
%struct.data_gaussMapFace_s = type { %struct.vector3, i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry4mesh16loadGaussMapDataENS_5types11enumShape_tE(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.data_gaussMapMesh_s) align 4 %0, i32 noundef %1) local_unnamed_addr #0 {
  switch i32 %1, label %7 [
    i32 0, label %3
    i32 1, label %4
    i32 4, label %5
    i32 7, label %6
  ]

3:                                                ; preds = %2
  tail call void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind nonnull writable sret(%struct.data_gaussMapMesh_s) align 4 %0)
  br label %11

4:                                                ; preds = %2
  tail call void @_ZN8geometry4meshL21loadCylinderGaussMeshEv(ptr dead_on_unwind nonnull writable sret(%struct.data_gaussMapMesh_s) align 4 %0)
  br label %11

5:                                                ; preds = %2
  tail call void @_ZN8geometry4meshL19loadSphereGaussMeshEv(ptr dead_on_unwind nonnull writable sret(%struct.data_gaussMapMesh_s) align 4 %0)
  br label %11

6:                                                ; preds = %2
  tail call void @_ZN8geometry4meshL20loadCapsuleGaussMeshEv(ptr dead_on_unwind nonnull writable sret(%struct.data_gaussMapMesh_s) align 4 %0)
  br label %11

7:                                                ; preds = %2
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %8, i32 noundef %1)
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull @.str.1)
  tail call void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind nonnull writable sret(%struct.data_gaussMapMesh_s) align 4 %0)
  br label %11

11:                                               ; preds = %7, %6, %5, %4, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL17loadCubeGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL21loadCylinderGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL19loadSphereGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN8geometry4meshL20loadCapsuleGaussMeshEv(ptr dead_on_unwind noalias writable sret(%struct.data_gaussMapMesh_s) align 4) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { 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 #2 = { inlinehint 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 #3 = { "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" }

!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)"}


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