; LLVM IR from ROCm/aomp :: test/smoke-fails/CountPrimes (CountPrimes)

; 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 [38 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @is_prime(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
declare dso_local zeroext i1 @is_primeT(i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [1000 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %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
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4000, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %13

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

16:                                               ; preds = %13
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = call zeroext i1 @is_prime(i32 noundef %17)
  br i1 %18, label %19, label %26

19:                                               ; preds = %16
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1000 x i32], ptr %2, i64 0, i64 %22
  store i32 %20, ptr %23, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %19, %16
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %6, align 4, !tbaa !5
  br label %13, !llvm.loop !9

29:                                               ; preds = %13
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef 1000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %41, %29
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 1000
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %44

35:                                               ; preds = %31
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1000 x i32], ptr %2, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %39)
  br label %41

41:                                               ; preds = %35
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !11

44:                                               ; preds = %34
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %46 = getelementptr inbounds [1000 x i32], ptr %2, i64 0, i64 999
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = mul nsw i32 %48, %49
  store i32 %50, ptr %9, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %51, i32 noundef %52)
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %54 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %54, ptr %10, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %68, %44
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %55
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = getelementptr inbounds [1000 x i32], ptr %2, i64 0, i64 0
  %63 = call zeroext i1 @is_primeT(i32 noundef %61, ptr noundef %62, i32 noundef 1000)
  br i1 %63, label %64, label %67

64:                                               ; preds = %60
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %3, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %64, %60
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = add nsw i32 %69, 2
  store i32 %70, ptr %10, align 4, !tbaa !5
  br label %55, !llvm.loop !12

71:                                               ; preds = %59
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %72)
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %74 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %74, ptr %11, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %88, %71
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = icmp sle i32 %76, %77
  br i1 %78, label %80, label %79

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

80:                                               ; preds = %75
  %81 = load i32, ptr %11, align 4, !tbaa !5
  %82 = getelementptr inbounds [1000 x i32], ptr %2, i64 0, i64 0
  %83 = call zeroext i1 @is_primeT(i32 noundef %81, ptr noundef %82, i32 noundef 1000)
  br i1 %83, label %84, label %87

84:                                               ; preds = %80
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %4, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %84, %80
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %11, align 4, !tbaa !5
  %90 = add nsw i32 %89, 2
  store i32 %90, ptr %11, align 4, !tbaa !5
  br label %75, !llvm.loop !13

91:                                               ; preds = %79
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %92)
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = icmp eq i32 %94, %95
  br i1 %96, label %97, label %98

97:                                               ; preds = %91
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %99

98:                                               ; preds = %91
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %99

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

declare i32 @printf(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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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 [38 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @is_prime(i32 noundef) local_unnamed_addr #0

; 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: nounwind uwtable
declare dso_local zeroext i1 @is_primeT(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
  %1 = alloca [1000 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 4000, ptr nonnull %1) #3
  br label %2

2:                                                ; preds = %0, %8
  %.03443 = phi i32 [ 2, %0 ], [ %9, %8 ]
  %.03542 = phi i32 [ 0, %0 ], [ %.136, %8 ]
  %3 = tail call zeroext i1 @is_prime(i32 noundef %.03443)
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = sext i32 %.03542 to i64
  %6 = getelementptr inbounds [1000 x i32], ptr %1, i64 0, i64 %5
  store i32 %.03443, ptr %6, align 4, !tbaa !5
  %7 = add nsw i32 %.03542, 1
  br label %8

8:                                                ; preds = %4, %2
  %.136 = phi i32 [ %7, %4 ], [ %.03542, %2 ]
  %9 = add nuw nsw i32 %.03443, 1
  %10 = icmp slt i32 %.136, 1000
  br i1 %10, label %2, label %11, !llvm.loop !9

11:                                               ; preds = %8
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1000)
  br label %20

13:                                               ; preds = %20
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %15 = getelementptr inbounds i8, ptr %1, i64 3996
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = mul nsw i32 %16, %16
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %16, i32 noundef %17)
  %.not45 = icmp sgt i32 %16, %17
  br i1 %.not45, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %13
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef 0)
  br label %._crit_edge53

20:                                               ; preds = %11, %20
  %indvars.iv = phi i64 [ 0, %11 ], [ %indvars.iv.next, %20 ]
  %21 = getelementptr inbounds [1000 x i32], ptr %1, i64 0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %22)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1000
  br i1 %exitcond.not, label %13, label %20, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %spec.select)
  br i1 %.not45, label %._crit_edge53, label %.lr.ph52

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.03047 = phi i32 [ %27, %.lr.ph ], [ %16, %13 ]
  %.03246 = phi i32 [ %spec.select, %.lr.ph ], [ 0, %13 ]
  %25 = call zeroext i1 @is_primeT(i32 noundef %.03047, ptr noundef nonnull %1, i32 noundef 1000)
  %26 = zext i1 %25 to i32
  %spec.select = add nuw nsw i32 %.03246, %26
  %27 = add nsw i32 %.03047, 2
  %.not = icmp sgt i32 %27, %17
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge53:                                    ; preds = %.lr.ph52, %._crit_edge.thread, %._crit_edge
  %.032.lcssa57 = phi i32 [ %spec.select, %._crit_edge ], [ 0, %._crit_edge.thread ], [ %spec.select, %.lr.ph52 ]
  %.037.lcssa = phi i32 [ 0, %._crit_edge ], [ 0, %._crit_edge.thread ], [ %spec.select41, %.lr.ph52 ]
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %.037.lcssa)
  %29 = icmp ne i32 %.037.lcssa, %.032.lcssa57
  %. = sext i1 %29 to i32
  call void @llvm.lifetime.end.p0(i64 4000, ptr nonnull %1) #3
  ret i32 %.

.lr.ph52:                                         ; preds = %._crit_edge, %.lr.ph52
  %.050 = phi i32 [ %32, %.lr.ph52 ], [ %16, %._crit_edge ]
  %.03749 = phi i32 [ %spec.select41, %.lr.ph52 ], [ 0, %._crit_edge ]
  %30 = call zeroext i1 @is_primeT(i32 noundef %.050, ptr noundef nonnull %1, i32 noundef 1000)
  %31 = zext i1 %30 to i32
  %spec.select41 = add nuw nsw i32 %.03749, %31
  %32 = add nsw i32 %.050, 2
  %.not40 = icmp sgt i32 %32, %17
  br i1 %.not40, label %._crit_edge53, label %.lr.ph52, !llvm.loop !13
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass