; LLVM IR from CRAFT-THU/BSim :: src/neuron/poisson/PoissonNeuron.ll (ZN13PoissonNeuron7monitorER7SimInfo)

; 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.PoissonNeuron = type { %class.NeuronBase.base, %"class.std::vector", %"class.std::linear_congruential_engine", %"class.std::poisson_distribution", float, float, float, float, i8, i8, i32, i32, i32, i32, ptr }
%class.NeuronBase.base = type <{ %class.Base, %"class.std::vector", i8, i8, [2 x i8], i32, float }>
%class.Base = type { ptr, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<SynapseBase *, std::allocator<SynapseBase *>>::_Vector_impl" }
%"struct.std::_Vector_base<SynapseBase *, std::allocator<SynapseBase *>>::_Vector_impl" = type { %"struct.std::_Vector_base<SynapseBase *, std::allocator<SynapseBase *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SynapseBase *, std::allocator<SynapseBase *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::linear_congruential_engine" = type { i64 }
%"class.std::poisson_distribution" = type { %"struct.std::poisson_distribution<>::param_type", %"class.std::normal_distribution" }
%"struct.std::poisson_distribution<>::param_type" = type { double, double, double, double, double, double, double, double, double }
%"class.std::normal_distribution" = type <{ %"struct.std::normal_distribution<>::param_type", double, i8, [7 x i8] }>
%"struct.std::normal_distribution<>::param_type" = type { double, double }
%struct.SimInfo = type { i32, float, %"class.std::vector.0", %"class.std::vector.5" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13PoissonNeuron7monitorER7SimInfo(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef nonnull align 8 dereferenceable(56) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [128 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 9
  %8 = load i8, ptr %7, align 1, !tbaa !9, !range !27, !noundef !28
  %9 = trunc i8 %8 to i1
  br i1 %9, label %10, label %36

10:                                               ; preds = %2
  %11 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 14
  %12 = load ptr, ptr %11, align 8, !tbaa !29
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %21

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 128, ptr %5) #5
  %15 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %16 = call noundef i32 @_ZN4Base5getIDEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %17 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %15, ptr noundef @.str, i32 noundef %16) #5
  %18 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.1)
  %20 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 14
  store ptr %19, ptr %20, align 8, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #5
  br label %21

21:                                               ; preds = %14, %10
  %22 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 14
  %23 = load ptr, ptr %22, align 8, !tbaa !29
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.SimInfo, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !30
  %27 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 11
  %28 = load i32, ptr %27, align 8, !tbaa !40
  %29 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 10
  %30 = load i32, ptr %29, align 4, !tbaa !41
  %31 = getelementptr inbounds %class.PoissonNeuron, ptr %6, i32 0, i32 8
  %32 = load i8, ptr %31, align 8, !tbaa !42, !range !27, !noundef !28
  %33 = trunc i8 %32 to i1
  %34 = zext i1 %33 to i32
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.2, i32 noundef %26, i32 noundef %28, i32 noundef %30, i32 noundef %34) #5
  br label %36

36:                                               ; preds = %21, %2
  ret void
}

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Base5getIDEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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 "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 = { 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 #4 = { "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 = { 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, !18, i64 209}
!10 = !{!"_ZTS13PoissonNeuron", !11, i64 0, !14, i64 56, !20, i64 80, !22, i64 88, !19, i64 192, !19, i64 196, !19, i64 200, !19, i64 204, !18, i64 208, !18, i64 209, !13, i64 212, !13, i64 216, !13, i64 220, !13, i64 224, !6, i64 232}
!11 = !{!"_ZTS10NeuronBase", !12, i64 0, !14, i64 16, !18, i64 40, !18, i64 41, !13, i64 44, !19, i64 48}
!12 = !{!"_ZTS4Base", !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSSt6vectorIP11SynapseBaseSaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIP11SynapseBaseSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIP11SynapseBaseSaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIP11SynapseBaseSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = !{!"_ZTSSt26linear_congruential_engineImLm16807ELm0ELm2147483647EE", !21, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSSt20poisson_distributionIiE", !23, i64 0, !25, i64 72}
!23 = !{!"_ZTSNSt20poisson_distributionIiE10param_typeE", !24, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !24, i64 32, !24, i64 40, !24, i64 48, !24, i64 56, !24, i64 64}
!24 = !{!"double", !7, i64 0}
!25 = !{!"_ZTSSt19normal_distributionIdE", !26, i64 0, !24, i64 16, !18, i64 24}
!26 = !{!"_ZTSNSt19normal_distributionIdE10param_typeE", !24, i64 0, !24, i64 8}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!10, !6, i64 232}
!30 = !{!31, !13, i64 0}
!31 = !{!"_ZTS7SimInfo", !13, i64 0, !19, i64 4, !32, i64 8, !36, i64 32}
!32 = !{!"_ZTSSt6vectorIiSaIiEE", !33, i64 0}
!33 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!36 = !{!"_ZTSSt6vectorIfSaIfEE", !37, i64 0}
!37 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !38, i64 0}
!38 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !39, i64 0}
!39 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!40 = !{!10, !13, i64 216}
!41 = !{!10, !13, i64 212}
!42 = !{!10, !18, i64 208}


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

@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN13PoissonNeuron7monitorER7SimInfo(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %1) unnamed_addr #1 align 2 {
  %3 = alloca [128 x i8], align 16
  %4 = getelementptr inbounds i8, ptr %0, i64 209
  %5 = load i8, ptr %4, align 1, !tbaa !5, !range !26, !noundef !27
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %7, label %26

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 232
  %9 = load ptr, ptr %8, align 8, !tbaa !28
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %15

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #4
  %12 = tail call noundef i32 @_ZN4Base5getIDEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %13 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %12) #4
  %14 = call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.1)
  store ptr %14, ptr %8, align 8, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #4
  br label %15

15:                                               ; preds = %11, %7
  %16 = phi ptr [ %14, %11 ], [ %9, %7 ]
  %17 = load i32, ptr %1, align 8, !tbaa !29
  %18 = getelementptr inbounds i8, ptr %0, i64 216
  %19 = load i32, ptr %18, align 8, !tbaa !39
  %20 = getelementptr inbounds i8, ptr %0, i64 212
  %21 = load i32, ptr %20, align 4, !tbaa !40
  %22 = getelementptr inbounds i8, ptr %0, i64 208
  %23 = load i8, ptr %22, align 8, !tbaa !41, !range !26, !noundef !27
  %24 = zext nneg i8 %23 to i32
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.2, i32 noundef %17, i32 noundef %19, i32 noundef %21, i32 noundef %24) #4
  br label %26

26:                                               ; preds = %15, %2
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Base5getIDEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree nounwind "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 = { 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 #4 = { 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, !17, i64 209}
!6 = !{!"_ZTS13PoissonNeuron", !7, i64 0, !12, i64 56, !19, i64 80, !21, i64 88, !18, i64 192, !18, i64 196, !18, i64 200, !18, i64 204, !17, i64 208, !17, i64 209, !9, i64 212, !9, i64 216, !9, i64 220, !9, i64 224, !16, i64 232}
!7 = !{!"_ZTS10NeuronBase", !8, i64 0, !12, i64 16, !17, i64 40, !17, i64 41, !9, i64 44, !18, i64 48}
!8 = !{!"_ZTS4Base", !9, i64 8, !9, i64 12}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt6vectorIP11SynapseBaseSaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIP11SynapseBaseSaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIP11SynapseBaseSaIS1_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIP11SynapseBaseSaIS1_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !10, i64 0}
!17 = !{!"bool", !10, i64 0}
!18 = !{!"float", !10, i64 0}
!19 = !{!"_ZTSSt26linear_congruential_engineImLm16807ELm0ELm2147483647EE", !20, i64 0}
!20 = !{!"long", !10, i64 0}
!21 = !{!"_ZTSSt20poisson_distributionIiE", !22, i64 0, !24, i64 72}
!22 = !{!"_ZTSNSt20poisson_distributionIiE10param_typeE", !23, i64 0, !23, i64 8, !23, i64 16, !23, i64 24, !23, i64 32, !23, i64 40, !23, i64 48, !23, i64 56, !23, i64 64}
!23 = !{!"double", !10, i64 0}
!24 = !{!"_ZTSSt19normal_distributionIdE", !25, i64 0, !23, i64 16, !17, i64 24}
!25 = !{!"_ZTSNSt19normal_distributionIdE10param_typeE", !23, i64 0, !23, i64 8}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!6, !16, i64 232}
!29 = !{!30, !9, i64 0}
!30 = !{!"_ZTS7SimInfo", !9, i64 0, !18, i64 4, !31, i64 8, !35, i64 32}
!31 = !{!"_ZTSSt6vectorIiSaIiEE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!35 = !{!"_ZTSSt6vectorIfSaIfEE", !36, i64 0}
!36 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !37, i64 0}
!37 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !38, i64 0}
!38 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!39 = !{!6, !9, i64 216}
!40 = !{!6, !9, i64 212}
!41 = !{!6, !17, i64 208}


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