; LLVM IR from ROCm/aomp :: test/omp5/reduc_map_prob (reduc_map_prob)

; 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"

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %8 = call noalias ptr @malloc(i64 noundef 40000000) #7
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = call noalias ptr @malloc(i64 noundef 40000000) #7
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %23, %0
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 5000000
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %26

14:                                               ; preds = %10
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  store double 1.000000e+00, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds double, ptr %19, i64 %21
  store double 1.000000e+00, ptr %22, align 8, !tbaa !11
  br label %23

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

26:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %44, %26
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 5000000
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %47

31:                                               ; preds = %27
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds double, ptr %37, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !11
  %42 = load double, ptr %5, align 8, !tbaa !11
  %43 = call double @llvm.fmuladd.f64(double %36, double %41, double %42)
  store double %43, ptr %5, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %31
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %6, align 4, !tbaa !9
  br label %27, !llvm.loop !15

47:                                               ; preds = %30
  %48 = load double, ptr %5, align 8, !tbaa !11
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %48)
  %50 = load double, ptr %5, align 8, !tbaa !11
  %51 = fcmp une double %50, 5.000000e+06
  br i1 %51, label %52, label %54

52:                                               ; preds = %47
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %59

54:                                               ; preds = %47
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %56

56:                                               ; preds = %54
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %57) #6
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %58) #6
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %59

59:                                               ; preds = %56, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %60 = load i32, ptr %1, align 4
  ret i32 %60
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

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

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 = { "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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"

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
vector.ph:
  %0 = tail call noalias dereferenceable_or_null(40000000) ptr @malloc(i64 noundef 40000000) #5
  %1 = tail call noalias dereferenceable_or_null(40000000) ptr @malloc(i64 noundef 40000000) #5
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.1, %vector.body ]
  %2 = getelementptr inbounds double, ptr %0, i64 %index
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %2, align 8, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds double, ptr %1, i64 %index
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %4, align 8, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %5, align 8, !tbaa !5
  %index.next = or disjoint i64 %index, 4
  %6 = getelementptr inbounds double, ptr %0, i64 %index.next
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %6, align 8, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds double, ptr %1, i64 %index.next
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %8, align 8, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %9, align 8, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 8
  %10 = icmp eq i64 %index.next.1, 5000000
  br i1 %10, label %.preheader, label %vector.body, !llvm.loop !9

11:                                               ; preds = %.preheader
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %38)
  %13 = fcmp une double %38, 5.000000e+06
  br i1 %13, label %39, label %41

.preheader:                                       ; preds = %vector.body, %.preheader
  %indvars.iv24 = phi i64 [ %indvars.iv.next25.4, %.preheader ], [ 0, %vector.body ]
  %.01721 = phi double [ %38, %.preheader ], [ 0.000000e+00, %vector.body ]
  %14 = getelementptr inbounds double, ptr %0, i64 %indvars.iv24
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds double, ptr %1, i64 %indvars.iv24
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %.01721)
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %19 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.next25
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next25
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %22, double %18)
  %indvars.iv.next25.1 = add nuw nsw i64 %indvars.iv24, 2
  %24 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.next25.1
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next25.1
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = tail call double @llvm.fmuladd.f64(double %25, double %27, double %23)
  %indvars.iv.next25.2 = add nuw nsw i64 %indvars.iv24, 3
  %29 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.next25.2
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next25.2
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %28)
  %indvars.iv.next25.3 = add nuw nsw i64 %indvars.iv24, 4
  %34 = getelementptr inbounds double, ptr %0, i64 %indvars.iv.next25.3
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next25.3
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = tail call double @llvm.fmuladd.f64(double %35, double %37, double %33)
  %indvars.iv.next25.4 = add nuw nsw i64 %indvars.iv24, 5
  %exitcond27.not.4 = icmp eq i64 %indvars.iv.next25.4, 5000000
  br i1 %exitcond27.not.4, label %11, label %.preheader, !llvm.loop !13

39:                                               ; preds = %11
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %43

41:                                               ; preds = %11
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @free(ptr noundef nonnull %0) #6
  tail call void @free(ptr noundef nonnull %1) #6
  br label %43

43:                                               ; preds = %41, %39
  %.019 = phi i32 [ -1, %39 ], [ 0, %41 ]
  ret i32 %.019
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nofree 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind allocsize(0) }
attributes #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass