; LLVM IR from ROCm/aomp :: test/smoke/target-shared-variables (target-shared-variables)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z23further_update_functionfffPfS_S_(float noundef %0, float noundef %1, float noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  store float %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store float 1.000000e+00, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store float 2.000000e+00, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store float 3.000000e+00, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %45, %6
  %18 = load i32, ptr %16, align 4, !tbaa !11
  %19 = load float, ptr %7, align 4, !tbaa !5
  %20 = fptosi float %19 to i32
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %48

23:                                               ; preds = %17
  %24 = load float, ptr %7, align 4, !tbaa !5
  %25 = load float, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %16, align 4, !tbaa !11
  %27 = sitofp i32 %26 to float
  %28 = call float @llvm.fmuladd.f32(float %24, float %25, float %27)
  %29 = load float, ptr %13, align 4, !tbaa !5
  %30 = fadd float %29, %28
  store float %30, ptr %13, align 4, !tbaa !5
  %31 = load float, ptr %8, align 4, !tbaa !5
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %16, align 4, !tbaa !11
  %34 = sitofp i32 %33 to float
  %35 = call float @llvm.fmuladd.f32(float %31, float %32, float %34)
  %36 = load float, ptr %14, align 4, !tbaa !5
  %37 = fadd float %36, %35
  store float %37, ptr %14, align 4, !tbaa !5
  %38 = load float, ptr %9, align 4, !tbaa !5
  %39 = load float, ptr %9, align 4, !tbaa !5
  %40 = load i32, ptr %16, align 4, !tbaa !11
  %41 = sitofp i32 %40 to float
  %42 = call float @llvm.fmuladd.f32(float %38, float %39, float %41)
  %43 = load float, ptr %15, align 4, !tbaa !5
  %44 = fadd float %43, %42
  store float %44, ptr %15, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %23
  %46 = load i32, ptr %16, align 4, !tbaa !11
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %16, align 4, !tbaa !11
  br label %17, !llvm.loop !13

48:                                               ; preds = %22
  %49 = load float, ptr %13, align 4, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !9
  store float %49, ptr %50, align 4, !tbaa !5
  %51 = load float, ptr %14, align 4, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !9
  store float %51, ptr %52, align 4, !tbaa !5
  %53 = load float, ptr %15, align 4, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  store float %53, ptr %54, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret void
}

; 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 float @llvm.fmuladd.f32(float, float, float) #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 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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 nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_Z23further_update_functionfffPfS_S_(float noundef %0, float noundef %1, float noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = fptosi float %0 to i32
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %6
  %xtraiter = and i32 %7, 1
  %9 = icmp eq i32 %7, 1
  br i1 %9, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %7, 2147483646
  %10 = insertelement <2 x float> poison, float %1, i64 0
  %11 = insertelement <2 x float> %10, float %2, i64 1
  %12 = insertelement <2 x float> poison, float %1, i64 0
  %13 = insertelement <2 x float> %12, float %2, i64 1
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa.loopexit:          ; preds = %.lr.ph
  %14 = uitofp nneg i32 %42 to float
  br label %._crit_edge.loopexit.unr-lcssa

._crit_edge.loopexit.unr-lcssa:                   ; preds = %._crit_edge.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.lcssa35.ph = phi float [ poison, %.lr.ph.preheader ], [ %37, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.lcssa.ph = phi <2 x float> [ poison, %.lr.ph.preheader ], [ %41, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.026.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %14, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.02223.unr = phi float [ 1.000000e+00, %.lr.ph.preheader ], [ %37, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.unr = phi <2 x float> [ <float 2.000000e+00, float 3.000000e+00>, %.lr.ph.preheader ], [ %41, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %15 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %.026.unr)
  %16 = fadd float %.02223.unr, %15
  %17 = insertelement <2 x float> poison, float %1, i64 0
  %18 = insertelement <2 x float> %17, float %2, i64 1
  %19 = insertelement <2 x float> poison, float %.026.unr, i64 0
  %20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
  %21 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %18, <2 x float> %18, <2 x float> %20)
  %22 = fadd <2 x float> %.unr, %21
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %6
  %.022.lcssa = phi float [ 1.000000e+00, %6 ], [ %.lcssa35.ph, %._crit_edge.loopexit.unr-lcssa ], [ %16, %.lr.ph.epil ]
  %23 = phi <2 x float> [ <float 2.000000e+00, float 3.000000e+00>, %6 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %22, %.lr.ph.epil ]
  store float %.022.lcssa, ptr %3, align 4, !tbaa !5
  %24 = extractelement <2 x float> %23, i64 0
  store float %24, ptr %4, align 4, !tbaa !5
  %25 = extractelement <2 x float> %23, i64 1
  store float %25, ptr %5, align 4, !tbaa !5
  ret void

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.026 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %42, %.lr.ph ]
  %.02223 = phi float [ 1.000000e+00, %.lr.ph.preheader.new ], [ %37, %.lr.ph ]
  %26 = phi <2 x float> [ <float 2.000000e+00, float 3.000000e+00>, %.lr.ph.preheader.new ], [ %41, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %27 = uitofp nneg i32 %.026 to float
  %28 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %27)
  %29 = fadd float %.02223, %28
  %30 = insertelement <2 x float> poison, float %27, i64 0
  %31 = shufflevector <2 x float> %30, <2 x float> poison, <2 x i32> zeroinitializer
  %32 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %11, <2 x float> %11, <2 x float> %31)
  %33 = fadd <2 x float> %26, %32
  %34 = or disjoint i32 %.026, 1
  %35 = uitofp nneg i32 %34 to float
  %36 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %35)
  %37 = fadd float %29, %36
  %38 = insertelement <2 x float> poison, float %35, i64 0
  %39 = shufflevector <2 x float> %38, <2 x float> poison, <2 x i32> zeroinitializer
  %40 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %13, <2 x float> %13, <2 x float> %39)
  %41 = fadd <2 x float> %33, %40
  %42 = add nuw nsw i32 %.026, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa.loopexit, label %.lr.ph, !llvm.loop !9
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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) }
attributes #2 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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