; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ/BZOJ 4555（多项式求逆）.ll (Z4initv)

; 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.cp = type { x86_fp80, x86_fp80 }

@_ZL2pi = external hidden global x86_fp80, align 16
@mod = external dso_local global i64, align 8
@nlim = external dso_local global i64, align 8
@sp = external dso_local global i64, align 8
@msk = external dso_local global i64, align 8
@w = external dso_local global [262145 x %struct.cp], align 16
@wInv = external dso_local global [262145 x %struct.cp], align 16

; 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 uwtable
define dso_local void @_Z4initv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.cp, align 16
  %6 = alloca %struct.cp, align 16
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 262144, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %61, %0
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %64

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %15, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = ashr i32 %16, 1
  store i32 %17, ptr %4, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %30, %14
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = and i32 %19, 1
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %27, label %22

22:                                               ; preds = %18
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = and i32 %23, 1
  %25 = icmp ne i32 %24, 0
  %26 = xor i1 %25, true
  br label %27

27:                                               ; preds = %22, %18
  %28 = phi i1 [ false, %18 ], [ %26, %22 ]
  br i1 %28, label %29, label %35

29:                                               ; preds = %27
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = ashr i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = ashr i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  br label %18, !llvm.loop !9

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #5
  %36 = load x86_fp80, ptr @_ZL2pi, align 16, !tbaa !11
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sitofp i32 %37 to x86_fp80
  %39 = fdiv x86_fp80 %36, %38
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sitofp i32 %40 to x86_fp80
  %42 = fmul x86_fp80 %39, %41
  %43 = call noundef x86_fp80 @_ZSt3cose(x86_fp80 noundef %42)
  %44 = load x86_fp80, ptr @_ZL2pi, align 16, !tbaa !11
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sitofp i32 %45 to x86_fp80
  %47 = fdiv x86_fp80 %44, %46
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sitofp i32 %48 to x86_fp80
  %50 = fmul x86_fp80 %47, %49
  %51 = call noundef x86_fp80 @_ZSt3sine(x86_fp80 noundef %50)
  call void @_ZN2cpC2Eee(ptr noundef nonnull align 16 dereferenceable(32) %5, x86_fp80 noundef %43, x86_fp80 noundef %51)
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [262145 x %struct.cp], ptr @w, i64 0, i64 %53
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %54, ptr align 16 %5, i64 32, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #5
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [262145 x %struct.cp], ptr @w, i64 0, i64 %56
  call void @_ZNK2cp4conjEv(ptr dead_on_unwind writable sret(%struct.cp) align 16 %6, ptr noundef nonnull align 16 dereferenceable(32) %57)
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [262145 x %struct.cp], ptr @wInv, i64 0, i64 %59
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %60, ptr align 16 %6, i64 32, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %61

61:                                               ; preds = %35
  %62 = load i32, ptr %1, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %1, align 4, !tbaa !5
  br label %9, !llvm.loop !14

64:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %65 = load i64, ptr @mod, align 8, !tbaa !15
  %66 = sub nsw i64 %65, 1
  %67 = sdiv i64 10000000006, %66
  %68 = load i64, ptr @mod, align 8, !tbaa !15
  %69 = sub nsw i64 %68, 1
  %70 = sdiv i64 %67, %69
  store i64 %70, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 1000009, ptr %8, align 8, !tbaa !15
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %72 = load i64, ptr %71, align 8, !tbaa !15
  store i64 %72, ptr @nlim, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  store i64 1, ptr @sp, align 8, !tbaa !15
  br label %73

73:                                               ; preds = %82, %64
  %74 = load i64, ptr @sp, align 8, !tbaa !15
  %75 = shl i64 %74, 1
  %76 = trunc i64 %75 to i32
  %77 = shl i32 1, %76
  %78 = sext i32 %77 to i64
  %79 = load i64, ptr @mod, align 8, !tbaa !15
  %80 = icmp slt i64 %78, %79
  br i1 %80, label %81, label %85

81:                                               ; preds = %73
  br label %82

82:                                               ; preds = %81
  %83 = load i64, ptr @sp, align 8, !tbaa !15
  %84 = add nsw i64 %83, 1
  store i64 %84, ptr @sp, align 8, !tbaa !15
  br label %73, !llvm.loop !17

85:                                               ; preds = %73
  %86 = load i64, ptr @sp, align 8, !tbaa !15
  %87 = trunc i64 %86 to i32
  %88 = shl i32 1, %87
  %89 = sub nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  store i64 %90, ptr @msk, align 8, !tbaa !15
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3cose(x86_fp80 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3sine(x86_fp80 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2cpC2Eee(ptr noundef nonnull align 16 dereferenceable(32), x86_fp80 noundef, x86_fp80 noundef) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2cp4conjEv(ptr dead_on_unwind noalias writable sret(%struct.cp) align 16, ptr noundef nonnull align 16 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{i64 0, i64 16, !11, i64 16, i64 16, !11}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = distinct !{!17, !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"

%struct.cp = type { x86_fp80, x86_fp80 }

@_ZL2pi = external hidden local_unnamed_addr global x86_fp80, align 16
@mod = external dso_local local_unnamed_addr global i64, align 8
@nlim = external dso_local local_unnamed_addr global i64, align 8
@sp = external dso_local local_unnamed_addr global i64, align 8
@msk = external dso_local local_unnamed_addr global i64, align 8
@w = external dso_local global [262145 x %struct.cp], align 16
@wInv = external dso_local local_unnamed_addr global [262145 x %struct.cp], align 16

; 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 uwtable
define dso_local void @_Z4initv() local_unnamed_addr #1 {
  %1 = alloca %struct.cp, align 16
  %2 = alloca %struct.cp, align 16
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  br label %.preheader

.preheader:                                       ; preds = %0, %._crit_edge
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %._crit_edge ]
  %5 = trunc nuw nsw i64 %indvars.iv to i32
  %6 = and i32 %5, 1
  %.not19 = icmp eq i32 %6, 0
  br i1 %.not19, label %.lr.ph, label %._crit_edge

7:                                                ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %8 = load i64, ptr @mod, align 8, !tbaa !5
  %9 = add nsw i64 %8, -1
  %10 = sdiv i64 10000000006, %9
  %11 = sdiv i64 %10, %9
  store i64 %11, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i64 1000009, ptr %4, align 8, !tbaa !5
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %13 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %13, ptr @nlim, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %14 = load i64, ptr @mod, align 8, !tbaa !5
  br label %32

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.021 = phi i32 [ %16, %.lr.ph ], [ 131072, %.preheader ]
  %.01620 = phi i32 [ %15, %.lr.ph ], [ %5, %.preheader ]
  %15 = lshr exact i32 %.01620, 1
  %16 = lshr exact i32 %.021, 1
  %17 = and i32 %.01620, 2
  %.not = icmp eq i32 %17, 0
  %18 = and i32 %.021, 2
  %.not18 = icmp eq i32 %18, 0
  %19 = select i1 %.not, i1 %.not18, i1 false
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.016.lcssa = phi i32 [ %5, %.preheader ], [ %15, %.lr.ph ]
  %.0.lcssa = phi i32 [ 131072, %.preheader ], [ %16, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #5
  %20 = load x86_fp80, ptr @_ZL2pi, align 16, !tbaa !11
  %21 = uitofp nneg i32 %.0.lcssa to x86_fp80
  %22 = fdiv x86_fp80 %20, %21
  %23 = uitofp nneg i32 %.016.lcssa to x86_fp80
  %24 = fmul x86_fp80 %22, %23
  %25 = call noundef x86_fp80 @_ZSt3cose(x86_fp80 noundef %24)
  %26 = load x86_fp80, ptr @_ZL2pi, align 16, !tbaa !11
  %27 = fdiv x86_fp80 %26, %21
  %28 = fmul x86_fp80 %27, %23
  %29 = call noundef x86_fp80 @_ZSt3sine(x86_fp80 noundef %28)
  call void @_ZN2cpC2Eee(ptr noundef nonnull align 16 dereferenceable(32) %1, x86_fp80 noundef %25, x86_fp80 noundef %29)
  %30 = getelementptr inbounds [262145 x %struct.cp], ptr @w, i64 0, i64 %indvars.iv
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %30, ptr noundef nonnull align 16 dereferenceable(32) %1, i64 32, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @_ZNK2cp4conjEv(ptr dead_on_unwind nonnull writable sret(%struct.cp) align 16 %2, ptr noundef nonnull align 16 dereferenceable(32) %30)
  %31 = getelementptr inbounds [262145 x %struct.cp], ptr @wInv, i64 0, i64 %indvars.iv
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %31, ptr noundef nonnull align 16 dereferenceable(32) %2, i64 32, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 262144
  br i1 %exitcond.not, label %7, label %.preheader, !llvm.loop !14

32:                                               ; preds = %32, %7
  %storemerge = phi i64 [ 1, %7 ], [ %37, %32 ]
  %storemerge.tr = trunc i64 %storemerge to i32
  %33 = shl i32 %storemerge.tr, 1
  %34 = shl nuw i32 1, %33
  %35 = zext nneg i32 %34 to i64
  %36 = icmp sgt i64 %14, %35
  %37 = add nuw nsw i64 %storemerge, 1
  br i1 %36, label %32, label %38, !llvm.loop !15

38:                                               ; preds = %32
  store i64 %storemerge, ptr @sp, align 8, !tbaa !5
  %notmask = shl nsw i32 -1, %storemerge.tr
  %39 = xor i32 %notmask, -1
  %40 = zext nneg i32 %39 to i64
  store i64 %40, ptr @msk, align 8, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3cose(x86_fp80 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3sine(x86_fp80 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2cpC2Eee(ptr noundef nonnull align 16 dereferenceable(32), x86_fp80 noundef, x86_fp80 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2cp4conjEv(ptr dead_on_unwind noalias writable sret(%struct.cp) align 16, ptr noundef nonnull align 16 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{i64 0, i64 16, !11, i64 16, i64 16, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass