; LLVM IR from preshing/CompareIntegerMaps :: mersennetwister.ll (ZN15MersenneTwister6reseedEj)

; 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.MersenneTwister = type { [624 x i32], i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15MersenneTwister6reseedEj(ptr noundef nonnull align 4 dereferenceable(2500) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.MersenneTwister, ptr %7, i32 0, i32 0
  %10 = getelementptr inbounds [624 x i32], ptr %9, i64 0, i64 0
  store i32 %8, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %37, %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 624
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %11
  %16 = getelementptr inbounds %class.MersenneTwister, ptr %7, i32 0, i32 0
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [624 x i32], ptr %16, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = getelementptr inbounds %class.MersenneTwister, ptr %7, i32 0, i32 0
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [624 x i32], ptr %22, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = lshr i32 %27, 30
  %29 = xor i32 %21, %28
  %30 = mul i32 1812433253, %29
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = add i32 %30, %31
  %33 = getelementptr inbounds %class.MersenneTwister, ptr %7, i32 0, i32 0
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [624 x i32], ptr %33, i64 0, i64 %35
  store i32 %32, ptr %36, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %15
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !11

40:                                               ; preds = %14
  %41 = getelementptr inbounds %class.MersenneTwister, ptr %7, i32 0, i32 1
  store i32 0, ptr %41, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %48, %40
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 2496
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %42
  %47 = call noundef i32 @_ZN15MersenneTwister7integerEv(ptr noundef nonnull align 4 dereferenceable(2500) %7)
  br label %48

48:                                               ; preds = %46
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %6, align 4, !tbaa !9
  br label %42, !llvm.loop !15

51:                                               ; preds = %45
  ret void
}

; 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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN15MersenneTwister7integerEv(ptr noundef nonnull align 4 dereferenceable(2500)) #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 2496}
!14 = !{!"_ZTS15MersenneTwister", !7, i64 0, !10, i64 2496}
!15 = distinct !{!15, !12}


; 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 @_ZN15MersenneTwister6reseedEj(ptr noundef nonnull align 4 dereferenceable(2500) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  store i32 %1, ptr %0, align 4, !tbaa !5
  br label %5

3:                                                ; preds = %5
  %4 = getelementptr inbounds i8, ptr %0, i64 2496
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %21

5:                                                ; preds = %13, %2
  %6 = phi i32 [ %1, %2 ], [ %18, %13 ]
  %indvars.iv = phi i64 [ 1, %2 ], [ %indvars.iv.next.1, %13 ]
  %7 = lshr i32 %6, 30
  %8 = xor i32 %7, %6
  %9 = mul i32 %8, 1812433253
  %10 = trunc nuw nsw i64 %indvars.iv to i32
  %11 = add i32 %9, %10
  %12 = getelementptr inbounds [624 x i32], ptr %0, i64 0, i64 %indvars.iv
  store i32 %11, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 624
  br i1 %exitcond.not, label %3, label %13, !llvm.loop !11

13:                                               ; preds = %5
  %14 = lshr i32 %11, 30
  %15 = xor i32 %14, %11
  %16 = mul i32 %15, 1812433253
  %17 = trunc nuw nsw i64 %indvars.iv.next to i32
  %18 = add i32 %16, %17
  %19 = getelementptr inbounds [624 x i32], ptr %0, i64 0, i64 %indvars.iv.next
  store i32 %18, ptr %19, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %5

20:                                               ; preds = %21
  ret void

21:                                               ; preds = %3, %21
  %.011 = phi i32 [ 0, %3 ], [ %23, %21 ]
  %22 = tail call noundef i32 @_ZN15MersenneTwister7integerEv(ptr noundef nonnull align 4 dereferenceable(2500) %0)
  %23 = add nuw nsw i32 %.011, 1
  %exitcond13.not = icmp eq i32 %23, 2496
  br i1 %exitcond13.not, label %20, label %21, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN15MersenneTwister7integerEv(ptr noundef nonnull align 4 dereferenceable(2500)) local_unnamed_addr #0 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 2496}
!10 = !{!"_ZTS15MersenneTwister", !7, i64 0, !6, i64 2496}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass