; LLVM IR from tangjz/acm-icpc :: lydsy (3239)

; 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.Node = type { i32, i64 }

@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@P = external dso_local global i64, align 8
@B = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@baby = external dso_local global [100001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK4NodeS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z11lower_boundx(i64 noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3powxx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  br label %7

7:                                                ; preds = %130, %0
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @P, ptr noundef @B, ptr noundef @N)
  %9 = icmp ne i32 %8, -1
  br i1 %9, label %10, label %131

10:                                               ; preds = %7
  %11 = load i64, ptr @P, align 8, !tbaa !5
  %12 = sub nsw i64 %11, 1
  %13 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %12)
  %14 = fptosi double %13 to i32
  store i32 %14, ptr @n, align 4, !tbaa !9
  %15 = load i32, ptr @n, align 4, !tbaa !9
  %16 = load i32, ptr @n, align 4, !tbaa !9
  %17 = mul nsw i32 %15, %16
  %18 = sext i32 %17 to i64
  %19 = load i64, ptr @P, align 8, !tbaa !5
  %20 = sub nsw i64 %19, 1
  %21 = icmp slt i64 %18, %20
  br i1 %21, label %22, label %25

22:                                               ; preds = %10
  %23 = load i32, ptr @n, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @n, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %22, %10
  store i32 0, ptr @baby, align 16, !tbaa !11
  store i64 1, ptr getelementptr inbounds (%struct.Node, ptr @baby, i32 0, i32 1), align 8, !tbaa !13
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %50, %25
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = load i32, ptr @n, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %53

30:                                               ; preds = %26
  %31 = load i32, ptr %2, align 4, !tbaa !9
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.Node, ptr %34, i32 0, i32 0
  store i32 %31, ptr %35, align 16, !tbaa !11
  %36 = load i32, ptr %2, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.Node, ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = load i64, ptr @B, align 8, !tbaa !5
  %43 = mul nsw i64 %41, %42
  %44 = load i64, ptr @P, align 8, !tbaa !5
  %45 = srem i64 %43, %44
  %46 = load i32, ptr %2, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.Node, ptr %48, i32 0, i32 1
  store i64 %45, ptr %49, align 8, !tbaa !13
  br label %50

50:                                               ; preds = %30
  %51 = load i32, ptr %2, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %2, align 4, !tbaa !9
  br label %26, !llvm.loop !14

53:                                               ; preds = %26
  %54 = load i32, ptr @n, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds %struct.Node, ptr @baby, i64 %55
  call void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef @baby, ptr noundef %56, ptr noundef @_Z3cmpRK4NodeS1_)
  store i32 1, ptr @tot, align 4, !tbaa !9
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %83, %53
  %58 = load i32, ptr %2, align 4, !tbaa !9
  %59 = load i32, ptr @n, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %61, label %86

61:                                               ; preds = %57
  %62 = load i32, ptr %2, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.Node, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !13
  %67 = load i32, ptr @tot, align 4, !tbaa !9
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Node, ptr %70, i32 0, i32 1
  %72 = load i64, ptr %71, align 8, !tbaa !13
  %73 = icmp ne i64 %66, %72
  br i1 %73, label %74, label %82

74:                                               ; preds = %61
  %75 = load i32, ptr %2, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %76
  %78 = load i32, ptr @tot, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr @tot, align 4, !tbaa !9
  %80 = sext i32 %78 to i64
  %81 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %80
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %81, ptr align 16 %77, i64 16, i1 false), !tbaa.struct !16
  br label %82

82:                                               ; preds = %74, %61
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %2, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %2, align 4, !tbaa !9
  br label %57, !llvm.loop !17

86:                                               ; preds = %57
  %87 = load i64, ptr @N, align 8, !tbaa !5
  store i64 %87, ptr %3, align 8, !tbaa !5
  %88 = load i64, ptr @B, align 8, !tbaa !5
  %89 = load i64, ptr @P, align 8, !tbaa !5
  %90 = sub nsw i64 %89, 2
  %91 = call noundef i64 @_Z3powxx(i64 noundef %88, i64 noundef %90)
  %92 = load i32, ptr @n, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  %94 = call noundef i64 @_Z3powxx(i64 noundef %91, i64 noundef %93)
  store i64 %94, ptr %4, align 8, !tbaa !5
  store i32 -1, ptr @ans, align 4, !tbaa !9
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %119, %86
  %96 = load i32, ptr %2, align 4, !tbaa !9
  %97 = load i32, ptr @n, align 4, !tbaa !9
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %99, label %122

99:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %100 = load i64, ptr %3, align 8, !tbaa !5
  %101 = call noundef i32 @_Z11lower_boundx(i64 noundef %100)
  store i32 %101, ptr %5, align 4, !tbaa !9
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = icmp ne i32 %102, -1
  br i1 %103, label %104, label %110

104:                                              ; preds = %99
  %105 = load i32, ptr %2, align 4, !tbaa !9
  %106 = load i32, ptr @n, align 4, !tbaa !9
  %107 = mul nsw i32 %105, %106
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = add nsw i32 %107, %108
  store i32 %109, ptr @ans, align 4, !tbaa !9
  store i32 10, ptr %6, align 4
  br label %116

110:                                              ; preds = %99
  %111 = load i64, ptr %3, align 8, !tbaa !5
  %112 = load i64, ptr %4, align 8, !tbaa !5
  %113 = mul nsw i64 %111, %112
  %114 = load i64, ptr @P, align 8, !tbaa !5
  %115 = srem i64 %113, %114
  store i64 %115, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  br label %116

116:                                              ; preds = %110, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  %117 = load i32, ptr %6, align 4
  switch i32 %117, label %133 [
    i32 0, label %118
    i32 10, label %122
  ]

118:                                              ; preds = %116
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %2, align 4, !tbaa !9
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %2, align 4, !tbaa !9
  br label %95, !llvm.loop !18

122:                                              ; preds = %116, %95
  %123 = load i32, ptr @ans, align 4, !tbaa !9
  %124 = icmp eq i32 %123, -1
  br i1 %124, label %125, label %127

125:                                              ; preds = %122
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %130

127:                                              ; preds = %122
  %128 = load i32, ptr @ans, align 4, !tbaa !9
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %128)
  br label %130

130:                                              ; preds = %127, %125
  br label %7, !llvm.loop !19

131:                                              ; preds = %7
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %132 = load i32, ptr %1, align 4
  ret i32 %132

133:                                              ; preds = %116
  unreachable
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) #5

; 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) #6

declare i32 @printf(ptr noundef, ...) #3

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS4Node", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 4, !9, i64 8, i64 8, !5}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}


; 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.Node = type { i32, i64 }

@n = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@P = external dso_local global i64, align 8
@B = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@baby = external dso_local global [100001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK4NodeS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z11lower_boundx(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3powxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @P, ptr noundef nonnull @B, ptr noundef nonnull @N)
  %.not43 = icmp eq i32 %1, -1
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

.lr.ph45:                                         ; preds = %0, %88
  %2 = load i64, ptr @P, align 8, !tbaa !5
  %3 = add nsw i64 %2, -1
  %4 = tail call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %3)
  %5 = fptosi double %4 to i32
  store i32 %5, ptr @n, align 4, !tbaa !9
  %6 = mul nsw i32 %5, %5
  %7 = zext nneg i32 %6 to i64
  %8 = load i64, ptr @P, align 8, !tbaa !5
  %9 = add nsw i64 %8, -1
  %10 = icmp sgt i64 %9, %7
  br i1 %10, label %11, label %13

11:                                               ; preds = %.lr.ph45
  %12 = add nsw i32 %5, 1
  store i32 %12, ptr @n, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %11, %.lr.ph45
  %14 = phi i32 [ %12, %11 ], [ %5, %.lr.ph45 ]
  store i32 0, ptr @baby, align 16, !tbaa !11
  store i64 1, ptr getelementptr inbounds (i8, ptr @baby, i64 8), align 8, !tbaa !13
  %15 = icmp sgt i32 %14, 1
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %13
  %16 = load i64, ptr @B, align 8, !tbaa !5
  %wide.trip.count = zext nneg i32 %14 to i64
  %17 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %17, 1
  %18 = icmp eq i32 %14, 2
  br i1 %18, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %17, -2
  br label %19

19:                                               ; preds = %19, %.lr.ph.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next.1, %19 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %19 ]
  %20 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %indvars.iv
  %21 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %21, ptr %20, align 16, !tbaa !11
  %22 = add nsw i64 %indvars.iv, -1
  %23 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %22, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = mul nsw i64 %16, %24
  %26 = srem i64 %25, %8
  %27 = getelementptr inbounds i8, ptr %20, i64 8
  store i64 %26, ptr %27, align 8, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %indvars.iv.next
  %29 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %29, ptr %28, align 16, !tbaa !11
  %30 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %indvars.iv, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !13
  %32 = mul nsw i64 %16, %31
  %33 = srem i64 %32, %8
  %34 = getelementptr inbounds i8, ptr %28, i64 8
  store i64 %33, ptr %34, align 8, !tbaa !13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %19, !llvm.loop !14

._crit_edge.loopexit.unr-lcssa:                   ; preds = %19, %.lr.ph
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next.1, %19 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %35 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %indvars.iv.unr
  %36 = trunc nuw nsw i64 %indvars.iv.unr to i32
  store i32 %36, ptr %35, align 16, !tbaa !11
  %37 = add nsw i64 %indvars.iv.unr, -1
  %38 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %37, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !13
  %40 = mul nsw i64 %16, %39
  %41 = srem i64 %40, %8
  %42 = getelementptr inbounds i8, ptr %35, i64 8
  store i64 %41, ptr %42, align 8, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %13
  %43 = sext i32 %14 to i64
  %44 = getelementptr inbounds %struct.Node, ptr @baby, i64 %43
  tail call void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef nonnull @baby, ptr noundef nonnull %44, ptr noundef nonnull @_Z3cmpRK4NodeS1_)
  store i32 1, ptr @tot, align 4, !tbaa !9
  %45 = load i32, ptr @n, align 4, !tbaa !9
  %46 = icmp sgt i32 %45, 1
  br i1 %46, label %.lr.ph37.preheader, label %._crit_edge38

.lr.ph37.preheader:                               ; preds = %._crit_edge
  %wide.trip.count53 = zext nneg i32 %45 to i64
  br label %.lr.ph37

.lr.ph37:                                         ; preds = %.lr.ph37.preheader, %59
  %indvars.iv50 = phi i64 [ 1, %.lr.ph37.preheader ], [ %indvars.iv.next51, %59 ]
  %47 = phi i32 [ 1, %.lr.ph37.preheader ], [ %60, %59 ]
  %48 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %indvars.iv50
  %49 = getelementptr inbounds i8, ptr %48, i64 8
  %50 = load i64, ptr %49, align 8, !tbaa !13
  %51 = add nsw i32 %47, -1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %52, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !13
  %.not27 = icmp eq i64 %50, %54
  br i1 %.not27, label %59, label %55

55:                                               ; preds = %.lr.ph37
  %56 = add nsw i32 %47, 1
  store i32 %56, ptr @tot, align 4, !tbaa !9
  %57 = sext i32 %47 to i64
  %58 = getelementptr inbounds [100001 x %struct.Node], ptr @baby, i64 0, i64 %57
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %58, ptr noundef nonnull align 16 dereferenceable(16) %48, i64 16, i1 false), !tbaa.struct !16
  br label %59

59:                                               ; preds = %.lr.ph37, %55
  %60 = phi i32 [ %47, %.lr.ph37 ], [ %56, %55 ]
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond54.not = icmp eq i64 %indvars.iv.next51, %wide.trip.count53
  br i1 %exitcond54.not, label %._crit_edge38, label %.lr.ph37, !llvm.loop !17

._crit_edge38:                                    ; preds = %59, %._crit_edge
  %61 = load i64, ptr @N, align 8, !tbaa !5
  %62 = load i64, ptr @B, align 8, !tbaa !5
  %63 = load i64, ptr @P, align 8, !tbaa !5
  %64 = add nsw i64 %63, -2
  %65 = tail call noundef i64 @_Z3powxx(i64 noundef %62, i64 noundef %64)
  %66 = load i32, ptr @n, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = tail call noundef i64 @_Z3powxx(i64 noundef %65, i64 noundef %67)
  store i32 -1, ptr @ans, align 4, !tbaa !9
  %69 = load i32, ptr @n, align 4, !tbaa !9
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.lr.ph42, label %thread-pre-split.thread

.lr.ph42:                                         ; preds = %._crit_edge38, %76
  %.240 = phi i32 [ %80, %76 ], [ 0, %._crit_edge38 ]
  %.02139 = phi i64 [ %79, %76 ], [ %61, %._crit_edge38 ]
  %71 = tail call noundef i32 @_Z11lower_boundx(i64 noundef %.02139)
  %.not26 = icmp eq i32 %71, -1
  br i1 %.not26, label %76, label %72

72:                                               ; preds = %.lr.ph42
  %73 = load i32, ptr @n, align 4, !tbaa !9
  %74 = mul nsw i32 %73, %.240
  %75 = add nsw i32 %74, %71
  store i32 %75, ptr @ans, align 4, !tbaa !9
  br label %thread-pre-split

76:                                               ; preds = %.lr.ph42
  %77 = mul nsw i64 %.02139, %68
  %78 = load i64, ptr @P, align 8, !tbaa !5
  %79 = srem i64 %77, %78
  %80 = add nuw nsw i32 %.240, 1
  %81 = load i32, ptr @n, align 4, !tbaa !9
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %.lr.ph42, label %thread-pre-split.loopexit, !llvm.loop !18

thread-pre-split.loopexit:                        ; preds = %76
  %.pr.pre = load i32, ptr @ans, align 4, !tbaa !9
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %thread-pre-split.loopexit, %72
  %83 = phi i32 [ %75, %72 ], [ %.pr.pre, %thread-pre-split.loopexit ]
  %84 = icmp eq i32 %83, -1
  br i1 %84, label %thread-pre-split.thread, label %86

thread-pre-split.thread:                          ; preds = %._crit_edge38, %thread-pre-split
  %85 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %88

86:                                               ; preds = %thread-pre-split
  %87 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %83)
  br label %88

88:                                               ; preds = %86, %thread-pre-split.thread
  %89 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @P, ptr noundef nonnull @B, ptr noundef nonnull @N)
  %.not = icmp eq i32 %89, -1
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !19

._crit_edge46:                                    ; preds = %88, %0
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; 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) #5

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

attributes #0 = { 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 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS4Node", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 4, !9, i64 8, i64 8, !5}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}


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