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

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

%struct.Val_t = type { double }

@A = external dso_local constant [128 x %struct.Val_t], align 16
@M = external dso_local global %struct.Val_t, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [8 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
  %10 = 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
  store double 1.000000e+00, ptr @M, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %11

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

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

15:                                               ; preds = %11
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %6, align 4, !tbaa !5
  store double 4.200000e+01, ptr @M, align 8, !tbaa !11
  br label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %8, align 4, !tbaa !5
  br label %11, !llvm.loop !14

21:                                               ; preds = %14
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sub nsw i32 128, %22
  store i32 %23, ptr %7, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %21
  %27 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %73

28:                                               ; preds = %21
  %29 = load double, ptr @M, align 8, !tbaa !11
  %30 = fsub double 4.200000e+01, %29
  %31 = fptosi double %30 to i32
  store i32 %31, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %28
  %35 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %35, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %73

36:                                               ; preds = %28
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %52, %36
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 128
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %55

41:                                               ; preds = %37
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [128 x %struct.Val_t], ptr @A, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Val_t, ptr %44, i32 0, i32 0
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fadd double %46, 1.000000e+00
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sitofp i32 %48 to double
  %50 = fadd double %49, %47
  %51 = fptosi double %50 to i32
  store i32 %51, ptr %6, align 4, !tbaa !5
  store double 4.200000e+01, ptr @M, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %41
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %10, align 4, !tbaa !5
  br label %37, !llvm.loop !16

55:                                               ; preds = %40
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sub nsw i32 128, %56
  store i32 %57, ptr %7, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %55
  %61 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %61, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %73

62:                                               ; preds = %55
  %63 = load double, ptr @M, align 8, !tbaa !11
  %64 = fsub double 4.200000e+01, %63
  %65 = fptosi double %64 to i32
  store i32 %65, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %62
  %69 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %69, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %73

70:                                               ; preds = %62
  %71 = load ptr, ptr @stderr, align 8, !tbaa !9
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str) #3
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %73

73:                                               ; preds = %70, %68, %60, %34, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %74 = load i32, ptr %3, align 4
  ret i32 %74
}

; 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 = !{!12, !13, i64 0}
!12 = !{!"Val_t", !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

%struct.Val_t = type { double }

@A = external dso_local local_unnamed_addr constant [128 x %struct.Val_t], align 16
@M = external dso_local local_unnamed_addr global %struct.Val_t, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [8 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 {
.preheader.preheader:
  br label %.preheader

2:                                                ; preds = %.preheader
  store double 4.200000e+01, ptr @M, align 8, !tbaa !5
  %.not26 = icmp eq i32 %26, 128
  br i1 %.not26, label %29, label %27

.preheader:                                       ; preds = %.preheader, %.preheader.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next.3, %.preheader ]
  %.130 = phi i32 [ 0, %.preheader.preheader ], [ %26, %.preheader ]
  %3 = getelementptr inbounds [128 x %struct.Val_t], ptr @A, i64 0, i64 %indvars.iv
  %4 = load double, ptr %3, align 16, !tbaa !5
  %5 = fadd double %4, 1.000000e+00
  %6 = sitofp i32 %.130 to double
  %7 = fadd double %5, %6
  %8 = fptosi double %7 to i32
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds [128 x %struct.Val_t], ptr @A, i64 0, i64 %indvars.iv.next
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fadd double %10, 1.000000e+00
  %12 = sitofp i32 %8 to double
  %13 = fadd double %11, %12
  %14 = fptosi double %13 to i32
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %15 = getelementptr inbounds [128 x %struct.Val_t], ptr @A, i64 0, i64 %indvars.iv.next.1
  %16 = load double, ptr %15, align 16, !tbaa !5
  %17 = fadd double %16, 1.000000e+00
  %18 = sitofp i32 %14 to double
  %19 = fadd double %17, %18
  %20 = fptosi double %19 to i32
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %21 = getelementptr inbounds [128 x %struct.Val_t], ptr @A, i64 0, i64 %indvars.iv.next.2
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fadd double %22, 1.000000e+00
  %24 = sitofp i32 %20 to double
  %25 = fadd double %23, %24
  %26 = fptosi double %25 to i32
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, 128
  br i1 %exitcond.not.3, label %2, label %.preheader, !llvm.loop !10

27:                                               ; preds = %2
  %28 = sub nsw i32 128, %26
  br label %32

29:                                               ; preds = %2
  %30 = load ptr, ptr @stderr, align 8, !tbaa !12
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str) #2
  br label %32

32:                                               ; preds = %29, %27
  %.020 = phi i32 [ %28, %27 ], [ 0, %29 ]
  ret i32 %.020
}

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

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 = { 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, !7, i64 0}
!6 = !{!"Val_t", !7, i64 0}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass