; LLVM IR from ROCm/aomp :: test/smoke/usm-globals-with-pragma (usm_globals_with_pragma)

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

@x = external dso_local global i32, align 4
@z = external dso_local global [10 x i32], align 16
@k = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  store i32 3, ptr @x, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %15, %0
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = icmp ult i64 %7, 10
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %18

10:                                               ; preds = %6
  %11 = load i64, ptr %3, align 8, !tbaa !9
  %12 = trunc i64 %11 to i32
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = getelementptr inbounds [10 x i32], ptr @z, i64 0, i64 %13
  store i32 %12, ptr %14, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %10
  %16 = load i64, ptr %3, align 8, !tbaa !9
  %17 = add i64 %16, 1
  store i64 %17, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !11

18:                                               ; preds = %9
  %19 = call noalias noundef nonnull ptr @_Znam(i64 noundef 20) #6
  store ptr %19, ptr @k, align 8, !tbaa !13
  %20 = load ptr, ptr @k, align 8, !tbaa !13
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %33, %18
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = icmp ult i64 %23, 5
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %36

26:                                               ; preds = %22
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = sub i64 0, %27
  %29 = trunc i64 %28 to i32
  %30 = load ptr, ptr @k, align 8, !tbaa !13
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds i32, ptr %30, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %26
  %34 = load i64, ptr %4, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %4, align 8, !tbaa !9
  br label %22, !llvm.loop !15

36:                                               ; preds = %25
  %37 = load i32, ptr @x, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr @x, align 4, !tbaa !5
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %50, %36
  %42 = load i64, ptr %5, align 8, !tbaa !9
  %43 = icmp ult i64 %42, 10
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %53

45:                                               ; preds = %41
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = getelementptr inbounds [10 x i32], ptr @z, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %47, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %45
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = add i64 %51, 1
  store i64 %52, ptr %5, align 8, !tbaa !9
  br label %41, !llvm.loop !16

53:                                               ; preds = %44
  %54 = load ptr, ptr @k, align 8, !tbaa !13
  %55 = load ptr, ptr @k, align 8, !tbaa !13
  %56 = getelementptr inbounds i32, ptr %55, i64 3
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %54, i32 noundef %57)
  %59 = load i32, ptr @x, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = load i32, ptr getelementptr inbounds ([10 x i32], ptr @z, i64 0, i64 7), align 4, !tbaa !5
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %59, i32 noundef %60, i32 noundef %61)
  %63 = load ptr, ptr @k, align 8, !tbaa !13
  %64 = icmp eq ptr %63, null
  br i1 %64, label %66, label %65

65:                                               ; preds = %53
  call void @_ZdaPv(ptr noundef %63) #7
  br label %66

66:                                               ; preds = %65, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@x = external dso_local local_unnamed_addr global i32, align 4
@z = external dso_local local_unnamed_addr global [10 x i32], align 16
@k = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store i32 3, ptr @x, align 4, !tbaa !5
  store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, ptr @z, align 16, !tbaa !5
  store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, ptr getelementptr inbounds (i8, ptr @z, i64 16), align 16, !tbaa !5
  store i32 8, ptr getelementptr inbounds (i8, ptr @z, i64 32), align 16, !tbaa !5
  store i32 9, ptr getelementptr inbounds (i8, ptr @z, i64 36), align 4, !tbaa !5
  %1 = tail call noalias noundef nonnull dereferenceable(20) ptr @_Znam(i64 noundef 20) #4
  store ptr %1, ptr @k, align 8, !tbaa !9
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull %1)
  %3 = load ptr, ptr @k, align 8, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %3, i64 12
  store <4 x i32> <i32 0, i32 -1, i32 -2, i32 -3>, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 -4, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr @x, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr @x, align 4, !tbaa !5
  %8 = load <4 x i32>, ptr @z, align 16, !tbaa !5
  %9 = add nsw <4 x i32> %8, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %9, ptr @z, align 16, !tbaa !5
  %10 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @z, i64 16), align 16, !tbaa !5
  %11 = add nsw <4 x i32> %10, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %11, ptr getelementptr inbounds (i8, ptr @z, i64 16), align 16, !tbaa !5
  %12 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @z, i64 32), align 16, !tbaa !5
  %13 = add nsw <2 x i32> %12, <i32 1, i32 1>
  store <2 x i32> %13, ptr getelementptr inbounds (i8, ptr @z, i64 32), align 16, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %3, i32 noundef %14)
  %16 = load i32, ptr @x, align 4, !tbaa !5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @z, i64 28), align 4, !tbaa !5
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %16, i32 noundef 0, i32 noundef %17)
  %19 = load ptr, ptr @k, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %0
  tail call void @_ZdaPv(ptr noundef nonnull %19) #5
  br label %22

22:                                               ; preds = %21, %0
  ret i32 0
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

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 = { nobuiltin allocsize(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 = { 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 #3 = { nobuiltin 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 = { builtin allocsize(0) }
attributes #5 = { builtin 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 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass