; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_misc.ll (ZN6SoLoud4Misc3Prg5srandEi)

; 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.SoLoud::Misc::Prg" = type { [16 x i32], i32 }

; 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 nounwind uwtable
define dso_local void @_ZN6SoLoud4Misc3Prg5srandEi(ptr noundef nonnull align 4 dereferenceable(68) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.SoLoud::Misc::Prg", ptr %6, i32 0, i32 1
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %23, %2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 16
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = mul nsw i32 %13, %14
  %16 = add nsw i32 %12, %15
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = add nsw i32 %16, %17
  %19 = getelementptr inbounds %"class.SoLoud::Misc::Prg", ptr %6, i32 0, i32 0
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [16 x i32], ptr %19, i64 0, i64 %21
  store i32 %18, ptr %22, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %11
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !13

26:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 64}
!12 = !{!"_ZTSN6SoLoud4Misc3PrgE", !7, i64 0, !10, i64 64}
!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN6SoLoud4Misc3Prg5srandEi(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(68) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %0, align 4, !tbaa !10
  %4 = shl i32 %1, 1
  %5 = or disjoint i32 %4, 1
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %5, ptr %6, align 4, !tbaa !10
  %7 = mul i32 %1, 3
  %8 = add nsw i32 %7, 2
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %8, ptr %9, align 4, !tbaa !10
  %10 = shl i32 %1, 2
  %11 = or disjoint i32 %10, 3
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %11, ptr %12, align 4, !tbaa !10
  %13 = mul i32 %1, 5
  %14 = add nsw i32 %13, 4
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %14, ptr %15, align 4, !tbaa !10
  %16 = mul i32 %1, 6
  %17 = add nsw i32 %16, 5
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %17, ptr %18, align 4, !tbaa !10
  %19 = mul i32 %1, 7
  %20 = add nsw i32 %19, 6
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %20, ptr %21, align 4, !tbaa !10
  %22 = shl i32 %1, 3
  %23 = or disjoint i32 %22, 7
  %24 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %23, ptr %24, align 4, !tbaa !10
  %25 = insertelement <4 x i32> poison, i32 %1, i64 0
  %26 = shufflevector <4 x i32> %25, <4 x i32> poison, <4 x i32> zeroinitializer
  %27 = mul <4 x i32> %26, <i32 9, i32 10, i32 11, i32 12>
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = add nsw <4 x i32> %27, <i32 8, i32 9, i32 10, i32 11>
  store <4 x i32> %29, ptr %28, align 4, !tbaa !10
  %30 = mul i32 %1, 13
  %31 = add nsw i32 %30, 12
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %31, ptr %32, align 4, !tbaa !10
  %33 = mul i32 %1, 14
  %34 = add nsw i32 %33, 13
  %35 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %34, ptr %35, align 4, !tbaa !10
  %36 = mul i32 %1, 15
  %37 = add nsw i32 %36, 14
  %38 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %37, ptr %38, align 4, !tbaa !10
  %39 = shl i32 %1, 4
  %40 = or disjoint i32 %39, 15
  %41 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %40, ptr %41, align 4, !tbaa !10
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !9, i64 64}
!6 = !{!"_ZTSN6SoLoud4Misc3PrgE", !7, i64 0, !9, i64 64}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}


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