; LLVM IR from Lut1n/ImpGears :: src/ImpGears/Descriptors/JsonSceneNode.ll (ZN3imp9parseVec3EPNS_9JsonArrayE)

; 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.imp::Vec3" = type { %"class.imp::Vec.base", [4 x i8] }
%"class.imp::Vec.base" = type <{ %"class.imp::Object", [3 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.imp::JsonNumeric" = type { %"class.imp::JsonValue", double }
%"class.imp::JsonValue" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp9parseVec3EPNS_9JsonArrayE(ptr dead_on_unwind noalias writable sret(%"class.imp::Vec3") align 8 %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i1 false, ptr %5, align 1
  call void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 0)
          to label %10 unwind label %33

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.imp::JsonNumeric", ptr %9, i32 0, i32 1
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = fptrunc double %12 to float
  %14 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 0)
          to label %15 unwind label %33

15:                                               ; preds = %10
  store float %13, ptr %14, align 4, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %16, i32 noundef 1)
          to label %18 unwind label %33

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.imp::JsonNumeric", ptr %17, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = fptrunc double %20 to float
  %22 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 1)
          to label %23 unwind label %33

23:                                               ; preds = %18
  store float %21, ptr %22, align 4, !tbaa !13
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %24, i32 noundef 2)
          to label %26 unwind label %33

26:                                               ; preds = %23
  %27 = getelementptr inbounds %"class.imp::JsonNumeric", ptr %25, i32 0, i32 1
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fptrunc double %28 to float
  %30 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 2)
          to label %31 unwind label %33

31:                                               ; preds = %26
  store float %29, ptr %30, align 4, !tbaa !13
  store i1 true, ptr %5, align 1
  %32 = load i1, ptr %5, align 1
  br i1 %32, label %38, label %37

33:                                               ; preds = %26, %23, %18, %15, %10, %2
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %6, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %7, align 4
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %0) #3
  br label %39

37:                                               ; preds = %31
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %0) #3
  br label %38

38:                                               ; preds = %37, %31
  ret void

39:                                               ; preds = %33
  %40 = load ptr, ptr %6, align 8
  %41 = load i32, ptr %7, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #0 align 2

declare noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) #2 align 2

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

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 = { "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 = { 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++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"_ZTSN3imp11JsonNumericE", !11, i64 0, !12, i64 8}
!11 = !{!"_ZTSN3imp9JsonValueE"}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !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.imp::Vec3" = type { %"class.imp::Vec.base", [4 x i8] }
%"class.imp::Vec.base" = type <{ %"class.imp::Object", [3 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp9parseVec3EPNS_9JsonArrayE(ptr dead_on_unwind noalias nonnull writable sret(%"class.imp::Vec3") align 8 %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %3 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
          to label %4 unwind label %21

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fptrunc double %6 to float
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 0)
  store float %7, ptr %8, align 4, !tbaa !11
  %9 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
          to label %10 unwind label %21

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %9, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fptrunc double %12 to float
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 1)
  store float %13, ptr %14, align 4, !tbaa !11
  %15 = invoke noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
          to label %16 unwind label %21

16:                                               ; preds = %10
  %17 = getelementptr inbounds i8, ptr %15, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fptrunc double %18 to float
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef 2)
  store float %19, ptr %20, align 4, !tbaa !11
  ret void

21:                                               ; preds = %10, %4, %2
  %22 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %0) #3
  resume { ptr, i32 } %22
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3imp4Vec3C2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #0 align 2

declare noundef ptr @_ZN3imp9JsonArray10getNumericEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi3EfEixEj(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) local_unnamed_addr #2 align 2

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

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 = { "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 = { 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, !8, i64 8}
!6 = !{!"_ZTSN3imp11JsonNumericE", !7, i64 0, !8, i64 8}
!7 = !{!"_ZTSN3imp9JsonValueE"}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass