; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1134（高精度卡特兰数）.ll (ZNK6BigNumgtERKS_)

; 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.BigNum = type { [500 x i32], i32 }

; 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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK6BigNumgtERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %0, ptr noundef nonnull align 4 dereferenceable(2004) %1) #1 align 2 {
  %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
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %9 = getelementptr inbounds %class.BigNum, ptr %8, i32 0, i32 1
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.BigNum, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = icmp sgt i32 %10, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

16:                                               ; preds = %2
  %17 = getelementptr inbounds %class.BigNum, ptr %8, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.BigNum, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = icmp eq i32 %18, %21
  br i1 %22, label %23, label %66

23:                                               ; preds = %16
  %24 = getelementptr inbounds %class.BigNum, ptr %8, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sub nsw i32 %25, 1
  store i32 %26, ptr %6, align 4, !tbaa !12
  br label %27

27:                                               ; preds = %45, %23
  %28 = getelementptr inbounds %class.BigNum, ptr %8, i32 0, i32 0
  %29 = load i32, ptr %6, align 4, !tbaa !12
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [500 x i32], ptr %28, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.BigNum, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %6, align 4, !tbaa !12
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [500 x i32], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = icmp eq i32 %32, %38
  br i1 %39, label %40, label %43

40:                                               ; preds = %27
  %41 = load i32, ptr %6, align 4, !tbaa !12
  %42 = icmp sge i32 %41, 0
  br label %43

43:                                               ; preds = %40, %27
  %44 = phi i1 [ false, %27 ], [ %42, %40 ]
  br i1 %44, label %45, label %48

45:                                               ; preds = %43
  %46 = load i32, ptr %6, align 4, !tbaa !12
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr %6, align 4, !tbaa !12
  br label %27, !llvm.loop !13

48:                                               ; preds = %43
  %49 = load i32, ptr %6, align 4, !tbaa !12
  %50 = icmp sge i32 %49, 0
  br i1 %50, label %51, label %65

51:                                               ; preds = %48
  %52 = getelementptr inbounds %class.BigNum, ptr %8, i32 0, i32 0
  %53 = load i32, ptr %6, align 4, !tbaa !12
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [500 x i32], ptr %52, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !12
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %class.BigNum, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %6, align 4, !tbaa !12
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [500 x i32], ptr %58, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !12
  %63 = icmp sgt i32 %56, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %51
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

65:                                               ; preds = %51, %48
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

66:                                               ; preds = %16
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

67:                                               ; preds = %66, %65, %64, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %68 = load i1, ptr %3, align 1
  ret i1 %68
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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, !11, i64 2000}
!10 = !{!"_ZTS6BigNum", !7, i64 0, !11, i64 2000}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_ZNK6BigNumgtERKS_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(2004) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(2004) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 2000
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 2000
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %4, %6
  br i1 %7, label %20, label %8

8:                                                ; preds = %2
  %9 = icmp eq i32 %4, %6
  br i1 %9, label %.preheader.preheader, label %20

.preheader.preheader:                             ; preds = %8
  %10 = sext i32 %4 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv = phi i64 [ %10, %.preheader.preheader ], [ %indvars.iv.next, %.preheader ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %11 = getelementptr inbounds [500 x i32], ptr %0, i64 0, i64 %indvars.iv.next
  %12 = load i32, ptr %11, align 4, !tbaa !10
  %13 = getelementptr inbounds [500 x i32], ptr %1, i64 0, i64 %indvars.iv.next
  %14 = load i32, ptr %13, align 4, !tbaa !10
  %15 = icmp eq i32 %12, %14
  %16 = icmp sgt i64 %indvars.iv, 0
  %17 = and i1 %16, %15
  br i1 %17, label %.preheader, label %18, !llvm.loop !11

18:                                               ; preds = %.preheader
  %19 = icmp sgt i32 %12, %14
  %or.cond = and i1 %16, %19
  br label %20

20:                                               ; preds = %18, %8, %2
  %.012 = phi i1 [ true, %2 ], [ false, %8 ], [ %or.cond, %18 ]
  ret i1 %.012
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass