; LLVM IR from ROCm/aomp :: test/smoke-fails/unified_address (unified_address)

; 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 [31 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 ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1000, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %10, i64 4)
  %12 = extractvalue { i64, i1 } %11, 1
  %13 = extractvalue { i64, i1 } %11, 0
  %14 = select i1 %12, i64 -1, i64 %13
  %15 = call noalias noundef nonnull ptr @_Znam(i64 noundef %14) #6
  store ptr %15, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %27, %0
  %17 = load i32, ptr %4, 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 %4) #5
  br label %30

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

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

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

31:                                               ; preds = %43, %30
  %32 = load i32, ptr %5, 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 %5) #5
  br label %46

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %36
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !5
  br label %31, !llvm.loop !13

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

47:                                               ; preds = %79, %46
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 8, ptr %8, align 4
  br label %82

52:                                               ; preds = %47
  %53 = load ptr, ptr %3, align 8, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %53, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  %60 = icmp ne i32 %57, %59
  br i1 %60, label %61, label %78

61:                                               ; preds = %52
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %65, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %64, i32 noundef %69, i32 noundef %71)
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 10
  br i1 %74, label %75, label %77

75:                                               ; preds = %61
  %76 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %76, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %82

77:                                               ; preds = %61
  br label %78

78:                                               ; preds = %77, %52
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !5
  br label %47, !llvm.loop !14

82:                                               ; preds = %75, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %83 = load i32, ptr %8, align 4
  switch i32 %83, label %86 [
    i32 8, label %84
  ]

84:                                               ; preds = %82
  %85 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %85, ptr %1, align 4
  store i32 1, ptr %8, align 4
  br label %86

86:                                               ; preds = %84, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %87 = load i32, ptr %1, align 4
  ret i32 %87
}

; 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 { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

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

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

declare i32 @printf(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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 }
attributes #6 = { builtin allocsize(0) }

!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}
!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 [31 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
vector.ph:
  %0 = tail call noalias noundef nonnull dereferenceable(4000) ptr @_Znam(i64 noundef 4000) #3
  br label %vector.body

vector.body:                                      ; preds = %vector.body.1, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.3, %vector.body.1 ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next.3, %vector.body.1 ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %1 = getelementptr inbounds i32, ptr %0, i64 %index
  %2 = getelementptr inbounds i8, ptr %1, i64 16
  store <4 x i32> %vec.ind, ptr %1, align 4, !tbaa !5
  store <4 x i32> %step.add, ptr %2, align 4, !tbaa !5
  %3 = icmp eq i64 %index, 992
  br i1 %3, label %vector.body56, label %vector.body.1, !llvm.loop !9

vector.body.1:                                    ; preds = %vector.body
  %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>
  %4 = getelementptr inbounds i32, ptr %0, i64 %index.next
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  store <4 x i32> %vec.ind.next, ptr %4, align 4, !tbaa !5
  store <4 x i32> %step.add.1, ptr %5, align 4, !tbaa !5
  %index.next.1 = or disjoint i64 %index, 16
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %step.add.2 = add <4 x i32> %vec.ind, <i32 20, i32 20, i32 20, i32 20>
  %6 = getelementptr inbounds i32, ptr %0, i64 %index.next.1
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  store <4 x i32> %vec.ind.next.1, ptr %6, align 4, !tbaa !5
  store <4 x i32> %step.add.2, ptr %7, align 4, !tbaa !5
  %index.next.2 = or disjoint i64 %index, 24
  %vec.ind.next.2 = add <4 x i32> %vec.ind, <i32 24, i32 24, i32 24, i32 24>
  %step.add.3 = add <4 x i32> %vec.ind, <i32 28, i32 28, i32 28, i32 28>
  %8 = getelementptr inbounds i32, ptr %0, i64 %index.next.2
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x i32> %vec.ind.next.2, ptr %8, align 4, !tbaa !5
  store <4 x i32> %step.add.3, ptr %9, align 4, !tbaa !5
  %index.next.3 = add nuw nsw i64 %index, 32
  %vec.ind.next.3 = add <4 x i32> %vec.ind, <i32 32, i32 32, i32 32, i32 32>
  br label %vector.body

vector.body56:                                    ; preds = %vector.body, %vector.body56.1
  %index57 = phi i64 [ %index.next59.1, %vector.body56.1 ], [ 0, %vector.body ]
  %10 = getelementptr inbounds i32, ptr %0, i64 %index57
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %wide.load = load <4 x i32>, ptr %10, align 4, !tbaa !5
  %wide.load58 = load <4 x i32>, ptr %11, align 4, !tbaa !5
  %12 = add nsw <4 x i32> %wide.load, <i32 1, i32 1, i32 1, i32 1>
  %13 = add nsw <4 x i32> %wide.load58, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %12, ptr %10, align 4, !tbaa !5
  store <4 x i32> %13, ptr %11, align 4, !tbaa !5
  %14 = icmp eq i64 %index57, 992
  br i1 %14, label %.preheader, label %vector.body56.1, !llvm.loop !13

vector.body56.1:                                  ; preds = %vector.body56
  %index.next59 = or disjoint i64 %index57, 8
  %15 = getelementptr inbounds i32, ptr %0, i64 %index.next59
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %wide.load.1 = load <4 x i32>, ptr %15, align 4, !tbaa !5
  %wide.load58.1 = load <4 x i32>, ptr %16, align 4, !tbaa !5
  %17 = add nsw <4 x i32> %wide.load.1, <i32 1, i32 1, i32 1, i32 1>
  %18 = add nsw <4 x i32> %wide.load58.1, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %17, ptr %15, align 4, !tbaa !5
  store <4 x i32> %18, ptr %16, align 4, !tbaa !5
  %index.next59.1 = add nuw nsw i64 %index57, 16
  br label %vector.body56

.preheader:                                       ; preds = %vector.body56, %27
  %indvars.iv47 = phi i64 [ %indvars.iv.next48, %27 ], [ 0, %vector.body56 ]
  %.02840 = phi i32 [ %.1, %27 ], [ 0, %vector.body56 ]
  %19 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv47
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %indvars.iv.next48 = add nuw nsw i64 %indvars.iv47, 1
  %21 = zext i32 %20 to i64
  %.not = icmp eq i64 %indvars.iv.next48, %21
  br i1 %.not, label %27, label %22

22:                                               ; preds = %.preheader
  %indvars = trunc i64 %indvars.iv.next48 to i32
  %23 = add nsw i32 %.02840, 1
  %24 = trunc nuw nsw i64 %indvars.iv47 to i32
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %24, i32 noundef %20, i32 noundef %indvars)
  %26 = icmp sgt i32 %.02840, 9
  br i1 %26, label %28, label %27

27:                                               ; preds = %.preheader, %22
  %.1 = phi i32 [ %23, %22 ], [ %.02840, %.preheader ]
  %exitcond50 = icmp eq i64 %indvars.iv.next48, 1000
  br i1 %exitcond50, label %28, label %.preheader, !llvm.loop !14

28:                                               ; preds = %22, %27
  %spec.select = phi i32 [ %.1, %27 ], [ %23, %22 ]
  ret i32 %spec.select
}

; 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

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 = { builtin allocsize(0) }

!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 = 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, !11, !12}
!14 = distinct !{!14, !10}


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