; LLVM IR from intel/qpl :: tools/utils/generators/random_generator.ll (ZN3qpl4test11random_base3genEv)

; 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.qpl::test::random_base" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3qpl4test11random_base3genEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double 0x7FF8000000000000, ptr %3, align 8, !tbaa !9
  %8 = getelementptr inbounds i32, ptr %3, i64 0
  store i32 0, ptr %8, align 4, !tbaa !11
  %9 = getelementptr inbounds i32, ptr %3, i64 1
  store i32 1040187392, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %10 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 4
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 3
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 6
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = add i32 %13, %15
  %17 = sub i32 %11, %16
  store i32 %17, ptr %4, align 4, !tbaa !11
  %18 = load i32, ptr %4, align 4, !tbaa !11
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %1
  %21 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 6
  store i32 0, ptr %21, align 8, !tbaa !16
  br label %26

22:                                               ; preds = %1
  %23 = load i32, ptr %4, align 4, !tbaa !11
  %24 = sub nsw i32 %23, 18
  store i32 %24, ptr %4, align 4, !tbaa !11
  %25 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 6
  store i32 1, ptr %25, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %22, %20
  %27 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 3
  store i32 %28, ptr %29, align 4, !tbaa !15
  %30 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 5
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 4
  store i32 %31, ptr %32, align 8, !tbaa !13
  %33 = load i32, ptr %4, align 4, !tbaa !11
  %34 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 5
  store i32 %33, ptr %34, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %35 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 7
  %36 = load i32, ptr %35, align 4, !tbaa !18
  %37 = mul i32 69069, %36
  %38 = add i32 %37, 1013904243
  store i32 %38, ptr %5, align 4, !tbaa !11
  %39 = load i32, ptr %5, align 4, !tbaa !11
  %40 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 7
  store i32 %39, ptr %40, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %41 = load double, ptr %3, align 8, !tbaa !9
  %42 = load i32, ptr %4, align 4, !tbaa !11
  %43 = load i32, ptr %5, align 4, !tbaa !11
  %44 = add nsw i32 %42, %43
  %45 = sitofp i32 %44 to double
  %46 = fmul double %41, %45
  %47 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 10
  %48 = load double, ptr %47, align 8, !tbaa !19
  %49 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 9
  %50 = load double, ptr %49, align 8, !tbaa !20
  %51 = call double @llvm.fmuladd.f64(double %46, double %48, double %50)
  store double %51, ptr %6, align 8, !tbaa !9
  %52 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 12
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %52)
  %54 = load double, ptr %53, align 8, !tbaa !9
  store double %54, ptr %6, align 8, !tbaa !9
  %55 = getelementptr inbounds %"class.qpl::test::random_base", ptr %7, i32 0, i32 11
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %55)
  %57 = load double, ptr %56, align 8, !tbaa !9
  store double %57, ptr %6, align 8, !tbaa !9
  %58 = load double, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %58
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"_ZTSN3qpl4test11random_baseE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!15 = !{!14, !12, i64 12}
!16 = !{!14, !12, i64 24}
!17 = !{!14, !12, i64 20}
!18 = !{!14, !12, i64 28}
!19 = !{!14, !10, i64 48}
!20 = !{!14, !10, i64 40}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress 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 noundef double @_ZN3qpl4test11random_base3genEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca double, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = add i32 %5, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = load <2 x i32>, ptr %3, align 8, !tbaa !12
  %11 = extractelement <2 x i32> %10, i64 0
  %12 = sub i32 %11, %8
  %13 = icmp slt i32 %12, 1
  %14 = add nsw i32 %12, -18
  %storemerge = zext i1 %13 to i32
  %.0 = select i1 %13, i32 %14, i32 %12
  store i32 %storemerge, ptr %6, align 8, !tbaa !11
  store <2 x i32> %10, ptr %4, align 4, !tbaa !12
  store i32 %.0, ptr %9, align 4, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %0, i64 28
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %17 = mul i32 %16, 69069
  %18 = add i32 %17, 1013904243
  store i32 %18, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %19 = add nsw i32 %18, %.0
  %20 = sitofp i32 %19 to double
  %21 = fmul double %20, 0x3E00000000000000
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load double, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  %25 = load double, ptr %24, align 8, !tbaa !16
  %26 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %25)
  store double %26, ptr %2, align 8, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %27)
  %29 = load double, ptr %28, align 8, !tbaa !17
  store double %29, ptr %2, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %0, i64 56
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %30)
  %32 = load double, ptr %31, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret double %32
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 12}
!6 = !{!"_ZTSN3qpl4test11random_baseE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 28}
!15 = !{!6, !10, i64 48}
!16 = !{!6, !10, i64 40}
!17 = !{!10, !10, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass