; LLVM IR from ROCm/aomp :: test/smoke-fails/march-native-459012 (vmul)

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

; Function Attrs: nounwind uwtable
declare dso_local void @vmul(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #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: nounwind uwtable
define dso_local 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 100000, ptr %2, align 4, !tbaa !5
  %8 = call ptr @llvm.stacksave.p0()
  store ptr %8, ptr %3, align 8
  %9 = alloca i32, i64 100000, align 16
  %10 = alloca i32, i64 100000, align 16
  %11 = alloca i32, i64 100000, align 16
  %12 = alloca i32, i64 100000, align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 -1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %40, %0
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 100000
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %9, i64 %21
  store i32 %19, ptr %22, align 4, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = add nsw i32 %23, 2
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr %10, i64 %26
  store i32 %24, ptr %27, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %9, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %10, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = mul nsw i32 %31, %35
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %12, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %17
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !5
  br label %13, !llvm.loop !9

43:                                               ; preds = %16
  call void @vmul(ptr noundef %9, ptr noundef %10, ptr noundef %11, i32 noundef 100000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %76, %43
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 100000
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %79

48:                                               ; preds = %44
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %11, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %12, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp ne i32 %52, %56
  br i1 %57, label %58, label %75

58:                                               ; preds = %48
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = icmp eq i32 %59, -1
  br i1 %60, label %61, label %73

61:                                               ; preds = %58
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %11, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr %12, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %62, i32 noundef %66, i32 noundef %67, i32 noundef %71)
  br label %73

73:                                               ; preds = %61, %58
  %74 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %74, ptr %4, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %73, %48
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %6, align 4, !tbaa !5
  br label %44, !llvm.loop !11

79:                                               ; preds = %47
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = icmp eq i32 %80, -1
  br i1 %81, label %82, label %84

82:                                               ; preds = %79
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %97

84:                                               ; preds = %79
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i32, ptr %11, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr %12, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %85, i32 noundef %89, i32 noundef %90, i32 noundef %94)
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %97

97:                                               ; preds = %84, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %98 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %98)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %99 = load i32, ptr %1, align 4
  ret i32 %99
}

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

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

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

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

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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

; Function Attrs: nounwind uwtable
declare dso_local void @vmul(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
vector.ph:
  %0 = alloca [100000 x i32], align 16
  %1 = alloca [100000 x i32], align 16
  %2 = alloca [100000 x i32], align 16
  %3 = alloca [100000 x i32], align 16
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %4 = add nuw nsw <4 x i64> %vec.ind, <i64 1, i64 1, i64 1, i64 1>
  %5 = getelementptr inbounds i32, ptr %0, i64 %index
  %6 = trunc <4 x i64> %4 to <4 x i32>
  store <4 x i32> %6, ptr %5, align 16, !tbaa !5
  %7 = add nuw nsw <4 x i64> %vec.ind, <i64 2, i64 2, i64 2, i64 2>
  %8 = getelementptr inbounds i32, ptr %1, i64 %index
  %9 = trunc <4 x i64> %7 to <4 x i32>
  store <4 x i32> %9, ptr %8, align 16, !tbaa !5
  %10 = mul nuw nsw <4 x i64> %4, %7
  %11 = getelementptr inbounds i32, ptr %3, i64 %index
  %12 = trunc <4 x i64> %10 to <4 x i32>
  store <4 x i32> %12, ptr %11, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i64> %vec.ind, <i64 4, i64 4, i64 4, i64 4>
  %13 = icmp eq i64 %index.next, 100000
  br i1 %13, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  call void @vmul(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, i32 noundef 100000)
  br label %16

14:                                               ; preds = %26
  %15 = icmp eq i32 %.1, -1
  br i1 %15, label %34, label %27

16:                                               ; preds = %middle.block, %26
  %indvars.iv34 = phi i64 [ 0, %middle.block ], [ %indvars.iv.next35, %26 ]
  %.02631 = phi i32 [ -1, %middle.block ], [ %.1, %26 ]
  %17 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv34
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv34
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not = icmp eq i32 %18, %20
  br i1 %.not, label %26, label %21

21:                                               ; preds = %16
  %22 = icmp eq i32 %.02631, -1
  %23 = trunc nuw nsw i64 %indvars.iv34 to i32
  br i1 %22, label %24, label %26

24:                                               ; preds = %21
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %23, i32 noundef %18, i32 noundef %23, i32 noundef %20)
  br label %26

26:                                               ; preds = %21, %24, %16
  %.1 = phi i32 [ %.02631, %16 ], [ %23, %24 ], [ %23, %21 ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next35, 100000
  br i1 %exitcond37.not, label %14, label %16, !llvm.loop !13

27:                                               ; preds = %14
  %28 = sext i32 %.1 to i64
  %29 = getelementptr inbounds i32, ptr %2, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %3, i64 %28
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.1, i32 noundef %30, i32 noundef %.1, i32 noundef %32)
  br label %34

34:                                               ; preds = %14, %27
  %.str.3.sink = phi ptr [ @.str.3, %27 ], [ @.str.1, %14 ]
  %.027 = phi i32 [ 1, %27 ], [ 0, %14 ]
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  ret i32 %.027
}

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

attributes #0 = { 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 #1 = { 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" }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass