; LLVM IR from ROCm/aomp :: test/smoke/targc-272328 (targc-272328)

; 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.test_type = type { ptr }

@tt = external dso_local global %struct.test_type, align 8
@C = external dso_local global [10 x i32], align 16
@E = external dso_local global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [5 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 ptr, align 8
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %5 = call noalias ptr @malloc(i64 noundef 40) #5
  store ptr %5, ptr @tt, align 8, !tbaa !5
  %6 = load ptr, ptr @tt, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !10
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %20, %0
  %8 = load i32, ptr %2, align 4, !tbaa !11
  %9 = icmp slt i32 %8, 10
  br i1 %9, label %10, label %23

10:                                               ; preds = %7
  %11 = load i32, ptr %2, align 4, !tbaa !11
  %12 = add nsw i32 %11, 100
  %13 = load ptr, ptr @tt, align 8, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !11
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i32, ptr %13, i64 %15
  store i32 %12, ptr %16, align 4, !tbaa !11
  %17 = load i32, ptr %2, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %18
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %10
  %21 = load i32, ptr %2, align 4, !tbaa !11
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !11
  br label %7, !llvm.loop !13

23:                                               ; preds = %7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %42, %23
  %25 = load i32, ptr %2, align 4, !tbaa !11
  %26 = icmp slt i32 %25, 10
  br i1 %26, label %27, label %45

27:                                               ; preds = %24
  %28 = load i32, ptr %2, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = add nsw i32 %31, 10
  %33 = load ptr, ptr @tt, align 8, !tbaa !5
  %34 = load i32, ptr %2, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %33, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = add nsw i32 %32, %37
  %39 = load i32, ptr %2, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10 x i32], ptr @E, i64 0, i64 %40
  store i32 %38, ptr %41, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %27
  %43 = load i32, ptr %2, align 4, !tbaa !11
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %2, align 4, !tbaa !11
  br label %24, !llvm.loop !15

45:                                               ; preds = %24
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %64, %45
  %47 = load i32, ptr %2, align 4, !tbaa !11
  %48 = icmp slt i32 %47, 10
  br i1 %48, label %49, label %67

49:                                               ; preds = %46
  %50 = load i32, ptr %2, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !11
  %54 = add nsw i32 %53, 10
  %55 = load ptr, ptr @tt, align 8, !tbaa !5
  %56 = load i32, ptr %2, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = add nsw i32 %54, %59
  %61 = load i32, ptr %2, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %62
  store i32 %60, ptr %63, align 4, !tbaa !11
  br label %64

64:                                               ; preds = %49
  %65 = load i32, ptr %2, align 4, !tbaa !11
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %2, align 4, !tbaa !11
  br label %46, !llvm.loop !16

67:                                               ; preds = %46
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %88, %67
  %69 = load i32, ptr %2, align 4, !tbaa !11
  %70 = icmp slt i32 %69, 10
  br i1 %70, label %71, label %91

71:                                               ; preds = %68
  %72 = load i32, ptr %2, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !11
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %75)
  %77 = load i32, ptr %2, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [10 x i32], ptr @E, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !11
  %81 = load i32, ptr %2, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [10 x i32], ptr @C, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = icmp ne i32 %80, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %71
  store i32 1, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %92

87:                                               ; preds = %71
  br label %88

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

91:                                               ; preds = %68
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %92

92:                                               ; preds = %91, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %93 = load i32, ptr %1, align 4
  ret i32 %93
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare i32 @printf(ptr noundef, ...) #3

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

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 allocsize(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 = { "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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

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

%struct.test_type = type { ptr }

@tt = external dso_local local_unnamed_addr global %struct.test_type, align 8
@C = external dso_local local_unnamed_addr global [10 x i32], align 16
@E = external dso_local local_unnamed_addr global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
.preheader23.preheader:
  %0 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #3
  store ptr %0, ptr @tt, align 8, !tbaa !5
  store <4 x i32> <i32 100, i32 101, i32 102, i32 103>, ptr %0, align 4, !tbaa !10
  %1 = getelementptr inbounds i8, ptr %0, i64 16
  store <4 x i32> <i32 104, i32 105, i32 106, i32 107>, ptr %1, align 4, !tbaa !10
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 108, ptr %2, align 4, !tbaa !10
  %3 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 109, ptr %3, align 4, !tbaa !10
  store <4 x i32> <i32 110, i32 111, i32 112, i32 113>, ptr @E, align 16, !tbaa !10
  store <4 x i32> <i32 114, i32 115, i32 116, i32 117>, ptr getelementptr inbounds (i8, ptr @E, i64 16), align 16, !tbaa !10
  store i32 118, ptr getelementptr inbounds (i8, ptr @E, i64 32), align 16, !tbaa !10
  store i32 119, ptr getelementptr inbounds (i8, ptr @E, i64 36), align 4, !tbaa !10
  store <4 x i32> <i32 110, i32 111, i32 112, i32 113>, ptr @C, align 16, !tbaa !10
  store <4 x i32> <i32 114, i32 115, i32 116, i32 117>, ptr getelementptr inbounds (i8, ptr @C, i64 16), align 16, !tbaa !10
  store i32 118, ptr getelementptr inbounds (i8, ptr @C, i64 32), align 16, !tbaa !10
  store i32 119, ptr getelementptr inbounds (i8, ptr @C, i64 36), align 4, !tbaa !10
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 110)
  %5 = load i32, ptr @E, align 16, !tbaa !10
  %6 = load i32, ptr @C, align 16, !tbaa !10
  %.not = icmp eq i32 %5, %6
  br i1 %.not, label %.preheader.1, label %43

.preheader.1:                                     ; preds = %.preheader23.preheader
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 4), align 4, !tbaa !10
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %7)
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 4), align 4, !tbaa !10
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 4), align 4, !tbaa !10
  %.not.1 = icmp eq i32 %9, %10
  br i1 %.not.1, label %.preheader.2, label %43

.preheader.2:                                     ; preds = %.preheader.1
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 8), align 8, !tbaa !10
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %11)
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 8), align 8, !tbaa !10
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 8), align 8, !tbaa !10
  %.not.2 = icmp eq i32 %13, %14
  br i1 %.not.2, label %.preheader.3, label %43

.preheader.3:                                     ; preds = %.preheader.2
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 12), align 4, !tbaa !10
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %15)
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 12), align 4, !tbaa !10
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 12), align 4, !tbaa !10
  %.not.3 = icmp eq i32 %17, %18
  br i1 %.not.3, label %.preheader.4, label %43

.preheader.4:                                     ; preds = %.preheader.3
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 16), align 16, !tbaa !10
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %19)
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 16), align 16, !tbaa !10
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 16), align 16, !tbaa !10
  %.not.4 = icmp eq i32 %21, %22
  br i1 %.not.4, label %.preheader.5, label %43

.preheader.5:                                     ; preds = %.preheader.4
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 20), align 4, !tbaa !10
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %23)
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 20), align 4, !tbaa !10
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 20), align 4, !tbaa !10
  %.not.5 = icmp eq i32 %25, %26
  br i1 %.not.5, label %.preheader.6, label %43

.preheader.6:                                     ; preds = %.preheader.5
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 24), align 8, !tbaa !10
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %27)
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 24), align 8, !tbaa !10
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 24), align 8, !tbaa !10
  %.not.6 = icmp eq i32 %29, %30
  br i1 %.not.6, label %.preheader.7, label %43

.preheader.7:                                     ; preds = %.preheader.6
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 28), align 4, !tbaa !10
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %31)
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 28), align 4, !tbaa !10
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 28), align 4, !tbaa !10
  %.not.7 = icmp eq i32 %33, %34
  br i1 %.not.7, label %.preheader.8, label %43

.preheader.8:                                     ; preds = %.preheader.7
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 32), align 16, !tbaa !10
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %35)
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 32), align 16, !tbaa !10
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 32), align 16, !tbaa !10
  %.not.8 = icmp eq i32 %37, %38
  br i1 %.not.8, label %.preheader.9, label %43

.preheader.9:                                     ; preds = %.preheader.8
  %39 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 36), align 4, !tbaa !10
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %39)
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @E, i64 36), align 4, !tbaa !10
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @C, i64 36), align 4, !tbaa !10
  %.not.9 = icmp ne i32 %41, %42
  %spec.select = zext i1 %.not.9 to i32
  br label %43

43:                                               ; preds = %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader23.preheader
  %.0 = phi i32 [ 1, %.preheader23.preheader ], [ 1, %.preheader.1 ], [ 1, %.preheader.2 ], [ 1, %.preheader.3 ], [ 1, %.preheader.4 ], [ 1, %.preheader.5 ], [ 1, %.preheader.6 ], [ 1, %.preheader.7 ], [ 1, %.preheader.8 ], [ %spec.select, %.preheader.9 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 allocsize(0) }

!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 = !{!"test_type", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass