; LLVM IR from doyubkim/fluid-engine-dev :: src/jet (point_particle_emitter2)

; 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.jet::Matrix" = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x double] }
%"class.jet::Vector" = type { double, double }
%"class.jet::PointParticleEmitter2" = type { %"class.jet::ParticleEmitter2", %"class.std::mersenne_twister_engine", double, i64, i64, i64, %"class.jet::Vector", %"class.jet::Vector", double, double }
%"class.jet::ParticleEmitter2" = type { ptr, i8, %"class.std::shared_ptr", %"class.std::function" }
%"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.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.std::mersenne_twister_engine" = type { [624 x i64], i64 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3jet21PointParticleEmitter24emitEPNS_5ArrayINS_6VectorIdLm2EEELm1EEES5_m(ptr noundef nonnull align 8 dereferenceable(5144) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca %"class.jet::Matrix", align 8
  %12 = alloca %"class.jet::Vector", align 8
  %13 = alloca %"class.jet::Vector", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %32, %4
  %16 = load i64, ptr %9, align 8, !tbaa !9
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %35

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %21 = call noundef double @_ZN3jet21PointParticleEmitter26randomEv(ptr noundef nonnull align 8 dereferenceable(5144) %14)
  %22 = fsub double %21, 5.000000e-01
  %23 = getelementptr inbounds %"class.jet::PointParticleEmitter2", ptr %14, i32 0, i32 9
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = fmul double %22, %24
  store double %25, ptr %10, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #2
  call void @_ZN3jet6MatrixIdLm2ELm2EE18makeRotationMatrixERKd(ptr dead_on_unwind writable sret(%"class.jet::Matrix") align 8 %11, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.jet::PointParticleEmitter2", ptr %14, i32 0, i32 6
  call void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 8 dereferenceable(16) %27)
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #2
  %29 = getelementptr inbounds %"class.jet::PointParticleEmitter2", ptr %14, i32 0, i32 8
  %30 = load double, ptr %29, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #2
  %31 = getelementptr inbounds %"class.jet::PointParticleEmitter2", ptr %14, i32 0, i32 7
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEERKNS_6MatrixIS2_Lm2ELm2EEERKS3_(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %13, ptr noundef nonnull align 8 dereferenceable(32) %11, ptr noundef nonnull align 8 dereferenceable(16) %31)
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEES2_RKS3_(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %12, double noundef %30, ptr noundef nonnull align 8 dereferenceable(16) %13)
  call void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 8 dereferenceable(16) %12)
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %32

32:                                               ; preds = %20
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %9, align 8, !tbaa !9
  br label %15, !llvm.loop !25

35:                                               ; preds = %19
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN3jet21PointParticleEmitter26randomEv(ptr noundef nonnull align 8 dereferenceable(5144)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jet6MatrixIdLm2ELm2EE18makeRotationMatrixERKd(ptr dead_on_unwind noalias writable sret(%"class.jet::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEERKNS_6MatrixIS2_Lm2ELm2EEERKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !21, i64 5136}
!12 = !{!"_ZTSN3jet21PointParticleEmitter2E", !13, i64 0, !20, i64 64, !21, i64 5064, !10, i64 5072, !10, i64 5080, !10, i64 5088, !22, i64 5096, !22, i64 5112, !21, i64 5128, !21, i64 5136}
!13 = !{!"_ZTSN3jet16ParticleEmitter2E", !14, i64 8, !15, i64 16, !18, i64 32}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt10shared_ptrIN3jet19ParticleSystemData2EE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrIN3jet19ParticleSystemData2ELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!18 = !{!"_ZTSSt8functionIFvPN3jet16ParticleEmitter2EddEE", !19, i64 0, !6, i64 24}
!19 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!20 = !{!"_ZTSSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EE", !7, i64 0, !10, i64 4992}
!21 = !{!"double", !7, i64 0}
!22 = !{!"_ZTSN3jet6VectorIdLm2EEE", !21, i64 0, !21, i64 8}
!23 = !{!21, !21, i64 0}
!24 = !{!12, !21, i64 5128}
!25 = distinct !{!25, !26}
!26 = !{!"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"

%"class.jet::Matrix" = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x double] }
%"class.jet::Vector" = type { double, double }

; 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 uwtable
define dso_local void @_ZN3jet21PointParticleEmitter24emitEPNS_5ArrayINS_6VectorIdLm2EEELm1EEES5_m(ptr noundef nonnull align 8 dereferenceable(5144) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca double, align 8
  %6 = alloca %"class.jet::Matrix", align 8
  %7 = alloca %"class.jet::Vector", align 8
  %8 = alloca %"class.jet::Vector", align 8
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 5136
  %10 = getelementptr inbounds i8, ptr %0, i64 5096
  %11 = getelementptr inbounds i8, ptr %0, i64 5128
  %12 = getelementptr inbounds i8, ptr %0, i64 5112
  br label %13

._crit_edge:                                      ; preds = %13, %4
  ret void

13:                                               ; preds = %.lr.ph, %13
  %.05 = phi i64 [ 0, %.lr.ph ], [ %19, %13 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #2
  %14 = call noundef double @_ZN3jet21PointParticleEmitter26randomEv(ptr noundef nonnull align 8 dereferenceable(5144) %0)
  %15 = fadd double %14, -5.000000e-01
  %16 = load double, ptr %9, align 8, !tbaa !5
  %17 = fmul double %15, %16
  store double %17, ptr %5, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #2
  call void @_ZN3jet6MatrixIdLm2ELm2EE18makeRotationMatrixERKd(ptr dead_on_unwind nonnull writable sret(%"class.jet::Matrix") align 8 %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(16) %10)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #2
  %18 = load double, ptr %11, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #2
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEERKNS_6MatrixIS2_Lm2ELm2EEERKS3_(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(16) %12)
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEES2_RKS3_(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %7, double noundef %18, ptr noundef nonnull align 8 dereferenceable(16) %8)
  call void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #2
  %19 = add nuw i64 %.05, 1
  %exitcond.not = icmp eq i64 %19, %3
  br i1 %exitcond.not, label %._crit_edge, label %13, !llvm.loop !23
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN3jet21PointParticleEmitter26randomEv(ptr noundef nonnull align 8 dereferenceable(5144)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jet6MatrixIdLm2ELm2EE18makeRotationMatrixERKd(ptr dead_on_unwind noalias writable sret(%"class.jet::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jet5ArrayINS_6VectorIdLm2EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm2EEERKNS_6MatrixIS2_Lm2ELm2EEERKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !19, i64 5136}
!6 = !{!"_ZTSN3jet21PointParticleEmitter2E", !7, i64 0, !17, i64 64, !19, i64 5064, !18, i64 5072, !18, i64 5080, !18, i64 5088, !20, i64 5096, !20, i64 5112, !19, i64 5128, !19, i64 5136}
!7 = !{!"_ZTSN3jet16ParticleEmitter2E", !8, i64 8, !11, i64 16, !15, i64 32}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt10shared_ptrIN3jet19ParticleSystemData2EE", !12, i64 0}
!12 = !{!"_ZTSSt12__shared_ptrIN3jet19ParticleSystemData2ELN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0, !14, i64 8}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0}
!15 = !{!"_ZTSSt8functionIFvPN3jet16ParticleEmitter2EddEE", !16, i64 0, !13, i64 24}
!16 = !{!"_ZTSSt14_Function_base", !9, i64 0, !13, i64 16}
!17 = !{!"_ZTSSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EE", !9, i64 0, !18, i64 4992}
!18 = !{!"long", !9, i64 0}
!19 = !{!"double", !9, i64 0}
!20 = !{!"_ZTSN3jet6VectorIdLm2EEE", !19, i64 0, !19, i64 8}
!21 = !{!19, !19, i64 0}
!22 = !{!6, !19, i64 5128}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass