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

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; 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
declare dso_local void @_ZNK6BigNumdvERKi(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4, ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [101 x %class.BigNum], align 16
  %5 = alloca %class.BigNum, align 4
  %6 = alloca %class.BigNum, align 4
  %7 = alloca %class.BigNum, align 4
  %8 = alloca %class.BigNum, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 202404, ptr %4) #5
  %10 = getelementptr inbounds [101 x %class.BigNum], ptr %4, i32 0, i32 0
  %11 = getelementptr inbounds %class.BigNum, ptr %10, i64 101
  br label %12

12:                                               ; preds = %12, %0
  %13 = phi ptr [ %10, %0 ], [ %14, %12 ]
  call void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004) %13)
  %14 = getelementptr inbounds %class.BigNum, ptr %13, i64 1
  %15 = icmp eq ptr %14, %11
  br i1 %15, label %16, label %12

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 2004, ptr %5) #5
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %5, i32 noundef 1)
  %17 = getelementptr inbounds [101 x %class.BigNum], ptr %4, i64 0, i64 0
  %18 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %17, ptr noundef nonnull align 4 dereferenceable(2004) %5)
  call void @llvm.lifetime.end.p0(i64 2004, ptr %5) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %36, %16
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 101
  br i1 %21, label %22, label %39

22:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 2004, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 2004, ptr %7) #5
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [101 x %class.BigNum], ptr %4, i64 0, i64 %25
  call void @llvm.lifetime.start.p0(i64 2004, ptr %8) #5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = mul nsw i32 4, %27
  %29 = sub nsw i32 %28, 2
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %8, i32 noundef %29)
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind writable sret(%class.BigNum) align 4 %7, ptr noundef nonnull align 4 dereferenceable(2004) %26, ptr noundef nonnull align 4 dereferenceable(2004) %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %9, align 4, !tbaa !5
  call void @_ZNK6BigNumdvERKi(ptr dead_on_unwind writable sret(%class.BigNum) align 4 %6, ptr noundef nonnull align 4 dereferenceable(2004) %7, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [101 x %class.BigNum], ptr %4, i64 0, i64 %33
  %35 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %34, ptr noundef nonnull align 4 dereferenceable(2004) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr %6) #5
  br label %36

36:                                               ; preds = %22
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !9

39:                                               ; preds = %19
  br label %40

40:                                               ; preds = %48, %39
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = icmp ne i32 %44, -1
  br label %46

46:                                               ; preds = %43, %40
  %47 = phi i1 [ false, %40 ], [ %45, %43 ]
  br i1 %47, label %48, label %52

48:                                               ; preds = %46
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [101 x %class.BigNum], ptr %4, i64 0, i64 %50
  call void @_ZN6BigNum5printEv(ptr noundef nonnull align 4 dereferenceable(2004) %51)
  br label %40, !llvm.loop !11

52:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 202404, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

declare void @_ZN6BigNumC1Ei(ptr, i32)

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 = { mustprogress norecurse 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 = { "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 #5 = { 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}


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; 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
declare dso_local void @_ZNK6BigNumdvERKi(ptr dead_on_unwind noalias writable sret(%class.BigNum) align 4, ptr noundef nonnull align 4 dereferenceable(2004), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6BigNum5printEv(ptr noundef nonnull align 4 dereferenceable(2004)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca [101 x %class.BigNum], align 16
  %3 = alloca %class.BigNum, align 4
  %4 = alloca %class.BigNum, align 4
  %5 = alloca %class.BigNum, align 4
  %6 = alloca %class.BigNum, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 202404, ptr nonnull %2) #5
  br label %8

8:                                                ; preds = %8, %0
  %.idx = phi i64 [ 0, %0 ], [ %.add, %8 ]
  %.ptr = getelementptr inbounds i8, ptr %2, i64 %.idx
  call void @_ZN6BigNumC2Ev(ptr noundef nonnull align 4 dereferenceable(2004) %.ptr)
  %.add = add nuw nsw i64 %.idx, 2004
  %9 = icmp eq i64 %.add, 202404
  br i1 %9, label %10, label %8

10:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %3) #5
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %3, i32 noundef 1)
  %11 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %2, ptr noundef nonnull align 4 dereferenceable(2004) %3)
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %3) #5
  br label %17

.preheader:                                       ; preds = %17
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %13 = icmp eq i32 %12, 1
  %14 = load i32, ptr %1, align 4
  %15 = icmp ne i32 %14, -1
  %16 = select i1 %13, i1 %15, i1 false
  br i1 %16, label %.lr.ph, label %._crit_edge

17:                                               ; preds = %10, %17
  %indvars.iv = phi i64 [ 1, %10 ], [ %indvars.iv.next, %17 ]
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %5) #5
  %18 = add nsw i64 %indvars.iv, -1
  %19 = getelementptr inbounds [101 x %class.BigNum], ptr %2, i64 0, i64 %18
  call void @llvm.lifetime.start.p0(i64 2004, ptr nonnull %6) #5
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %20 = shl i32 %indvars.iv.tr, 2
  %21 = add i32 %20, -2
  call void @_ZN6BigNumC1Ei(ptr noundef nonnull align 4 dereferenceable(2004) %6, i32 noundef %21)
  call void @_ZNK6BigNummlERKS_(ptr dead_on_unwind nonnull writable sret(%class.BigNum) align 4 %5, ptr noundef nonnull align 4 dereferenceable(2004) %19, ptr noundef nonnull align 4 dereferenceable(2004) %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %22, ptr %7, align 4, !tbaa !5
  call void @_ZNK6BigNumdvERKi(ptr dead_on_unwind nonnull writable sret(%class.BigNum) align 4 %4, ptr noundef nonnull align 4 dereferenceable(2004) %5, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %23 = getelementptr inbounds [101 x %class.BigNum], ptr %2, i64 0, i64 %indvars.iv
  %24 = call noundef nonnull align 4 dereferenceable(2004) ptr @_ZN6BigNumaSERKS_(ptr noundef nonnull align 4 dereferenceable(2004) %23, ptr noundef nonnull align 4 dereferenceable(2004) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 2004, ptr nonnull %4) #5
  %exitcond.not = icmp eq i64 %indvars.iv.next, 101
  br i1 %exitcond.not, label %.preheader, label %17, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %25 = phi i32 [ %30, %.lr.ph ], [ %14, %.preheader ]
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [101 x %class.BigNum], ptr %2, i64 0, i64 %26
  call void @_ZN6BigNum5printEv(ptr noundef nonnull align 4 dereferenceable(2004) %27)
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %29 = icmp eq i32 %28, 1
  %30 = load i32, ptr %1, align 4
  %31 = icmp ne i32 %30, -1
  %32 = select i1 %29, i1 %31, i1 false
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @llvm.lifetime.end.p0(i64 202404, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

declare void @_ZN6BigNumC1Ei(ptr, i32) 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 = { mustprogress norecurse 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 = { 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 #5 = { 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,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass