; LLVM IR from ROCm/aomp :: test/smoke/nested_loop_trunk (nested_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"

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1

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

17:                                               ; preds = %31, %0
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 960
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [960 x double], ptr %3, i64 0, i64 %23
  store double 0.000000e+00, ptr %24, align 8, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [960 x double], ptr %4, i64 0, i64 %26
  store double 0.000000e+00, ptr %27, align 8, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [960 x double], ptr %5, i64 0, i64 %29
  store double 1.000000e+00, ptr %30, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %21
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %6, align 4, !tbaa !5
  br label %17, !llvm.loop !11

34:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 32, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 6, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 5, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %64, %34
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 1
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %67

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

40:                                               ; preds = %60, %39
  %41 = load i32, ptr %15, align 4, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %63

45:                                               ; preds = %40
  %46 = load i32, ptr %15, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [960 x double], ptr %4, i64 0, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !9
  %50 = load i32, ptr %15, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [960 x double], ptr %5, i64 0, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = fadd double %49, %53
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [960 x double], ptr %3, i64 0, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = fadd double %58, %54
  store double %59, ptr %57, align 8, !tbaa !9
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %45
  %61 = load i32, ptr %15, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %15, align 4, !tbaa !5
  br label %40, !llvm.loop !13

63:                                               ; preds = %44
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %13, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %13, align 4, !tbaa !5
  br label %35, !llvm.loop !14

67:                                               ; preds = %38
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = load i32, ptr %12, align 4, !tbaa !5
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %68, i32 noundef %69, i32 noundef %70)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %90, %67
  %73 = load i32, ptr %16, align 4, !tbaa !5
  %74 = icmp slt i32 %73, 5
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  store i32 11, ptr %14, align 4
  br label %93

76:                                               ; preds = %72
  %77 = load i32, ptr %16, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [960 x double], ptr %3, i64 0, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !9
  %81 = fcmp une double %80, 1.000000e+00
  br i1 %81, label %82, label %89

82:                                               ; preds = %76
  %83 = load i32, ptr %16, align 4, !tbaa !5
  %84 = load i32, ptr %16, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [960 x double], ptr %3, i64 0, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !9
  %88 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %83, double noundef 1.000000e+00, double noundef %87)
  store i32 1, ptr %2, align 4, !tbaa !5
  store i32 11, ptr %14, align 4
  br label %93

89:                                               ; preds = %76
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %16, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %16, align 4, !tbaa !5
  br label %72, !llvm.loop !15

93:                                               ; preds = %82, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %2, align 4, !tbaa !5
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %94
  %98 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %14, align 4
  br label %101

99:                                               ; preds = %94
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %14, align 4
  br label %101

101:                                              ; preds = %99, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  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 %7) #3
  call void @llvm.lifetime.end.p0(i64 7680, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 7680, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 7680, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %102 = load i32, ptr %1, align 4
  ret i32 %102
}

; 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

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

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
vector.ph:
  %0 = alloca [960 x double], align 16
  call void @llvm.lifetime.start.p0(i64 7680, ptr nonnull %0) #3
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.5, %vector.body ]
  %1 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index
  %2 = getelementptr inbounds i8, ptr %1, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %1, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %2, align 16, !tbaa !5
  %index.next = or disjoint i64 %index, 4
  %3 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index.next
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %3, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %4, align 16, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 8
  %5 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index.next.1
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %5, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %6, align 16, !tbaa !5
  %index.next.2 = add nuw nsw i64 %index, 12
  %7 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index.next.2
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %7, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %8, align 16, !tbaa !5
  %index.next.3 = add nuw nsw i64 %index, 16
  %9 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index.next.3
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %9, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %10, align 16, !tbaa !5
  %index.next.4 = add nuw nsw i64 %index, 20
  %11 = getelementptr inbounds [960 x double], ptr %0, i64 0, i64 %index.next.4
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %11, align 16, !tbaa !5
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %12, align 16, !tbaa !5
  %index.next.5 = add nuw nsw i64 %index, 24
  %13 = icmp eq i64 %index.next.5, 960
  br i1 %13, label %.preheader.preheader, label %vector.body, !llvm.loop !9

.preheader.preheader:                             ; preds = %vector.body
  %14 = load double, ptr %0, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load double, ptr %17, align 16, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load double, ptr %21, align 16, !tbaa !5
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1, i32 noundef 1, i32 noundef 1)
  %24 = fcmp une double %14, 1.000000e+00
  br i1 %24, label %33, label %25

25:                                               ; preds = %.preheader.preheader
  %26 = fcmp une double %16, 1.000000e+00
  br i1 %26, label %33, label %27

27:                                               ; preds = %25
  %28 = fcmp une double %18, 1.000000e+00
  br i1 %28, label %33, label %29

29:                                               ; preds = %27
  %30 = fcmp une double %20, 1.000000e+00
  br i1 %30, label %33, label %31

31:                                               ; preds = %29
  %32 = fcmp une double %22, 1.000000e+00
  br i1 %32, label %33, label %.critedge

33:                                               ; preds = %31, %29, %27, %25, %.preheader.preheader
  %.036.lcssa.wide = phi i32 [ 0, %.preheader.preheader ], [ 1, %25 ], [ 2, %27 ], [ 3, %29 ], [ 4, %31 ]
  %.lcssa.in = phi double [ %14, %.preheader.preheader ], [ %16, %25 ], [ %18, %27 ], [ %20, %29 ], [ %22, %31 ]
  %.lcssa = fadd double %.lcssa.in, 0.000000e+00
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.036.lcssa.wide, double noundef 1.000000e+00, double noundef %.lcssa)
  br label %.critedge

.critedge:                                        ; preds = %31, %33
  %.str.3.sink = phi ptr [ @.str.2, %33 ], [ @.str.3, %31 ]
  %.028 = phi i32 [ 1, %33 ], [ 0, %31 ]
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  call void @llvm.lifetime.end.p0(i64 7680, ptr nonnull %0) #3
  ret i32 %.028
}

; 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = !{!"double", !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"}


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