; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (alglibmisc)

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

%"struct.alglib_impl::hqrndstate" = type { i64, i64, i64 }

@_ZN11alglib_implL13hqrnd_hqrndm1E = external hidden global i64, align 8
@_ZN11alglib_implL13hqrnd_hqrndm2E = external hidden global i64, align 8
@_ZN11alglib_implL16hqrnd_hqrndmagicE = external hidden global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl9hqrndseedEllPNS_10hqrndstateEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %7, align 8, !tbaa !9
  call void @_ZN11alglib_impl17_hqrndstate_clearEPv(ptr noundef %9)
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %4
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = add nsw i64 %13, 1
  %15 = sub nsw i64 0, %14
  store i64 %15, ptr %5, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %12, %4
  %17 = load i64, ptr %6, align 8, !tbaa !5
  %18 = icmp slt i64 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = load i64, ptr %6, align 8, !tbaa !5
  %21 = add nsw i64 %20, 1
  %22 = sub nsw i64 0, %21
  store i64 %22, ptr %6, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %19, %16
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = load i64, ptr @_ZN11alglib_implL13hqrnd_hqrndm1E, align 8, !tbaa !5
  %26 = sub nsw i64 %25, 1
  %27 = srem i64 %24, %26
  %28 = add nsw i64 %27, 1
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = getelementptr inbounds %"struct.alglib_impl::hqrndstate", ptr %29, i32 0, i32 0
  store i64 %28, ptr %30, align 8, !tbaa !11
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = load i64, ptr @_ZN11alglib_implL13hqrnd_hqrndm2E, align 8, !tbaa !5
  %33 = sub nsw i64 %32, 1
  %34 = srem i64 %31, %33
  %35 = add nsw i64 %34, 1
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = getelementptr inbounds %"struct.alglib_impl::hqrndstate", ptr %36, i32 0, i32 1
  store i64 %35, ptr %37, align 8, !tbaa !13
  %38 = load i64, ptr @_ZN11alglib_implL16hqrnd_hqrndmagicE, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = getelementptr inbounds %"struct.alglib_impl::hqrndstate", ptr %39, i32 0, i32 2
  store i64 %38, ptr %40, align 8, !tbaa !14
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl17_hqrndstate_clearEPv(ptr noundef) #0

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

!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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN11alglib_impl10hqrndstateE", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}


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

@_ZN11alglib_implL13hqrnd_hqrndm1E = external hidden local_unnamed_addr global i64, align 8
@_ZN11alglib_implL13hqrnd_hqrndm2E = external hidden local_unnamed_addr global i64, align 8
@_ZN11alglib_implL16hqrnd_hqrndmagicE = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl9hqrndseedEllPNS_10hqrndstateEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr nocapture noundef readnone %3) local_unnamed_addr #0 {
  tail call void @_ZN11alglib_impl17_hqrndstate_clearEPv(ptr noundef %2)
  %.lobit = ashr i64 %0, 63
  %spec.select = xor i64 %.lobit, %0
  %.lobit13 = ashr i64 %1, 63
  %.09 = xor i64 %.lobit13, %1
  %5 = load i64, ptr @_ZN11alglib_implL13hqrnd_hqrndm1E, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  %7 = srem i64 %spec.select, %6
  %8 = add nuw nsw i64 %7, 1
  store i64 %8, ptr %2, align 8, !tbaa !9
  %9 = load i64, ptr @_ZN11alglib_implL13hqrnd_hqrndm2E, align 8, !tbaa !5
  %10 = add nsw i64 %9, -1
  %11 = srem i64 %.09, %10
  %12 = add nuw nsw i64 %11, 1
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  store i64 %12, ptr %13, align 8, !tbaa !11
  %14 = load i64, ptr @_ZN11alglib_implL16hqrnd_hqrndmagicE, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  store i64 %14, ptr %15, align 8, !tbaa !12
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl17_hqrndstate_clearEPv(ptr noundef) local_unnamed_addr #0

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

!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, !6, i64 0}
!10 = !{!"_ZTSN11alglib_impl10hqrndstateE", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}


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