; LLVM IR from EdoPro98/SimSiPM :: src/SiPMRandom.ll (ZN4sipm7SiPMRng15Xorshift256plus4seedEm)

; 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.sipm::SiPMRng::Xorshift256plus" = type <{ [4 x i64], [32 x i8], [65536 x i64], i32, [60 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL5lcg64m(i64 noundef) #0

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sipm7SiPMRng15Xorshift256plus4seedEm(ptr noundef nonnull align 64 dereferenceable(524356) %0, i64 noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = load i64, ptr %4, align 8, !tbaa !9
  %9 = call noundef i64 @_ZL5lcg64m(i64 noundef %8)
  %10 = getelementptr inbounds %"class.sipm::SiPMRng::Xorshift256plus", ptr %7, i32 0, i32 0
  %11 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  store i64 %9, ptr %11, align 64, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  store i8 1, ptr %5, align 1, !tbaa !11
  br label %12

12:                                               ; preds = %30, %2
  %13 = load i8, ptr %5, align 1, !tbaa !11
  %14 = zext i8 %13 to i32
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  br label %33

17:                                               ; preds = %12
  %18 = getelementptr inbounds %"class.sipm::SiPMRng::Xorshift256plus", ptr %7, i32 0, i32 0
  %19 = load i8, ptr %5, align 1, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [4 x i64], ptr %18, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = call noundef i64 @_ZL5lcg64m(i64 noundef %24)
  %26 = getelementptr inbounds %"class.sipm::SiPMRng::Xorshift256plus", ptr %7, i32 0, i32 0
  %27 = load i8, ptr %5, align 1, !tbaa !11
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [4 x i64], ptr %26, i64 0, i64 %28
  store i64 %25, ptr %29, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %17
  %31 = load i8, ptr %5, align 1, !tbaa !11
  %32 = add i8 %31, 1
  store i8 %32, ptr %5, align 1, !tbaa !11
  br label %12, !llvm.loop !12

33:                                               ; preds = %16
  %34 = getelementptr inbounds %"class.sipm::SiPMRng::Xorshift256plus", ptr %7, i32 0, i32 3
  store i32 65536, ptr %34, align 64, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !17
  br label %35

35:                                               ; preds = %41, %33
  %36 = load i32, ptr %6, align 4, !tbaa !17
  %37 = icmp ult i32 %36, 65536
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %44

39:                                               ; preds = %35
  %40 = call noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356) %7) #4
  br label %41

41:                                               ; preds = %39
  %42 = load i32, ptr %6, align 4, !tbaa !17
  %43 = add i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !17
  br label %35, !llvm.loop !18

44:                                               ; preds = %38
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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, !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !16, i64 524352}
!15 = !{!"_ZTSN4sipm7SiPMRng15Xorshift256plusE", !7, i64 0, !7, i64 64, !16, i64 524352}
!16 = !{!"int", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = distinct !{!18, !13}


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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL5lcg64m(i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sipm7SiPMRng15Xorshift256plus4seedEm(ptr noundef nonnull align 64 dereferenceable(524356) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i64 @_ZL5lcg64m(i64 noundef %1)
  store i64 %3, ptr %0, align 64, !tbaa !5
  %4 = tail call noundef i64 @_ZL5lcg64m(i64 noundef %3)
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %4, ptr %5, align 8, !tbaa !5
  %6 = tail call noundef i64 @_ZL5lcg64m(i64 noundef %4)
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %6, ptr %7, align 16, !tbaa !5
  %8 = tail call noundef i64 @_ZL5lcg64m(i64 noundef %6)
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %8, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 524352
  store i32 65536, ptr %10, align 64, !tbaa !9
  br label %12

11:                                               ; preds = %12
  ret void

12:                                               ; preds = %2, %12
  %.010 = phi i32 [ 0, %2 ], [ %14, %12 ]
  %13 = tail call noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356) %0) #2
  %14 = add nuw nsw i32 %.010, 1
  %exitcond.not = icmp eq i32 %14, 65536
  br i1 %exitcond.not, label %11, label %12, !llvm.loop !12
}

attributes #0 = { 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 #1 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 524352}
!10 = !{!"_ZTSN4sipm7SiPMRng15Xorshift256plusE", !7, i64 0, !7, i64 64, !11, i64 524352}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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