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

; 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
declare dso_local noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(2004)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6BigNummlERKS_(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4, ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(2004)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6BigNumeoERKi(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4 %0, ptr noundef nonnull align 4 dereferenceable(2004) %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %class.BigNum, align 4
  %8 = alloca %class.BigNum, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %class.BigNum, align 4
  %13 = alloca %class.BigNum, align 4
  %14 = alloca %class.BigNum, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 2004, ptr %7) #4
  call void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004) %7)
  call void @llvm.lifetime.start.p0(i64 2004, ptr %8) #4
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %8, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  call void @exit(i32 noundef -1) #5
  unreachable

20:                                               ; preds = %3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %0, i32 noundef 1)
  store i32 1, ptr %10, align 4
  br label %59

25:                                               ; preds = %20
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  call void @_ZN6BigNumC1ERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %0, ptr noundef nonnull align 4 dereferenceable(2004) %15)
  store i32 1, ptr %10, align 4
  br label %59

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %31, align 4, !tbaa !9
  store i32 %32, ptr %11, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %57, %30
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp sgt i32 %34, 1
  br i1 %35, label %36, label %58

36:                                               ; preds = %33
  %37 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %7, ptr noundef nonnull align 4 dereferenceable(2004) %15)
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %45, %36
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = shl i32 %39, 1
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = icmp sle i32 %40, %41
  br i1 %42, label %43, label %48

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 2004, ptr %12) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind writable sret(%class.BigNum) align 4 %12, ptr noundef nonnull align 4 dereferenceable(2004) %7, ptr noundef nonnull align 4 dereferenceable(2004) %7)
  %44 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %7, ptr noundef nonnull align 4 dereferenceable(2004) %12)
  call void @llvm.lifetime.end.p0(i64 2004, ptr %12) #4
  br label %45

45:                                               ; preds = %43
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = shl i32 %46, 1
  store i32 %47, ptr %9, align 4, !tbaa !9
  br label %38, !llvm.loop !11

48:                                               ; preds = %38
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = sub nsw i32 %50, %49
  store i32 %51, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2004, ptr %13) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind writable sret(%class.BigNum) align 4 %13, ptr noundef nonnull align 4 dereferenceable(2004) %8, ptr noundef nonnull align 4 dereferenceable(2004) %7)
  %52 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %8, ptr noundef nonnull align 4 dereferenceable(2004) %13)
  call void @llvm.lifetime.end.p0(i64 2004, ptr %13) #4
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %57

55:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 2004, ptr %14) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind writable sret(%class.BigNum) align 4 %14, ptr noundef nonnull align 4 dereferenceable(2004) %8, ptr noundef nonnull align 4 dereferenceable(2004) %15)
  %56 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %8, ptr noundef nonnull align 4 dereferenceable(2004) %14)
  call void @llvm.lifetime.end.p0(i64 2004, ptr %14) #4
  br label %57

57:                                               ; preds = %55, %48
  br label %33, !llvm.loop !13

58:                                               ; preds = %33
  call void @_ZN6BigNumC1ERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %0, ptr noundef nonnull align 4 dereferenceable(2004) %8)
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %59

59:                                               ; preds = %58, %29, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 2004, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 2004, ptr %7) #4
  ret void
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

declare void @_ZN6BigNumC1Ei(ptr, i32)

declare void @_ZN6BigNumC1ERKS_(ptr, ptr)

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 = { 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 = { noreturn 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 #4 = { nounwind }
attributes #5 = { noreturn 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"}
!13 = distinct !{!13, !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"

%class.BigNum = type { [500 x i32], i32 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(2004)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6BigNummlERKS_(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4, ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(2004)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6BigNumeoERKi(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4 %0, ptr noundef nonnull align 4 dereferenceable(2004) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %class.BigNum, align 4
  %5 = alloca %class.BigNum, align 4
  %6 = alloca %class.BigNum, align 4
  %7 = alloca %class.BigNum, align 4
  %8 = alloca %class.BigNum, align 4
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %4) #4
  call void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004) %4)
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %5) #4
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %5, i32 noundef 1)
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  call void @exit(i32 noundef -1) #5
  unreachable

12:                                               ; preds = %3
  switch i32 %9, label %.lr.ph [
    i32 0, label %13
    i32 1, label %14
  ]

13:                                               ; preds = %12
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %0, i32 noundef 1)
  br label %27

14:                                               ; preds = %12
  call void @_ZN6BigNumC1ERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %0, ptr noundef nonnull align 4 dereferenceable(2004) %1)
  br label %27

.lr.ph:                                           ; preds = %12, %25
  %.014 = phi i32 [ %21, %25 ], [ %9, %12 ]
  %15 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %4, ptr noundef nonnull align 4 dereferenceable(2004) %1)
  br label %16

16:                                               ; preds = %.lr.ph, %16
  %17 = phi i32 [ 2, %.lr.ph ], [ %19, %16 ]
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %6) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind nonnull writable sret(%class.BigNum) align 4 %6, ptr noundef nonnull align 4 dereferenceable(2004) %4, ptr noundef nonnull align 4 dereferenceable(2004) %4)
  %18 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %4, ptr noundef nonnull align 4 dereferenceable(2004) %6)
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %6) #4
  %19 = shl i32 %17, 1
  %.not = icmp sgt i32 %19, %.014
  br i1 %.not, label %20, label %16, !llvm.loop !9

20:                                               ; preds = %16
  %21 = sub nsw i32 %.014, %17
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %7) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind nonnull writable sret(%class.BigNum) align 4 %7, ptr noundef nonnull align 4 dereferenceable(2004) %5, ptr noundef nonnull align 4 dereferenceable(2004) %4)
  %22 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %5, ptr noundef nonnull align 4 dereferenceable(2004) %7)
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %7) #4
  %23 = icmp eq i32 %21, 1
  br i1 %23, label %.thread, label %25

.thread:                                          ; preds = %20
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %8) #4
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind nonnull writable sret(%class.BigNum) align 4 %8, ptr noundef nonnull align 4 dereferenceable(2004) %5, ptr noundef nonnull align 4 dereferenceable(2004) %1)
  %24 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %5, ptr noundef nonnull align 4 dereferenceable(2004) %8)
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %8) #4
  br label %._crit_edge

25:                                               ; preds = %20
  %26 = icmp sgt i32 %21, 1
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %25, %.thread
  call void @_ZN6BigNumC1ERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %0, ptr noundef nonnull align 4 dereferenceable(2004) %5)
  br label %27

27:                                               ; preds = %._crit_edge, %14, %13
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %4) #4
  ret void
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

declare void @_ZN6BigNumC1Ei(ptr, i32) local_unnamed_addr

declare void @_ZN6BigNumC1ERKS_(ptr, ptr) local_unnamed_addr

attributes #0 = { mustprogress 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 = { 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 = { noreturn 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 #4 = { nounwind }
attributes #5 = { noreturn 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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