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

; 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 = %33, %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 %36

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

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

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

37:                                               ; preds = %54, %36
  %38 = load i64, ptr %7, align 8, !tbaa !5
  %39 = icmp ult i64 %38, 102400
  br i1 %39, label %41, label %40

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

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

54:                                               ; preds = %41
  %55 = load i64, ptr %7, align 8, !tbaa !5
  %56 = add i64 %55, 1
  store i64 %56, ptr %7, align 8, !tbaa !5
  br label %37, !llvm.loop !15

57:                                               ; preds = %40
  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 %58

58:                                               ; preds = %99, %57
  %59 = load i64, ptr %9, align 8, !tbaa !5
  %60 = icmp ult i64 %59, 102400
  br i1 %60, label %62, label %61

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

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

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

95:                                               ; preds = %77
  %96 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %96, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %102

97:                                               ; preds = %77
  br label %98

98:                                               ; preds = %97, %62
  br label %99

99:                                               ; preds = %98
  %100 = load i64, ptr %9, align 8, !tbaa !5
  %101 = add i64 %100, 1
  store i64 %101, ptr %9, align 8, !tbaa !5
  br label %58, !llvm.loop !18

102:                                              ; preds = %95, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %103 = load i32, ptr %10, align 4
  switch i32 %103, label %111 [
    i32 8, label %104
  ]

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

107:                                              ; preds = %104
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %109

109:                                              ; preds = %107, %104
  %110 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %110, ptr %1, align 4
  store i32 1, ptr %10, align 4
  br label %111

111:                                              ; preds = %109, %102
  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
  %112 = load i32, ptr %1, align 4
  ret i32 %112
}

; 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 = getelementptr inbounds double, ptr %0, i64 %index
  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, ptr %3, align 8, !tbaa !5
  %4 = uitofp <2 x i64> %vec.ind to <2 x double>
  %5 = getelementptr inbounds double, ptr %1, i64 %index
  store <2 x double> %4, ptr %5, align 8, !tbaa !5
  %6 = shl nuw nsw <2 x i64> %vec.ind, <i64 1, i64 1>
  %7 = uitofp nneg <2 x i64> %6 to <2 x double>
  %8 = getelementptr inbounds double, ptr %2, i64 %index
  store <2 x double> %7, ptr %8, align 8, !tbaa !5
  %index.next = or disjoint i64 %index, 2
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %9 = getelementptr inbounds double, ptr %0, i64 %index.next
  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, ptr %9, align 8, !tbaa !5
  %10 = uitofp <2 x i64> %vec.ind.next to <2 x double>
  %11 = getelementptr inbounds double, ptr %1, i64 %index.next
  store <2 x double> %10, ptr %11, align 8, !tbaa !5
  %12 = shl nuw nsw <2 x i64> %vec.ind.next, <i64 1, i64 1>
  %13 = uitofp nneg <2 x i64> %12 to <2 x double>
  %14 = getelementptr inbounds double, ptr %2, i64 %index.next
  store <2 x double> %13, ptr %14, 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>
  %15 = icmp eq i64 %index.next.1, 102400
  br i1 %15, label %vector.body54, label %vector.body, !llvm.loop !9

vector.body54:                                    ; preds = %vector.body, %vector.body54
  %index55 = phi i64 [ %index.next59.1, %vector.body54 ], [ 0, %vector.body ]
  %16 = getelementptr inbounds double, ptr %1, i64 %index55
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load = load <2 x double>, ptr %16, align 8, !tbaa !5
  %wide.load56 = load <2 x double>, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %2, i64 %index55
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load57 = load <2 x double>, ptr %18, align 8, !tbaa !5
  %wide.load58 = load <2 x double>, ptr %19, align 8, !tbaa !5
  %20 = fadd <2 x double> %wide.load, %wide.load57
  %21 = fadd <2 x double> %wide.load56, %wide.load58
  %22 = getelementptr inbounds double, ptr %0, i64 %index55
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store <2 x double> %20, ptr %22, align 8, !tbaa !5
  store <2 x double> %21, ptr %23, align 8, !tbaa !5
  %index.next59 = or disjoint i64 %index55, 4
  %24 = getelementptr inbounds double, ptr %1, i64 %index.next59
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load.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 = getelementptr inbounds double, ptr %2, i64 %index.next59
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %wide.load57.1 = load <2 x double>, ptr %26, align 8, !tbaa !5
  %wide.load58.1 = load <2 x double>, ptr %27, align 8, !tbaa !5
  %28 = fadd <2 x double> %wide.load.1, %wide.load57.1
  %29 = fadd <2 x double> %wide.load56.1, %wide.load58.1
  %30 = getelementptr inbounds double, ptr %0, i64 %index.next59
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  store <2 x double> %28, ptr %30, align 8, !tbaa !5
  store <2 x double> %29, ptr %31, align 8, !tbaa !5
  %index.next59.1 = add nuw nsw i64 %index55, 8
  %32 = icmp eq i64 %index.next59.1, 102400
  br i1 %32, label %.preheader, label %vector.body54, !llvm.loop !13

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

41:                                               ; preds = %.preheader
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %.03847, double noundef %34, double noundef %39)
  br label %43

43:                                               ; preds = %41, %.preheader
  %44 = add nuw nsw i64 %.03847, 1
  %exitcond49.not = icmp eq i64 %44, 102400
  br i1 %exitcond49.not, label %45, label %.preheader, !llvm.loop !14

45:                                               ; preds = %43
  %46 = 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