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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z22update_function_1_callfffPf(float noundef, float noundef, float noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z23update_function_2_callsfffPf(float noundef, float noundef, float noundef, ptr noundef) #1

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

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

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %30

21:                                               ; preds = %16
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = sitofp i32 %22 to float
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %15, i64 %25
  store float %23, ptr %26, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %21
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !5
  br label %16, !llvm.loop !11

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %57, %30
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %60

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %15, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = fpext float %40 to double
  %42 = fmul double %41, 5.000000e-01
  %43 = fptrunc double %42 to float
  store float %43, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 0.000000e+00, ptr %8, align 4, !tbaa !9
  %44 = load float, ptr %7, align 4, !tbaa !9
  %45 = fpext float %44 to double
  %46 = fsub double %45, 1.000000e+00
  %47 = fptrunc double %46 to float
  %48 = load float, ptr %7, align 4, !tbaa !9
  %49 = fpext float %48 to double
  %50 = fadd double %49, 1.000000e+00
  %51 = fptrunc double %50 to float
  %52 = load float, ptr %7, align 4, !tbaa !9
  call void @_Z22update_function_1_callfffPf(float noundef %47, float noundef %51, float noundef %52, ptr noundef %8)
  %53 = load float, ptr %8, align 4, !tbaa !9
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %15, i64 %55
  store float %53, ptr %56, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %57

57:                                               ; preds = %36
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %6, align 4, !tbaa !5
  br label %31, !llvm.loop !13

60:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %87, %60
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %90

66:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %67 = load i32, ptr %9, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %15, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = fpext float %70 to double
  %72 = fmul double %71, 5.000000e-01
  %73 = fptrunc double %72 to float
  store float %73, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store float 0.000000e+00, ptr %11, align 4, !tbaa !9
  %74 = load float, ptr %10, align 4, !tbaa !9
  %75 = fpext float %74 to double
  %76 = fsub double %75, 1.000000e+00
  %77 = fptrunc double %76 to float
  %78 = load float, ptr %10, align 4, !tbaa !9
  %79 = fpext float %78 to double
  %80 = fadd double %79, 1.000000e+00
  %81 = fptrunc double %80 to float
  %82 = load float, ptr %10, align 4, !tbaa !9
  call void @_Z23update_function_2_callsfffPf(float noundef %77, float noundef %81, float noundef %82, ptr noundef %11)
  %83 = load float, ptr %11, align 4, !tbaa !9
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %15, i64 %85
  store float %83, ptr %86, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %87

87:                                               ; preds = %66
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %9, align 4, !tbaa !5
  br label %61, !llvm.loop !14

90:                                               ; preds = %65
  %91 = getelementptr inbounds float, ptr %15, i64 7
  %92 = load float, ptr %91, align 4, !tbaa !9
  %93 = fpext float %92 to double
  %94 = fsub double %93, 0x401652949A5657FB
  %95 = fcmp ole double %94, 1.000000e-04
  br i1 %95, label %96, label %98

96:                                               ; preds = %90
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %100

98:                                               ; preds = %90
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %100

100:                                              ; preds = %98, %96
  %101 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %101)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %102 = load i32, ptr %1, align 4
  ret i32 %102
}

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

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

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

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

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


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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z22update_function_1_callfffPf(float noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z23update_function_2_callsfffPf(float noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
vector.ph:
  %0 = alloca float, align 4
  %1 = alloca float, align 4
  %2 = alloca [20000 x float], align 16
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.1, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next.1, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %3 = uitofp <4 x i32> %vec.ind to <4 x float>
  %4 = uitofp <4 x i32> %step.add to <4 x float>
  %5 = getelementptr inbounds float, ptr %2, i64 %index
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  store <4 x float> %3, ptr %5, align 16, !tbaa !5
  store <4 x float> %4, ptr %6, align 16, !tbaa !5
  %index.next = or disjoint i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 12, i32 12, i32 12, i32 12>
  %7 = uitofp <4 x i32> %vec.ind.next to <4 x float>
  %8 = uitofp <4 x i32> %step.add.1 to <4 x float>
  %9 = getelementptr inbounds float, ptr %2, i64 %index.next
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  store <4 x float> %7, ptr %9, align 16, !tbaa !5
  store <4 x float> %8, ptr %10, align 16, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 16
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %11 = icmp eq i64 %index.next.1, 20000
  br i1 %11, label %.preheader25, label %vector.body, !llvm.loop !9

.preheader25:                                     ; preds = %vector.body, %.preheader25
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %.preheader25 ], [ 0, %vector.body ]
  %12 = getelementptr inbounds float, ptr %2, i64 %indvars.iv30
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fmul float %13, 5.000000e-01
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4
  store float 0.000000e+00, ptr %0, align 4, !tbaa !5
  %15 = fadd float %14, -1.000000e+00
  %16 = fadd float %14, 1.000000e+00
  call void @_Z22update_function_1_callfffPf(float noundef %15, float noundef %16, float noundef %14, ptr noundef nonnull %0)
  %17 = load float, ptr %0, align 4, !tbaa !5
  store float %17, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #4
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next31, 20000
  br i1 %exitcond33.not, label %.preheader, label %.preheader25, !llvm.loop !13

18:                                               ; preds = %.preheader
  %19 = getelementptr inbounds i8, ptr %2, i64 28
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = fpext float %20 to double
  %22 = fadd double %21, 0xC01652949A5657FB
  %23 = fcmp ugt double %22, 1.000000e-04
  %.str.1..str = select i1 %23, ptr @.str.1, ptr @.str
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str)
  ret i32 0

.preheader:                                       ; preds = %.preheader25, %.preheader
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %.preheader ], [ 0, %.preheader25 ]
  %25 = getelementptr inbounds float, ptr %2, i64 %indvars.iv34
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = fmul float %26, 5.000000e-01
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  store float 0.000000e+00, ptr %1, align 4, !tbaa !5
  %28 = fadd float %27, -1.000000e+00
  %29 = fadd float %27, 1.000000e+00
  call void @_Z23update_function_2_callsfffPf(float noundef %28, float noundef %29, float noundef %27, ptr noundef nonnull %1)
  %30 = load float, ptr %1, align 4, !tbaa !5
  store float %30, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next35, 20000
  br i1 %exitcond37.not, label %18, label %.preheader, !llvm.loop !14
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 #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 = { 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 = 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}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass