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

@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @check(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

15:                                               ; preds = %55, %0
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 10000
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %58

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = sitofp i32 %21 to double
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %11, i64 %24
  store double %22, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %47, %19
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 10000
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %50

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

47:                                               ; preds = %30
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !5
  br label %26, !llvm.loop !11

50:                                               ; preds = %29
  %51 = load double, ptr %6, align 8, !tbaa !9
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %14, i64 %53
  store double %51, ptr %54, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %55

55:                                               ; preds = %50
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !13

58:                                               ; preds = %18
  call void @vmul_omp(ptr noundef %11, ptr noundef %12, ptr noundef %13, i32 noundef 10000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %59 = call i32 @check(ptr noundef %13, ptr noundef %14, i32 noundef 10000, ptr noundef @.str.4)
  store i32 %59, ptr %8, align 4, !tbaa !5
  call void @reset_c(ptr noundef %13, i32 noundef 10000)
  call void @vmul_sim(ptr noundef %11, ptr noundef %12, ptr noundef %13, i32 noundef 10000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %60 = call i32 @check(ptr noundef %13, ptr noundef %14, i32 noundef 10000, ptr noundef @.str.5)
  store i32 %60, ptr %9, align 4, !tbaa !5
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %66, label %63

63:                                               ; preds = %58
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = icmp ne i32 %64, 0
  br label %66

66:                                               ; preds = %63, %58
  %67 = phi i1 [ true, %58 ], [ %65, %63 ]
  %68 = zext i1 %67 to i32
  store i32 %68, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %69 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %69)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %70 = load i32, ptr %1, align 4
  ret i32 %70
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @vmul_omp(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @vmul_sim(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @reset_c(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @check(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
  %1 = alloca [10000 x double], align 16
  %2 = alloca [10000 x double], align 16
  %3 = alloca [10000 x double], align 16
  %4 = alloca [10000 x double], align 16
  br label %12

5:                                                ; preds = %16
  call void @vmul_omp(ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, i32 noundef 10000)
  %6 = call i32 @check(ptr noundef nonnull %3, ptr noundef nonnull %4, i32 noundef 10000, ptr noundef nonnull @.str.4)
  call void @reset_c(ptr noundef nonnull %3, i32 noundef 10000)
  call void @vmul_sim(ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, i32 noundef 10000)
  %7 = call i32 @check(ptr noundef nonnull %3, ptr noundef nonnull %4, i32 noundef 10000, ptr noundef nonnull @.str.5)
  %8 = icmp ne i32 %6, 0
  %9 = icmp ne i32 %7, 0
  %10 = select i1 %8, i1 true, i1 %9
  %11 = zext i1 %10 to i32
  ret i32 %11

12:                                               ; preds = %0, %16
  %indvars.iv22 = phi i64 [ 0, %0 ], [ %indvars.iv.next23, %16 ]
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %13 = trunc nuw nsw i64 %indvars.iv.next23 to i32
  %14 = uitofp nneg i32 %13 to double
  %15 = getelementptr inbounds double, ptr %1, i64 %indvars.iv22
  store double %14, ptr %15, align 8, !tbaa !5
  br label %18

16:                                               ; preds = %18
  %17 = getelementptr inbounds double, ptr %4, i64 %indvars.iv22
  store double %28, ptr %17, align 8, !tbaa !5
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 10000
  br i1 %exitcond25.not, label %5, label %12, !llvm.loop !9

18:                                               ; preds = %18, %12
  %indvars.iv = phi i64 [ 0, %12 ], [ %indvars.iv.next.1, %18 ]
  %.01718 = phi double [ 0.000000e+00, %12 ], [ %28, %18 ]
  %19 = trunc i64 %indvars.iv to i32
  %20 = add nuw nsw i32 %19, 2
  %21 = uitofp nneg i32 %20 to double
  %22 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %21, ptr %22, align 16, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %14, double %21, double %.01718)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %24 = trunc i64 %indvars.iv.next to i32
  %25 = add nuw nsw i32 %24, 2
  %26 = uitofp nneg i32 %25 to double
  %27 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  store double %26, ptr %27, align 8, !tbaa !5
  %28 = tail call double @llvm.fmuladd.f64(double %14, double %26, double %23)
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 10000
  br i1 %exitcond.not.1, label %16, label %18, !llvm.loop !11
}

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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}


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