; LLVM IR from ROCm/aomp :: test/usm/vector_add_auto_zero_copy (vector_add_auto_zero_copy)

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 102400, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %11 = call noalias noundef nonnull ptr @_Znam(i64 noundef 819200) #5
  store ptr %11, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef 819200) #5
  store ptr %12, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %13 = call noalias noundef nonnull ptr @_Znam(i64 noundef 819200) #5
  store ptr %13, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %30, %0
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = icmp ult i64 %15, 102400
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %33

18:                                               ; preds = %14
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %20 = uitofp i64 %19 to double
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = load i64, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %21, i64 %22
  store double %20, ptr %23, align 8, !tbaa !11
  %24 = load i64, ptr %6, align 8, !tbaa !5
  %25 = mul i64 2, %24
  %26 = uitofp i64 %25 to double
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds double, ptr %27, i64 %28
  store double %26, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %18
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = add i64 %31, 1
  store i64 %32, ptr %6, align 8, !tbaa !5
  br label %14, !llvm.loop !13

33:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %51, %33
  %35 = load i64, ptr %7, align 8, !tbaa !5
  %36 = icmp ult i64 %35, 102400
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %54

38:                                               ; preds = %34
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = load i64, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = load i64, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %43, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fadd double %42, %46
  %48 = load ptr, ptr %3, align 8, !tbaa !9
  %49 = load i64, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %48, i64 %49
  store double %47, ptr %50, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %38
  %52 = load i64, ptr %7, align 8, !tbaa !5
  %53 = add i64 %52, 1
  store i64 %53, ptr %7, align 8, !tbaa !5
  br label %34, !llvm.loop !15

54:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %96, %54
  %56 = load i64, ptr %9, align 8, !tbaa !5
  %57 = icmp ult i64 %56, 102400
  br i1 %57, label %59, label %58

58:                                               ; preds = %55
  store i32 8, ptr %10, align 4
  br label %99

59:                                               ; preds = %55
  %60 = load ptr, ptr %3, align 8, !tbaa !9
  %61 = load i64, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %4, align 8, !tbaa !9
  %65 = load i64, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %64, i64 %65
  %67 = load double, ptr %66, align 8, !tbaa !11
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = load i64, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %68, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = fadd double %67, %71
  %73 = fcmp une double %63, %72
  br i1 %73, label %74, label %95

74:                                               ; preds = %59
  %75 = load i64, ptr %9, align 8, !tbaa !5
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  %77 = load i64, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds double, ptr %76, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !11
  %80 = load ptr, ptr %4, align 8, !tbaa !9
  %81 = load i64, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %80, i64 %81
  %83 = load double, ptr %82, align 8, !tbaa !11
  %84 = load ptr, ptr %5, align 8, !tbaa !9
  %85 = load i64, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds double, ptr %84, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !11
  %88 = fadd double %83, %87
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %75, double noundef %79, double noundef %88)
  %90 = load i32, ptr %8, align 4, !tbaa !16
  %91 = icmp sgt i32 %90, 10
  br i1 %91, label %92, label %94

92:                                               ; preds = %74
  %93 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %93, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %99

94:                                               ; preds = %74
  br label %95

95:                                               ; preds = %94, %59
  br label %96

96:                                               ; preds = %95
  %97 = load i64, ptr %9, align 8, !tbaa !5
  %98 = add i64 %97, 1
  store i64 %98, ptr %9, align 8, !tbaa !5
  br label %55, !llvm.loop !18

99:                                               ; preds = %92, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %100 = load i32, ptr %10, align 4
  switch i32 %100, label %108 [
    i32 8, label %101
  ]

101:                                              ; preds = %99
  %102 = load i32, ptr %8, align 4, !tbaa !16
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %106, label %104

104:                                              ; preds = %101
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %106

106:                                              ; preds = %104, %101
  %107 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %107, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %108

108:                                              ; preds = %106, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %109 = load i32, ptr %1, align 4
  ret i32 %109
}

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

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

; 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, ...) #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 = { 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 = { nounwind }
attributes #5 = { 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 = !{!"long", !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 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !14}


; 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 [37 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 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(819200) ptr @_Znam(i64 noundef 819200) #3
  %1 = tail call noalias noundef nonnull dereferenceable(819200) ptr @_Znam(i64 noundef 819200) #3
  %2 = tail call noalias noundef nonnull dereferenceable(819200) ptr @_Znam(i64 noundef 819200) #3
  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 <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ %vec.ind.next.1, %vector.body ]
  %3 = uitofp <2 x i64> %vec.ind to <2 x double>
  %4 = getelementptr inbounds double, ptr %1, i64 %index
  store <2 x double> %3, ptr %4, align 8, !tbaa !5
  %5 = shl nuw nsw <2 x i64> %vec.ind, <i64 1, i64 1>
  %6 = uitofp nneg <2 x i64> %5 to <2 x double>
  %7 = getelementptr inbounds double, ptr %2, i64 %index
  store <2 x double> %6, ptr %7, align 8, !tbaa !5
  %index.next = or disjoint i64 %index, 2
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %8 = uitofp <2 x i64> %vec.ind.next to <2 x double>
  %9 = getelementptr inbounds double, ptr %1, i64 %index.next
  store <2 x double> %8, ptr %9, align 8, !tbaa !5
  %10 = shl nuw nsw <2 x i64> %vec.ind.next, <i64 1, i64 1>
  %11 = uitofp nneg <2 x i64> %10 to <2 x double>
  %12 = getelementptr inbounds double, ptr %2, i64 %index.next
  store <2 x double> %11, ptr %12, align 8, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 4
  %vec.ind.next.1 = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %13 = icmp eq i64 %index.next.1, 102400
  br i1 %13, label %vector.body52, label %vector.body, !llvm.loop !9

vector.body52:                                    ; preds = %vector.body, %vector.body52
  %index53 = phi i64 [ %index.next57.1, %vector.body52 ], [ 0, %vector.body ]
  %14 = getelementptr inbounds double, ptr %1, i64 %index53
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load = load <2 x double>, ptr %14, align 8, !tbaa !5
  %wide.load54 = load <2 x double>, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds double, ptr %2, i64 %index53
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load55 = load <2 x double>, ptr %16, align 8, !tbaa !5
  %wide.load56 = load <2 x double>, ptr %17, align 8, !tbaa !5
  %18 = fadd <2 x double> %wide.load, %wide.load55
  %19 = fadd <2 x double> %wide.load54, %wide.load56
  %20 = getelementptr inbounds double, ptr %0, i64 %index53
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x double> %18, ptr %20, align 8, !tbaa !5
  store <2 x double> %19, ptr %21, align 8, !tbaa !5
  %index.next57 = or disjoint i64 %index53, 4
  %22 = getelementptr inbounds double, ptr %1, i64 %index.next57
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %wide.load.1 = load <2 x double>, ptr %22, align 8, !tbaa !5
  %wide.load54.1 = load <2 x double>, ptr %23, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %2, i64 %index.next57
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load55.1 = load <2 x double>, ptr %24, align 8, !tbaa !5
  %wide.load56.1 = load <2 x double>, ptr %25, align 8, !tbaa !5
  %26 = fadd <2 x double> %wide.load.1, %wide.load55.1
  %27 = fadd <2 x double> %wide.load54.1, %wide.load56.1
  %28 = getelementptr inbounds double, ptr %0, i64 %index.next57
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  store <2 x double> %26, ptr %28, align 8, !tbaa !5
  store <2 x double> %27, ptr %29, align 8, !tbaa !5
  %index.next57.1 = add nuw nsw i64 %index53, 8
  %30 = icmp eq i64 %index.next57.1, 102400
  br i1 %30, label %.preheader, label %vector.body52, !llvm.loop !13

.preheader:                                       ; preds = %vector.body52, %41
  %.03645 = phi i64 [ %42, %41 ], [ 0, %vector.body52 ]
  %31 = getelementptr inbounds double, ptr %0, i64 %.03645
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %1, i64 %.03645
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds double, ptr %2, i64 %.03645
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fadd double %34, %36
  %38 = fcmp une double %32, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %.preheader
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %.03645, double noundef %32, double noundef %37)
  br label %41

41:                                               ; preds = %39, %.preheader
  %42 = add nuw nsw i64 %.03645, 1
  %exitcond47.not = icmp eq i64 %42, 102400
  br i1 %exitcond47.not, label %43, label %.preheader, !llvm.loop !14

43:                                               ; preds = %41
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  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

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 = !{!"double", !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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass