; LLVM IR from PaddlePaddle/Paddle :: paddle/common/ddim.ll (ZN6common33AreDimsWithDynamicShapeCompatibleERKNS_4DDimES2_)

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6common33AreDimsWithDynamicShapeCompatibleERKNS_4DDimES2_(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr noundef nonnull align 8 dereferenceable(76) %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %10)
  %12 = icmp ne i32 %9, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %47

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %41, %14
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %17)
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i32 2, ptr %7, align 4
  br label %44

21:                                               ; preds = %15
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %22, i32 noundef %23)
  %25 = icmp sge i64 %24, 0
  br i1 %25, label %26, label %40

26:                                               ; preds = %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %27, i32 noundef %28)
  %30 = icmp sge i64 %29, 0
  br i1 %30, label %31, label %40

31:                                               ; preds = %26
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %32, i32 noundef %33)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %35, i32 noundef %36)
  %38 = icmp ne i64 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %44

40:                                               ; preds = %31, %26, %21
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !9
  br label %15, !llvm.loop !11

44:                                               ; preds = %39, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %45 = load i32, ptr %7, align 4
  switch i32 %45, label %49 [
    i32 2, label %46
    i32 1, label %47
  ]

46:                                               ; preds = %44
  store i1 true, ptr %3, align 1
  br label %47

47:                                               ; preds = %46, %44, %13
  %48 = load i1, ptr %3, align 1
  ret i1 %48

49:                                               ; preds = %44
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 #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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6common33AreDimsWithDynamicShapeCompatibleERKNS_4DDimES2_(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr noundef nonnull align 8 dereferenceable(76) %1) local_unnamed_addr #2 {
  %3 = tail call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %4 = tail call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %1)
  %.not = icmp eq i32 %3, %4
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %5 = tail call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %6 = icmp slt i32 %5, 1
  br i1 %6, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %15
  %.01417 = phi i32 [ %16, %15 ], [ 0, %.preheader ]
  %7 = tail call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %0, i32 noundef %.01417)
  %8 = icmp sgt i64 %7, -1
  br i1 %8, label %9, label %15

9:                                                ; preds = %.lr.ph
  %10 = tail call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %1, i32 noundef %.01417)
  %11 = icmp sgt i64 %10, -1
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  %13 = tail call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %0, i32 noundef %.01417)
  %14 = tail call noundef i64 @_ZNK6common4DDimixEi(ptr noundef nonnull align 8 dereferenceable(76) %1, i32 noundef %.01417)
  %.not16 = icmp eq i64 %13, %14
  br i1 %.not16, label %15, label %.loopexit

15:                                               ; preds = %.lr.ph, %9, %12
  %16 = add nuw nsw i32 %.01417, 1
  %17 = tail call noundef i32 @_ZNK6common4DDim4sizeEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %.not20 = icmp slt i32 %16, %17
  br i1 %.not20, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %12, %15, %.preheader, %2
  %.1 = phi i1 [ false, %2 ], [ true, %.preheader ], [ false, %12 ], [ true, %15 ]
  ret i1 %.1
}

attributes #0 = { inlinehint mustprogress 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 = { 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 #2 = { 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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