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

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

10:                                               ; preds = %28, %1
  %11 = load i8, ptr %3, align 1, !tbaa !11
  %12 = zext i8 %11 to i32
  %13 = icmp slt i32 %12, 4
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  br label %31

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

28:                                               ; preds = %15
  %29 = load i8, ptr %3, align 1, !tbaa !11
  %30 = add i8 %29, 1
  store i8 %30, ptr %3, align 1, !tbaa !11
  br label %10, !llvm.loop !12

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

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

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %42

37:                                               ; preds = %33
  %38 = call noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356) %5) #4
  br label %39

39:                                               ; preds = %37
  %40 = load i32, ptr %4, align 4, !tbaa !17
  %41 = add i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !17
  br label %33, !llvm.loop !18

42:                                               ; preds = %36
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL5rdtscv() #1

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

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

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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
define dso_local void @_ZN4sipm7SiPMRng15Xorshift256plus4seedEv(ptr noundef nonnull align 64 dereferenceable(524356) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef i64 @_ZL5rdtscv()
  %3 = tail call noundef i64 @_ZL5lcg64m(i64 noundef %2)
  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 = %1, %12
  %.09 = phi i32 [ 0, %1 ], [ %14, %12 ]
  %13 = tail call noundef i64 @_ZN4sipm7SiPMRng15Xorshift256plusclEv(ptr noundef nonnull align 64 dereferenceable(524356) %0) #2
  %14 = add nuw nsw i32 %.09, 1
  %exitcond.not = icmp eq i32 %14, 65536
  br i1 %exitcond.not, label %11, label %12, !llvm.loop !12
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL5rdtscv() 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

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