; LLVM IR from ROCm/aomp :: test/smoke-fails/target-map-from-fail-array (map-from-into-const-global-scalar)

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

@A = external dso_local constant [128 x i32], align 16
@M = external dso_local global i32, align 4
@B = external dso_local constant [15 x i32], align 16
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %22, %2
  %11 = load i32, ptr %8, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 128
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [128 x i32], ptr @A, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = add nsw i32 %20, %19
  store i32 %21, ptr %7, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %14
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %8, align 4, !tbaa !5
  br label %10, !llvm.loop !11

25:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %39, %25
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 128
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %42

30:                                               ; preds = %26
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = srem i32 %31, 15
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [15 x i32], ptr @B, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr %6, align 4, !tbaa !5
  store i32 42, ptr @M, align 4, !tbaa !5
  br label %39

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

42:                                               ; preds = %29
  %43 = load ptr, ptr @stderr, align 8, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str, i32 noundef %44, i32 noundef %45) #3
  %47 = load ptr, ptr @stderr, align 8, !tbaa !9
  %48 = load i32, ptr @M, align 4, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.1, i32 noundef %48) #3
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = sub nsw i32 %50, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  ret i32 %52
}

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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 = { 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@A = external dso_local local_unnamed_addr constant [128 x i32], align 16
@M = external dso_local local_unnamed_addr global i32, align 4
@B = external dso_local local_unnamed_addr constant [15 x i32], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
vector.ph:
  %wide.load = load <4 x i32>, ptr @A, align 16, !tbaa !5
  %wide.load25 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 16), align 16, !tbaa !5
  %wide.load.1 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 32), align 16, !tbaa !5
  %wide.load25.1 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 48), align 16, !tbaa !5
  %wide.load.2 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 64), align 16, !tbaa !5
  %wide.load25.2 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 80), align 16, !tbaa !5
  %wide.load.3 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 96), align 16, !tbaa !5
  %wide.load25.3 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 112), align 16, !tbaa !5
  %wide.load.4 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 128), align 16, !tbaa !5
  %wide.load25.4 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 144), align 16, !tbaa !5
  %wide.load.5 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 160), align 16, !tbaa !5
  %wide.load25.5 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 176), align 16, !tbaa !5
  %wide.load.6 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 192), align 16, !tbaa !5
  %wide.load25.6 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 208), align 16, !tbaa !5
  %wide.load.7 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 224), align 16, !tbaa !5
  %wide.load25.7 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 240), align 16, !tbaa !5
  %wide.load.8 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 256), align 16, !tbaa !5
  %wide.load25.8 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 272), align 16, !tbaa !5
  %wide.load.9 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 288), align 16, !tbaa !5
  %wide.load25.9 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 304), align 16, !tbaa !5
  %wide.load.10 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 320), align 16, !tbaa !5
  %wide.load25.10 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 336), align 16, !tbaa !5
  %wide.load.11 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 352), align 16, !tbaa !5
  %wide.load25.11 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 368), align 16, !tbaa !5
  %wide.load.12 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 384), align 16, !tbaa !5
  %wide.load25.12 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 400), align 16, !tbaa !5
  %wide.load.13 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 416), align 16, !tbaa !5
  %wide.load25.13 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 432), align 16, !tbaa !5
  %wide.load.14 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 448), align 16, !tbaa !5
  %wide.load25.14 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 464), align 16, !tbaa !5
  %wide.load.15 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 480), align 16, !tbaa !5
  %wide.load25.15 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @A, i64 496), align 16, !tbaa !5
  br label %70

2:                                                ; preds = %70
  %3 = add <4 x i32> %wide.load25, <i32 2, i32 2, i32 2, i32 2>
  %4 = add <4 x i32> %3, %wide.load25.1
  %5 = add <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
  %6 = add <4 x i32> %5, %wide.load25.2
  %7 = add <4 x i32> %6, <i32 1, i32 1, i32 1, i32 1>
  %8 = add <4 x i32> %7, %wide.load25.3
  %9 = add <4 x i32> %8, <i32 1, i32 1, i32 1, i32 1>
  %10 = add <4 x i32> %9, %wide.load25.4
  %11 = add <4 x i32> %10, <i32 1, i32 1, i32 1, i32 1>
  %12 = add <4 x i32> %11, %wide.load25.5
  %13 = add <4 x i32> %12, <i32 1, i32 1, i32 1, i32 1>
  %14 = add <4 x i32> %13, %wide.load25.6
  %15 = add <4 x i32> %14, <i32 1, i32 1, i32 1, i32 1>
  %16 = add <4 x i32> %15, %wide.load25.7
  %17 = add <4 x i32> %16, <i32 1, i32 1, i32 1, i32 1>
  %18 = add <4 x i32> %17, %wide.load25.8
  %19 = add <4 x i32> %18, <i32 1, i32 1, i32 1, i32 1>
  %20 = add <4 x i32> %19, %wide.load25.9
  %21 = add <4 x i32> %20, <i32 1, i32 1, i32 1, i32 1>
  %22 = add <4 x i32> %21, %wide.load25.10
  %23 = add <4 x i32> %22, <i32 1, i32 1, i32 1, i32 1>
  %24 = add <4 x i32> %23, %wide.load25.11
  %25 = add <4 x i32> %24, <i32 1, i32 1, i32 1, i32 1>
  %26 = add <4 x i32> %25, %wide.load25.12
  %27 = add <4 x i32> %26, <i32 1, i32 1, i32 1, i32 1>
  %28 = add <4 x i32> %27, %wide.load25.13
  %29 = add <4 x i32> %28, <i32 1, i32 1, i32 1, i32 1>
  %30 = add <4 x i32> %29, %wide.load25.14
  %31 = add <4 x i32> %30, <i32 1, i32 1, i32 1, i32 1>
  %32 = add <4 x i32> %31, %wide.load25.15
  %33 = add <4 x i32> %wide.load, <i32 2, i32 2, i32 2, i32 2>
  %34 = add <4 x i32> %33, %wide.load.1
  %35 = add <4 x i32> %34, <i32 1, i32 1, i32 1, i32 1>
  %36 = add <4 x i32> %35, %wide.load.2
  %37 = add <4 x i32> %36, <i32 1, i32 1, i32 1, i32 1>
  %38 = add <4 x i32> %37, %wide.load.3
  %39 = add <4 x i32> %38, <i32 1, i32 1, i32 1, i32 1>
  %40 = add <4 x i32> %39, %wide.load.4
  %41 = add <4 x i32> %40, <i32 1, i32 1, i32 1, i32 1>
  %42 = add <4 x i32> %41, %wide.load.5
  %43 = add <4 x i32> %42, <i32 1, i32 1, i32 1, i32 1>
  %44 = add <4 x i32> %43, %wide.load.6
  %45 = add <4 x i32> %44, <i32 1, i32 1, i32 1, i32 1>
  %46 = add <4 x i32> %45, %wide.load.7
  %47 = add <4 x i32> %46, <i32 1, i32 1, i32 1, i32 1>
  %48 = add <4 x i32> %47, %wide.load.8
  %49 = add <4 x i32> %48, <i32 1, i32 1, i32 1, i32 1>
  %50 = add <4 x i32> %49, %wide.load.9
  %51 = add <4 x i32> %50, <i32 1, i32 1, i32 1, i32 1>
  %52 = add <4 x i32> %51, %wide.load.10
  %53 = add <4 x i32> %52, <i32 1, i32 1, i32 1, i32 1>
  %54 = add <4 x i32> %53, %wide.load.11
  %55 = add <4 x i32> %54, <i32 1, i32 1, i32 1, i32 1>
  %56 = add <4 x i32> %55, %wide.load.12
  %57 = add <4 x i32> %56, <i32 1, i32 1, i32 1, i32 1>
  %58 = add <4 x i32> %57, %wide.load.13
  %59 = add <4 x i32> %58, <i32 1, i32 1, i32 1, i32 1>
  %60 = add <4 x i32> %59, %wide.load.14
  %61 = add <4 x i32> %60, <i32 1, i32 1, i32 1, i32 1>
  %62 = add <4 x i32> %61, %wide.load.15
  %bin.rdx = add <4 x i32> %32, %62
  %63 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  store i32 42, ptr @M, align 4, !tbaa !5
  %64 = load ptr, ptr @stderr, align 8, !tbaa !9
  %65 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %64, ptr noundef nonnull @.str, i32 noundef %83, i32 noundef %63) #3
  %66 = load ptr, ptr @stderr, align 8, !tbaa !9
  %67 = load i32, ptr @M, align 4, !tbaa !5
  %68 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef nonnull @.str.1, i32 noundef %67) #3
  %69 = sub nsw i32 %83, %63
  ret i32 %69

70:                                               ; preds = %70, %vector.ph
  %.018 = phi i32 [ 0, %vector.ph ], [ %84, %70 ]
  %.01417 = phi i32 [ 0, %vector.ph ], [ %83, %70 ]
  %.lhs.trunc = trunc nuw i32 %.018 to i8
  %71 = urem i8 %.lhs.trunc, 15
  %72 = zext nneg i8 %71 to i64
  %73 = getelementptr inbounds [15 x i32], ptr @B, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add i32 %.01417, 1
  %76 = add i32 %75, %74
  %77 = trunc i32 %.018 to i8
  %.lhs.trunc.1 = or disjoint i8 %77, 1
  %78 = urem i8 %.lhs.trunc.1, 15
  %79 = zext nneg i8 %78 to i64
  %80 = getelementptr inbounds [15 x i32], ptr @B, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = add i32 %76, 1
  %83 = add i32 %82, %81
  %84 = add nuw nsw i32 %.018, 2
  %exitcond21.not.1 = icmp eq i32 %84, 128
  br i1 %exitcond21.not.1, label %2, label %70, !llvm.loop !11
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #2

attributes #0 = { nofree 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" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { cold 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass