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

; 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::Vector" = type { double, double, double }
%"class.jet::PointParticleEmitter3" = type { %"class.jet::ParticleEmitter3", %"class.std::mersenne_twister_engine", double, i64, i64, i64, %"class.jet::Vector", %"class.jet::Vector", double, double }
%"class.jet::ParticleEmitter3" = 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 @_ZN3jet21PointParticleEmitter34emitEPNS_5ArrayINS_6VectorIdLm3EEELm1EEES5_m(ptr noundef nonnull align 8 dereferenceable(5160) %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 %"class.jet::Vector", align 8
  %11 = 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
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %13

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

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %32

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  %19 = call noundef double @_ZN3jet21PointParticleEmitter36randomEv(ptr noundef nonnull align 8 dereferenceable(5160) %12)
  %20 = call noundef double @_ZN3jet21PointParticleEmitter36randomEv(ptr noundef nonnull align 8 dereferenceable(5160) %12)
  %21 = getelementptr inbounds %"class.jet::PointParticleEmitter3", ptr %12, i32 0, i32 7
  %22 = getelementptr inbounds %"class.jet::PointParticleEmitter3", ptr %12, i32 0, i32 9
  %23 = load double, ptr %22, align 8, !tbaa !11
  call void @_ZN3jet17uniformSampleConeIdEENS_6VectorIT_Lm3EEES2_S2_RKS3_S2_(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %10, double noundef %19, double noundef %20, ptr noundef nonnull align 8 dereferenceable(24) %21, double noundef %23)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.jet::PointParticleEmitter3", ptr %12, i32 0, i32 6
  call void @_ZN3jet5ArrayINS_6VectorIdLm3EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef nonnull align 8 dereferenceable(24) %25)
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #3
  %27 = getelementptr inbounds %"class.jet::PointParticleEmitter3", ptr %12, i32 0, i32 8
  %28 = load double, ptr %27, align 8, !tbaa !23
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm3EEES2_RKS3_(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %11, double noundef %28, ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @_ZN3jet5ArrayINS_6VectorIdLm3EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 8 dereferenceable(24) %11)
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #3
  br label %29

29:                                               ; preds = %18
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = add i64 %30, 1
  store i64 %31, ptr %9, align 8, !tbaa !9
  br label %13, !llvm.loop !24

32:                                               ; preds = %17
  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: inlinehint mustprogress uwtable
declare dso_local void @_ZN3jet17uniformSampleConeIdEENS_6VectorIT_Lm3EEES2_S2_RKS3_S2_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, double noundef, double noundef, ptr noundef nonnull align 8 dereferenceable(24), double noundef) #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm3EEES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(24)) #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 = { 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 = { 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 5152}
!12 = !{!"_ZTSN3jet21PointParticleEmitter3E", !13, i64 0, !20, i64 64, !21, i64 5064, !10, i64 5072, !10, i64 5080, !10, i64 5088, !22, i64 5096, !22, i64 5120, !21, i64 5144, !21, i64 5152}
!13 = !{!"_ZTSN3jet16ParticleEmitter3E", !14, i64 8, !15, i64 16, !18, i64 32}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt10shared_ptrIN3jet19ParticleSystemData3EE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrIN3jet19ParticleSystemData3ELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!18 = !{!"_ZTSSt8functionIFvPN3jet16ParticleEmitter3EddEE", !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 = !{!"_ZTSN3jet6VectorIdLm3EEE", !21, i64 0, !21, i64 8, !21, i64 16}
!23 = !{!12, !21, i64 5144}
!24 = distinct !{!24, !25}
!25 = !{!"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::Vector" = type { double, 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 @_ZN3jet21PointParticleEmitter34emitEPNS_5ArrayINS_6VectorIdLm3EEELm1EEES5_m(ptr noundef nonnull align 8 dereferenceable(5160) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.jet::Vector", align 8
  %6 = 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
  %7 = getelementptr inbounds i8, ptr %0, i64 5120
  %8 = getelementptr inbounds i8, ptr %0, i64 5152
  %9 = getelementptr inbounds i8, ptr %0, i64 5096
  %10 = getelementptr inbounds i8, ptr %0, i64 5144
  br label %11

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

11:                                               ; preds = %.lr.ph, %11
  %.05 = phi i64 [ 0, %.lr.ph ], [ %16, %11 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  %12 = call noundef double @_ZN3jet21PointParticleEmitter36randomEv(ptr noundef nonnull align 8 dereferenceable(5160) %0)
  %13 = call noundef double @_ZN3jet21PointParticleEmitter36randomEv(ptr noundef nonnull align 8 dereferenceable(5160) %0)
  %14 = load double, ptr %8, align 8, !tbaa !5
  call void @_ZN3jet17uniformSampleConeIdEENS_6VectorIT_Lm3EEES2_S2_RKS3_S2_(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %5, double noundef %12, double noundef %13, ptr noundef nonnull align 8 dereferenceable(24) %7, double noundef %14)
  call void @_ZN3jet5ArrayINS_6VectorIdLm3EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %9)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  %15 = load double, ptr %10, align 8, !tbaa !21
  call void @_ZN3jetmlIdEENS_6VectorIT_Lm3EEES2_RKS3_(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %6, double noundef %15, ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @_ZN3jet5ArrayINS_6VectorIdLm3EEELm1EE6appendERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  %16 = add nuw i64 %.05, 1
  %exitcond.not = icmp eq i64 %16, %3
  br i1 %exitcond.not, label %._crit_edge, label %11, !llvm.loop !22
}

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmlIdEENS_6VectorIT_Lm3EEES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, double noundef, ptr noundef nonnull align 8 dereferenceable(24)) 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 = { 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 = { 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 5152}
!6 = !{!"_ZTSN3jet21PointParticleEmitter3E", !7, i64 0, !17, i64 64, !19, i64 5064, !18, i64 5072, !18, i64 5080, !18, i64 5088, !20, i64 5096, !20, i64 5120, !19, i64 5144, !19, i64 5152}
!7 = !{!"_ZTSN3jet16ParticleEmitter3E", !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_ptrIN3jet19ParticleSystemData3EE", !12, i64 0}
!12 = !{!"_ZTSSt12__shared_ptrIN3jet19ParticleSystemData3ELN9__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 = !{!"_ZTSSt8functionIFvPN3jet16ParticleEmitter3EddEE", !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 = !{!"_ZTSN3jet6VectorIdLm3EEE", !19, i64 0, !19, i64 8, !19, i64 16}
!21 = !{!6, !19, i64 5144}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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