; LLVM IR from aff3ct/aff3ct :: src/Tools/Algo/PRNG/PRNG_MT19937.ll (ZN6aff3ct5tools12PRNG_MT199378rand_u32Ev)

; 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.aff3ct::tools::PRNG_MT19937" = type <{ ptr, %"class.std::vector", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6aff3ct5tools12PRNG_MT1993716generate_numbersEv(ptr noundef nonnull align 8 dereferenceable(36)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN6aff3ct5tools12PRNG_MT199378rand_u32Ev(ptr noundef nonnull align 8 dereferenceable(36) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.aff3ct::tools::PRNG_MT19937", ptr %4, i32 0, i32 2
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  call void @_ZN6aff3ct5tools12PRNG_MT1993716generate_numbersEv(ptr noundef nonnull align 8 dereferenceable(36) %4)
  br label %9

9:                                                ; preds = %8, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %10 = getelementptr inbounds %"class.aff3ct::tools::PRNG_MT19937", ptr %4, i32 0, i32 1
  %11 = getelementptr inbounds %"class.aff3ct::tools::PRNG_MT19937", ptr %4, i32 0, i32 2
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef %13) #2
  %15 = load i32, ptr %14, align 4, !tbaa !16
  store i32 %15, ptr %3, align 4, !tbaa !16
  %16 = load i32, ptr %3, align 4, !tbaa !16
  %17 = lshr i32 %16, 11
  %18 = load i32, ptr %3, align 4, !tbaa !16
  %19 = xor i32 %18, %17
  store i32 %19, ptr %3, align 4, !tbaa !16
  %20 = load i32, ptr %3, align 4, !tbaa !16
  %21 = shl i32 %20, 7
  %22 = and i32 %21, -1658038656
  %23 = load i32, ptr %3, align 4, !tbaa !16
  %24 = xor i32 %23, %22
  store i32 %24, ptr %3, align 4, !tbaa !16
  %25 = load i32, ptr %3, align 4, !tbaa !16
  %26 = shl i32 %25, 15
  %27 = and i32 %26, -272236544
  %28 = load i32, ptr %3, align 4, !tbaa !16
  %29 = xor i32 %28, %27
  store i32 %29, ptr %3, align 4, !tbaa !16
  %30 = load i32, ptr %3, align 4, !tbaa !16
  %31 = lshr i32 %30, 18
  %32 = load i32, ptr %3, align 4, !tbaa !16
  %33 = xor i32 %32, %31
  store i32 %33, ptr %3, align 4, !tbaa !16
  %34 = getelementptr inbounds %"class.aff3ct::tools::PRNG_MT19937", ptr %4, i32 0, i32 2
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = add i32 %35, 1
  store i32 %36, ptr %34, align 8, !tbaa !9
  %37 = icmp eq i32 %36, 624
  br i1 %37, label %38, label %40

38:                                               ; preds = %9
  %39 = getelementptr inbounds %"class.aff3ct::tools::PRNG_MT19937", ptr %4, i32 0, i32 2
  store i32 0, ptr %39, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %38, %9
  %41 = load i32, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %41
}

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, !15, i64 32}
!10 = !{!"_ZTSN6aff3ct5tools12PRNG_MT19937E", !11, i64 8, !15, i64 32}
!11 = !{!"_ZTSSt6vectorIjSaIjEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!15, !15, i64 0}


; 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 dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6aff3ct5tools12PRNG_MT1993716generate_numbersEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN6aff3ct5tools12PRNG_MT199378rand_u32Ev(ptr noundef nonnull align 8 dereferenceable(36) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %5

4:                                                ; preds = %1
  tail call void @_ZN6aff3ct5tools12PRNG_MT1993716generate_numbersEv(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %4, %1
  %6 = phi i32 [ %.pre, %4 ], [ %3, %1 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = zext i32 %6 to i64
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %8) #1
  %10 = load i32, ptr %9, align 4, !tbaa !15
  %11 = load i32, ptr %2, align 8, !tbaa !5
  %12 = add i32 %11, 1
  %13 = icmp eq i32 %12, 624
  %spec.select = select i1 %13, i32 0, i32 %12
  store i32 %spec.select, ptr %2, align 8, !tbaa !5
  %14 = lshr i32 %10, 11
  %15 = xor i32 %14, %10
  %16 = shl i32 %15, 7
  %17 = and i32 %16, -1658038656
  %18 = xor i32 %17, %15
  %19 = shl i32 %18, 15
  %20 = and i32 %19, -272236544
  %21 = xor i32 %20, %18
  %22 = lshr i32 %21, 18
  %23 = xor i32 %22, %21
  ret i32 %23
}

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 = { 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, !14, i64 32}
!6 = !{!"_ZTSN6aff3ct5tools12PRNG_MT19937E", !7, i64 8, !14, i64 32}
!7 = !{!"_ZTSSt6vectorIjSaIjEE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!14, !14, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass