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

; 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::mean_random" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double, double }

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

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

8:                                                ; preds = %1
  br label %9

9:                                                ; preds = %102, %8
  %10 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = mul i32 69069, %11
  %13 = add i32 %12, 1013904243
  %14 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  store i32 %13, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 4
  %16 = load i32, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 5
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = sub i32 %16, %18
  %20 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  %21 = load i32, ptr %20, align 8, !tbaa !16
  %22 = add i32 %19, %21
  %23 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 2
  store i32 %22, ptr %23, align 8, !tbaa !17
  %24 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !17
  %26 = ashr i32 %25, 31
  %27 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  store i32 %26, ptr %27, align 8, !tbaa !16
  %28 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = and i32 18, %29
  %31 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = sub i32 %32, %30
  store i32 %33, ptr %31, align 8, !tbaa !17
  %34 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 3
  %35 = load i32, ptr %34, align 4, !tbaa !18
  %36 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 5
  store i32 %35, ptr %36, align 4, !tbaa !15
  %37 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 2
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = add i32 %38, %40
  %42 = sitofp i32 %41 to double
  %43 = fmul double 0x3DFFFFFFFFFFFD09, %42
  %44 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 12
  store double %43, ptr %44, align 8, !tbaa !19
  %45 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = mul i32 69069, %46
  %48 = add i32 %47, 1013904243
  %49 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  store i32 %48, ptr %49, align 8, !tbaa !13
  %50 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 3
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 4
  %53 = load i32, ptr %52, align 8, !tbaa !14
  %54 = sub i32 %51, %53
  %55 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  %56 = load i32, ptr %55, align 8, !tbaa !16
  %57 = add i32 %54, %56
  %58 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 1
  store i32 %57, ptr %58, align 4, !tbaa !20
  %59 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !20
  %61 = ashr i32 %60, 31
  %62 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  store i32 %61, ptr %62, align 8, !tbaa !16
  %63 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 6
  %64 = load i32, ptr %63, align 8, !tbaa !16
  %65 = and i32 18, %64
  %66 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !20
  %68 = sub i32 %67, %65
  store i32 %68, ptr %66, align 4, !tbaa !20
  %69 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !17
  %71 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 4
  store i32 %70, ptr %71, align 8, !tbaa !14
  %72 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !20
  %74 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 3
  store i32 %73, ptr %74, align 4, !tbaa !18
  %75 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !20
  %77 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !13
  %79 = add i32 %76, %78
  %80 = sitofp i32 %79 to double
  %81 = fmul double 0x3DFFFFFFFFFFFD09, %80
  %82 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 11
  store double %81, ptr %82, align 8, !tbaa !21
  %83 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 11
  %84 = load double, ptr %83, align 8, !tbaa !21
  %85 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 11
  %86 = load double, ptr %85, align 8, !tbaa !21
  %87 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 12
  %88 = load double, ptr %87, align 8, !tbaa !19
  %89 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 12
  %90 = load double, ptr %89, align 8, !tbaa !19
  %91 = fmul double %88, %90
  %92 = call double @llvm.fmuladd.f64(double %84, double %86, double %91)
  %93 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  store double %92, ptr %93, align 8, !tbaa !22
  br label %94

94:                                               ; preds = %9
  %95 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %96 = load double, ptr %95, align 8, !tbaa !22
  %97 = fcmp oge double %96, 1.000000e+00
  br i1 %97, label %102, label %98

98:                                               ; preds = %94
  %99 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %100 = load double, ptr %99, align 8, !tbaa !22
  %101 = fcmp oeq double %100, 0.000000e+00
  br label %102

102:                                              ; preds = %98, %94
  %103 = phi i1 [ true, %94 ], [ %101, %98 ]
  br i1 %103, label %9, label %104, !llvm.loop !23

104:                                              ; preds = %102
  %105 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 7
  store i32 0, ptr %105, align 4, !tbaa !9
  %106 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %107 = load double, ptr %106, align 8, !tbaa !22
  %108 = call double @log(double noundef %107) #3
  %109 = fmul double -2.000000e+00, %108
  %110 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %111 = load double, ptr %110, align 8, !tbaa !22
  %112 = fdiv double %109, %111
  %113 = call double @sqrt(double noundef %112) #3
  %114 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  store double %113, ptr %114, align 8, !tbaa !22
  %115 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 9
  %116 = load double, ptr %115, align 8, !tbaa !25
  %117 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 10
  %118 = load double, ptr %117, align 8, !tbaa !26
  %119 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %120 = load double, ptr %119, align 8, !tbaa !22
  %121 = fmul double %118, %120
  %122 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 11
  %123 = load double, ptr %122, align 8, !tbaa !21
  %124 = call double @llvm.fmuladd.f64(double %121, double %123, double %116)
  store double %124, ptr %2, align 8
  br label %137

125:                                              ; preds = %1
  %126 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 7
  store i32 1, ptr %126, align 4, !tbaa !9
  %127 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 9
  %128 = load double, ptr %127, align 8, !tbaa !25
  %129 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 10
  %130 = load double, ptr %129, align 8, !tbaa !26
  %131 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 13
  %132 = load double, ptr %131, align 8, !tbaa !22
  %133 = fmul double %130, %132
  %134 = getelementptr inbounds %"class.qpl::test::mean_random", ptr %4, i32 0, i32 12
  %135 = load double, ptr %134, align 8, !tbaa !19
  %136 = call double @llvm.fmuladd.f64(double %133, double %135, double %128)
  store double %136, ptr %2, align 8
  br label %137

137:                                              ; preds = %125, %104
  %138 = load double, ptr %2, align 8
  ret double %138
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind
declare double @log(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 "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, !11, i64 28}
!10 = !{!"_ZTSN3qpl4test11mean_randomE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !11, i64 20}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 12}
!19 = !{!10, !12, i64 64}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !12, i64 56}
!22 = !{!10, !12, i64 72}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!10, !12, i64 40}
!26 = !{!10, !12, i64 48}


; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_ZN3qpl4test11mean_random3genEv(ptr nocapture noundef nonnull align 8 dereferenceable(80) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 28
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %55, label %.critedge.preheader

.critedge.preheader:                              ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %.promoted = load i32, ptr %0, align 8, !tbaa !11
  %.promoted5 = load i32, ptr %4, align 8, !tbaa !12
  %.promoted7 = load i32, ptr %5, align 4, !tbaa !13
  %.promoted9 = load i32, ptr %6, align 8, !tbaa !14
  %.promoted12 = load i32, ptr %7, align 4, !tbaa !15
  br label %.critedge

.critedge:                                        ; preds = %.critedge.preheader, %.critedge
  %10 = phi i32 [ %.promoted12, %.critedge.preheader ], [ %31, %.critedge ]
  %11 = phi i32 [ %.promoted9, %.critedge.preheader ], [ %29, %.critedge ]
  %12 = phi i32 [ %.promoted7, %.critedge.preheader ], [ %10, %.critedge ]
  %13 = phi i32 [ %.promoted5, %.critedge.preheader ], [ %21, %.critedge ]
  %14 = phi i32 [ %.promoted, %.critedge.preheader ], [ %26, %.critedge ]
  %15 = mul i32 %14, 69069
  %16 = add i32 %15, 1013904243
  %17 = sub i32 %13, %12
  %18 = add i32 %17, %11
  %19 = ashr i32 %18, 31
  %20 = and i32 %19, 18
  %21 = sub i32 %18, %20
  %22 = add i32 %21, %16
  %23 = sitofp i32 %22 to double
  %24 = fmul double %23, 0x3DFFFFFFFFFFFD09
  %25 = mul i32 %16, 69069
  %26 = add i32 %25, 1013904243
  %27 = sub i32 %10, %13
  %28 = add i32 %27, %19
  %29 = ashr i32 %28, 31
  %30 = and i32 %29, 18
  %31 = sub i32 %28, %30
  %32 = add i32 %31, %26
  %33 = sitofp i32 %32 to double
  %34 = fmul double %33, 0x3DFFFFFFFFFFFD09
  %35 = fmul double %24, %24
  %36 = tail call double @llvm.fmuladd.f64(double %34, double %34, double %35)
  %37 = fcmp oge double %36, 1.000000e+00
  %38 = fcmp oeq double %36, 0.000000e+00
  %or.cond = or i1 %37, %38
  br i1 %or.cond, label %.critedge, label %39, !llvm.loop !16

39:                                               ; preds = %.critedge
  %40 = getelementptr inbounds i8, ptr %0, i64 8
  %41 = getelementptr inbounds i8, ptr %0, i64 4
  %42 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 %26, ptr %0, align 8, !tbaa !11
  store i32 %21, ptr %4, align 8, !tbaa !12
  store i32 %10, ptr %5, align 4, !tbaa !13
  store i32 %29, ptr %6, align 8, !tbaa !14
  store i32 %21, ptr %40, align 8, !tbaa !18
  store i32 %31, ptr %7, align 4, !tbaa !15
  store double %24, ptr %8, align 8, !tbaa !19
  store i32 %31, ptr %41, align 4, !tbaa !20
  store double %34, ptr %9, align 8, !tbaa !21
  store double %36, ptr %42, align 8, !tbaa !22
  store i32 0, ptr %2, align 4, !tbaa !5
  %43 = tail call double @log(double noundef %36) #3
  %44 = fmul double %43, -2.000000e+00
  %45 = load double, ptr %42, align 8, !tbaa !22
  %46 = fdiv double %44, %45
  %47 = tail call double @sqrt(double noundef %46) #3
  store double %47, ptr %42, align 8, !tbaa !22
  %48 = getelementptr inbounds i8, ptr %0, i64 40
  %49 = load double, ptr %48, align 8, !tbaa !23
  %50 = getelementptr inbounds i8, ptr %0, i64 48
  %51 = load double, ptr %50, align 8, !tbaa !24
  %52 = fmul double %47, %51
  %53 = load double, ptr %9, align 8, !tbaa !21
  %54 = tail call double @llvm.fmuladd.f64(double %52, double %53, double %49)
  br label %66

55:                                               ; preds = %1
  store i32 1, ptr %2, align 4, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %0, i64 40
  %57 = load double, ptr %56, align 8, !tbaa !23
  %58 = getelementptr inbounds i8, ptr %0, i64 48
  %59 = load double, ptr %58, align 8, !tbaa !24
  %60 = getelementptr inbounds i8, ptr %0, i64 72
  %61 = load double, ptr %60, align 8, !tbaa !22
  %62 = fmul double %59, %61
  %63 = getelementptr inbounds i8, ptr %0, i64 64
  %64 = load double, ptr %63, align 8, !tbaa !19
  %65 = tail call double @llvm.fmuladd.f64(double %62, double %64, double %57)
  br label %66

66:                                               ; preds = %55, %39
  %.0 = phi double [ %54, %39 ], [ %65, %55 ]
  ret double %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind memory(write, argmem: readwrite) 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 nofree nounwind willreturn memory(write) "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, !7, i64 28}
!6 = !{!"_ZTSN3qpl4test11mean_randomE", !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, !10, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !7, i64 12}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !7, i64 8}
!19 = !{!6, !10, i64 64}
!20 = !{!6, !7, i64 4}
!21 = !{!6, !10, i64 56}
!22 = !{!6, !10, i64 72}
!23 = !{!6, !10, i64 40}
!24 = !{!6, !10, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass