; LLVM IR from ROCm/aomp :: test/smoke/reduction_array (reduction_array)

; 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 [21 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [10 x float], align 16
  %5 = alloca [10 x float], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 40, ptr %5) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %13, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 10
  br i1 %8, label %9, label %16

9:                                                ; preds = %6
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 %11
  store float 0.000000e+00, ptr %12, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %9
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !11

16:                                               ; preds = %6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %28, %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 10
  br i1 %19, label %20, label %31

20:                                               ; preds = %17
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sitofp i32 %21 to double
  %23 = fadd double 1.000000e+00, %22
  %24 = fptrunc double %23 to float
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [10 x float], ptr %5, i64 0, i64 %26
  store float %24, ptr %27, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %20
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !13

31:                                               ; preds = %17
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %53, %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp slt i32 %33, 10
  br i1 %34, label %35, label %56

35:                                               ; preds = %32
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %49, %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 10
  br i1 %38, label %39, label %52

39:                                               ; preds = %36
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10 x float], ptr %5, i64 0, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !9
  %48 = fadd float %47, %43
  store float %48, ptr %46, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %39
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %3, align 4, !tbaa !5
  br label %36, !llvm.loop !14

52:                                               ; preds = %36
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %2, align 4, !tbaa !5
  br label %32, !llvm.loop !15

56:                                               ; preds = %32
  %57 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 0
  %58 = load float, ptr %57, align 16, !tbaa !9
  %59 = fpext float %58 to double
  %60 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 9
  %61 = load float, ptr %60, align 4, !tbaa !9
  %62 = fpext float %61 to double
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %59, double noundef %62)
  call void @llvm.lifetime.end.p0(i64 40, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader15.preheader:
  %0 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef 1.000000e+01, double noundef 1.000000e+02)
  ret i32 0
}

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

attributes #0 = { mustprogress nofree norecurse 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 = { 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" }

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass