; LLVM IR from ROCm/aomp :: test/LLNL/openmp5.0-tests (test_imperfect_loop)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef 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 [100 x [100 x double]], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = 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 100, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80000, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %36, %2
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 100
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %39

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

21:                                               ; preds = %32, %20
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 100
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %21
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100 x [100 x double]], ptr %7, i64 0, i64 %27
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100 x double], ptr %28, i64 0, i64 %30
  store double 0.000000e+00, ptr %31, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %25
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %10, align 4, !tbaa !5
  br label %21, !llvm.loop !13

35:                                               ; preds = %24
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %8, align 4, !tbaa !5
  br label %16, !llvm.loop !15

39:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %75, %39
  %41 = load i32, ptr %11, align 4, !tbaa !5
  %42 = icmp slt i32 %41, 100
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %78

44:                                               ; preds = %40
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = mul nsw i32 10, %45
  %47 = sitofp i32 %46 to double
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100 x [100 x double]], ptr %7, i64 0, i64 %49
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [100 x double], ptr %50, i64 0, i64 %52
  store double %47, ptr %53, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %71, %44
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = icmp slt i32 %55, 100
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %74

58:                                               ; preds = %54
  %59 = load i32, ptr %11, align 4, !tbaa !5
  %60 = load i32, ptr %12, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  %62 = sitofp i32 %61 to double
  %63 = load i32, ptr %11, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100 x [100 x double]], ptr %7, i64 0, i64 %64
  %66 = load i32, ptr %12, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100 x double], ptr %65, i64 0, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !11
  %70 = fadd double %69, %62
  store double %70, ptr %68, align 8, !tbaa !11
  br label %71

71:                                               ; preds = %58
  %72 = load i32, ptr %12, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %12, align 4, !tbaa !5
  br label %54, !llvm.loop !16

74:                                               ; preds = %57
  br label %75

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

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

79:                                               ; preds = %109, %78
  %80 = load i32, ptr %14, align 4, !tbaa !5
  %81 = icmp slt i32 %80, 100
  br i1 %81, label %83, label %82

82:                                               ; preds = %79
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %112

83:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %105, %83
  %85 = load i32, ptr %15, align 4, !tbaa !5
  %86 = icmp slt i32 %85, 100
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  store i32 17, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %108

88:                                               ; preds = %84
  %89 = load i32, ptr %14, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100 x [100 x double]], ptr %7, i64 0, i64 %90
  %92 = load i32, ptr %15, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100 x double], ptr %91, i64 0, i64 %93
  %95 = load double, ptr %94, align 8, !tbaa !11
  %96 = load i32, ptr %14, align 4, !tbaa !5
  %97 = load i32, ptr %15, align 4, !tbaa !5
  %98 = add nsw i32 %96, %97
  %99 = sitofp i32 %98 to double
  %100 = fsub double %95, %99
  %101 = load i32, ptr %13, align 4, !tbaa !5
  %102 = sitofp i32 %101 to double
  %103 = fadd double %102, %100
  %104 = fptosi double %103 to i32
  store i32 %104, ptr %13, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %88
  %106 = load i32, ptr %15, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %15, align 4, !tbaa !5
  br label %84, !llvm.loop !18

108:                                              ; preds = %87
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %14, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %14, align 4, !tbaa !5
  br label %79, !llvm.loop !19

112:                                              ; preds = %82
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = icmp ne i32 %113, 49500
  br i1 %114, label %115, label %117

115:                                              ; preds = %112
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %119

117:                                              ; preds = %112
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %119

119:                                              ; preds = %117, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 80000, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %120 = load i32, ptr %3, align 4
  ret i32 %120
}

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #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++ 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 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !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"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
.preheader36.preheader:
  %2 = alloca [100 x [100 x double]], align 16
  call void @llvm.lifetime.start.p0(i64 80000, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80000) %2, i8 0, i64 80000, i1 false), !tbaa !5
  br label %.preheader36

.preheader36:                                     ; preds = %.preheader36.preheader, %middle.block
  %indvars.iv49 = phi i64 [ 0, %.preheader36.preheader ], [ %indvars.iv.next50, %middle.block ]
  %3 = trunc i64 %indvars.iv49 to i32
  %4 = mul i32 %3, 10
  %5 = uitofp nneg i32 %4 to double
  %6 = getelementptr inbounds [100 x [100 x double]], ptr %2, i64 0, i64 %indvars.iv49, i64 %indvars.iv49
  store double %5, ptr %6, align 8, !tbaa !5
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %indvars.iv49, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.preheader36
  %index = phi i64 [ 0, %.preheader36 ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %.preheader36 ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %7 = add nuw nsw <2 x i64> %vec.ind, %broadcast.splat
  %8 = add nuw nsw <2 x i64> %step.add, %broadcast.splat
  %9 = trunc <2 x i64> %7 to <2 x i32>
  %10 = trunc <2 x i64> %8 to <2 x i32>
  %11 = uitofp <2 x i32> %9 to <2 x double>
  %12 = uitofp <2 x i32> %10 to <2 x double>
  %13 = getelementptr inbounds [100 x [100 x double]], ptr %2, i64 0, i64 %indvars.iv49, i64 %index
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %wide.load = load <2 x double>, ptr %13, align 16, !tbaa !5
  %wide.load62 = load <2 x double>, ptr %14, align 16, !tbaa !5
  %15 = fadd <2 x double> %wide.load, %11
  %16 = fadd <2 x double> %wide.load62, %12
  store <2 x double> %15, ptr %13, align 16, !tbaa !5
  store <2 x double> %16, ptr %14, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %17 = icmp eq i64 %index.next, 100
  br i1 %17, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond52.not = icmp eq i64 %indvars.iv.next50, 100
  br i1 %exitcond52.not, label %.preheader, label %.preheader36, !llvm.loop !13

.preheader:                                       ; preds = %middle.block, %20
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %20 ], [ 0, %middle.block ]
  %.02944 = phi i32 [ %39, %20 ], [ 0, %middle.block ]
  br label %21

18:                                               ; preds = %20
  %.not = icmp ne i32 %39, 49500
  %.str.1..str = select i1 %.not, ptr @.str, ptr @.str.1
  %. = zext i1 %.not to i32
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str.1..str)
  call void @llvm.lifetime.end.p0(i64 80000, ptr nonnull %2) #4
  ret i32 %.

20:                                               ; preds = %21
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %exitcond60.not = icmp eq i64 %indvars.iv.next58, 100
  br i1 %exitcond60.not, label %18, label %.preheader, !llvm.loop !14

21:                                               ; preds = %21, %.preheader
  %indvars.iv53 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next54.1, %21 ]
  %.142 = phi i32 [ %.02944, %.preheader ], [ %39, %21 ]
  %22 = getelementptr inbounds [100 x [100 x double]], ptr %2, i64 0, i64 %indvars.iv57, i64 %indvars.iv53
  %23 = load double, ptr %22, align 16, !tbaa !5
  %24 = add nuw nsw i64 %indvars.iv53, %indvars.iv57
  %25 = trunc nuw nsw i64 %24 to i32
  %26 = uitofp nneg i32 %25 to double
  %27 = fsub double %23, %26
  %28 = sitofp i32 %.142 to double
  %29 = fadd double %27, %28
  %30 = fptosi double %29 to i32
  %indvars.iv.next54 = or disjoint i64 %indvars.iv53, 1
  %31 = getelementptr inbounds [100 x [100 x double]], ptr %2, i64 0, i64 %indvars.iv57, i64 %indvars.iv.next54
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = add nuw nsw i64 %indvars.iv.next54, %indvars.iv57
  %34 = trunc nuw nsw i64 %33 to i32
  %35 = uitofp nneg i32 %34 to double
  %36 = fsub double %32, %35
  %37 = sitofp i32 %30 to double
  %38 = fadd double %36, %37
  %39 = fptosi double %38 to i32
  %indvars.iv.next54.1 = add nuw nsw i64 %indvars.iv53, 2
  %exitcond56.not.1 = icmp eq i64 %indvars.iv.next54.1, 100
  br i1 %exitcond56.not.1, label %20, label %21, !llvm.loop !15
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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