; LLVM IR from tfhe/spqlios-arithmetic :: test/testlib/reim4_elem.ll (Z14gaussian_reim4v)

; 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.reim4_elem = type { [8 x 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 }

; 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 @_Z14gaussian_reim4v(ptr dead_on_unwind noalias writable sret(%class.reim4_elem) align 8 %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::normal_distribution", align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %5 = call noundef nonnull align 1 ptr @_Z7randgenv()
  store ptr %5, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #3
  call void @_ZNSt19normal_distributionIdEC2Edd(ptr noundef nonnull align 8 dereferenceable(25) %3, double noundef 0.000000e+00, double noundef 1.000000e+00)
  call void @_ZN10reim4_elemC1Ev(ptr noundef nonnull align 8 dereferenceable(64) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %16, %1
  %7 = load i64, ptr %4, align 8, !tbaa !9
  %8 = icmp ult i64 %7, 8
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %3, ptr noundef nonnull align 1 %11)
  %13 = getelementptr inbounds %class.reim4_elem, ptr %0, i32 0, i32 0
  %14 = load i64, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds [8 x double], ptr %13, i64 0, i64 %14
  store double %12, ptr %15, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %10
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = add i64 %17, 1
  store i64 %18, ptr %4, align 8, !tbaa !9
  br label %6, !llvm.loop !13

19:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret void
}

declare noundef nonnull align 1 ptr @_Z7randgenv() #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt19normal_distributionIdEC2Edd(ptr noundef nonnull align 8 dereferenceable(25), double noundef, double noundef) unnamed_addr #1 align 2

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

declare void @_ZN10reim4_elemC1Ev(ptr)

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 = { "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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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.reim4_elem = type { [8 x 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 }

; 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 uwtable
define dso_local void @_Z14gaussian_reim4v(ptr dead_on_unwind noalias writable sret(%class.reim4_elem) align 8 %0) local_unnamed_addr #1 {
  %2 = alloca %"class.std::normal_distribution", align 8
  %3 = tail call noundef nonnull align 1 ptr @_Z7randgenv()
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #3
  call void @_ZNSt19normal_distributionIdEC2Edd(ptr noundef nonnull align 8 dereferenceable(25) %2, double noundef 0.000000e+00, double noundef 1.000000e+00)
  call void @_ZN10reim4_elemC1Ev(ptr noundef nonnull align 8 dereferenceable(64) %0)
  %4 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  store double %4, ptr %0, align 8, !tbaa !5
  %5 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store double %5, ptr %6, align 8, !tbaa !5
  %7 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store double %7, ptr %8, align 8, !tbaa !5
  %9 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store double %11, ptr %12, align 8, !tbaa !5
  %13 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  store double %13, ptr %14, align 8, !tbaa !5
  %15 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  store double %15, ptr %16, align 8, !tbaa !5
  %17 = call noundef double @_ZNSt19normal_distributionIdEclISt26linear_congruential_engineImLm16807ELm0ELm2147483647EEEEdRT_(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 %3)
  %18 = getelementptr inbounds i8, ptr %0, i64 56
  store double %17, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #3
  ret void
}

declare noundef nonnull align 1 ptr @_Z7randgenv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt19normal_distributionIdEC2Edd(ptr noundef nonnull align 8 dereferenceable(25), double noundef, double noundef) unnamed_addr #1 align 2

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

declare void @_ZN10reim4_elemC1Ev(ptr) local_unnamed_addr

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 = { "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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass