; LLVM IR from ROCm/aomp :: test/smoke-fails/iteam-red-1 (iteam_red_1)

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

; Function Attrs: nounwind uwtable
declare dso_local void @__kmpc_rfun_sum_d(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @__kmpc_rfun_sum_lds_d(ptr addrspace(3) noundef, ptr addrspace(3) noundef) #0

; Function Attrs: alwaysinline nounwind uwtable
declare dso_local void @__kmpc_iteamr_d_16x64(double noundef, ptr noundef, ptr noundef, ptr noundef, double noundef, i64 noundef) #1

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

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

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

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

15:                                               ; preds = %60, %4
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %63

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %51, %20
  %22 = load i64, ptr %12, align 8, !tbaa !13
  %23 = icmp ult i64 %22, 256
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %54

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %26 = load i64, ptr %12, align 8, !tbaa !13
  store i64 %26, ptr %14, align 8, !tbaa !13
  br label %27

27:                                               ; preds = %45, %25
  %28 = load i64, ptr %14, align 8, !tbaa !13
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %28, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %27
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %48

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

45:                                               ; preds = %33
  %46 = load i64, ptr %14, align 8, !tbaa !13
  %47 = add nsw i64 %46, 256
  store i64 %47, ptr %14, align 8, !tbaa !13
  br label %27, !llvm.loop !15

48:                                               ; preds = %32
  %49 = load double, ptr %13, align 8, !tbaa !11
  %50 = load i64, ptr %12, align 8, !tbaa !13
  call void @__kmpc_iteamr_d_16x64(double noundef %49, ptr noundef %11, ptr noundef @__kmpc_rfun_sum_d, ptr noundef @__kmpc_rfun_sum_lds_d, double noundef 0.000000e+00, i64 noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %51

51:                                               ; preds = %48
  %52 = load i64, ptr %12, align 8, !tbaa !13
  %53 = add i64 %52, 1
  store i64 %53, ptr %12, align 8, !tbaa !13
  br label %21, !llvm.loop !17

54:                                               ; preds = %24
  %55 = load double, ptr %11, align 8, !tbaa !11
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  store double %55, ptr %59, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %60

60:                                               ; preds = %54
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %9, align 4, !tbaa !9
  br label %15, !llvm.loop !18

63:                                               ; preds = %19
  ret void
}

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 = { alwaysinline 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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: nounwind uwtable
declare dso_local void @__kmpc_rfun_sum_d(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @__kmpc_rfun_sum_lds_d(ptr addrspace(3) noundef, ptr addrspace(3) noundef) #0

; Function Attrs: alwaysinline nounwind uwtable
declare dso_local void @__kmpc_iteamr_d_16x64(double noundef, ptr noundef, ptr noundef, ptr noundef, double noundef, i64 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @vmul_sim(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca double, align 8
  %6 = icmp sgt i32 %3, 0
  br i1 %6, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %4
  %7 = zext nneg i32 %3 to i64
  br label %8

._crit_edge27:                                    ; preds = %12, %4
  ret void

8:                                                ; preds = %.lr.ph26, %12
  %indvars.iv = phi i64 [ 0, %.lr.ph26 ], [ %indvars.iv.next, %12 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds double, ptr %0, i64 %indvars.iv
  br label %.preheader

.preheader:                                       ; preds = %8, %._crit_edge
  %.01823 = phi i64 [ 0, %8 ], [ %15, %._crit_edge ]
  %10 = icmp ult i64 %.01823, %7
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %11 = load double, ptr %9, align 8, !tbaa !5
  br label %16

12:                                               ; preds = %._crit_edge
  %13 = load double, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %13, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next, %7
  br i1 %exitcond29.not, label %._crit_edge27, label %8, !llvm.loop !9

._crit_edge:                                      ; preds = %16, %.preheader
  %.017.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %19, %16 ]
  call void @__kmpc_iteamr_d_16x64(double noundef %.017.lcssa, ptr noundef nonnull %5, ptr noundef nonnull @__kmpc_rfun_sum_d, ptr noundef nonnull @__kmpc_rfun_sum_lds_d, double noundef 0.000000e+00, i64 noundef %.01823)
  %15 = add nuw nsw i64 %.01823, 1
  %exitcond.not = icmp eq i64 %15, 256
  br i1 %exitcond.not, label %12, label %.preheader, !llvm.loop !11

16:                                               ; preds = %.lr.ph, %16
  %.022 = phi i64 [ %.01823, %.lr.ph ], [ %20, %16 ]
  %.01721 = phi double [ 0.000000e+00, %.lr.ph ], [ %19, %16 ]
  %17 = getelementptr inbounds double, ptr %1, i64 %.022
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = call double @llvm.fmuladd.f64(double %11, double %18, double %.01721)
  %20 = add nuw nsw i64 %.022, 256
  %21 = icmp ult i64 %20, %7
  br i1 %21, label %16, label %._crit_edge, !llvm.loop !12
}

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 = { alwaysinline 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass