; LLVM IR from Tunghohin/Competitive_Coding :: Nowcoder/22529_B.ll (Z5solvev)

; 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.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@num = external dso_local global [110 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %25, %0
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %28

21:                                               ; preds = %16
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds [110 x i64], ptr @num, i64 0, i64 %22
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %23)
  br label %25

25:                                               ; preds = %21
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = add nsw i64 %26, 1
  store i64 %27, ptr %4, align 8, !tbaa !5
  br label %16, !llvm.loop !9

28:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %88, %28
  %30 = load i64, ptr %7, align 8, !tbaa !5
  %31 = load i64, ptr %3, align 8, !tbaa !5
  %32 = trunc i64 %31 to i32
  %33 = shl i32 1, %32
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %30, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %29
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %91

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %38 = load i64, ptr %2, align 8, !tbaa !5
  store i64 %38, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %39 = load i64, ptr %1, align 8, !tbaa !5
  %40 = sub nsw i64 %39, 1
  store i64 %40, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %66, %37
  %42 = load i64, ptr %12, align 8, !tbaa !5
  %43 = load i64, ptr %3, align 8, !tbaa !5
  %44 = icmp slt i64 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %69

46:                                               ; preds = %41
  %47 = load i64, ptr %7, align 8, !tbaa !5
  %48 = load i64, ptr %12, align 8, !tbaa !5
  %49 = ashr i64 %47, %48
  %50 = and i64 %49, 1
  %51 = icmp ne i64 %50, 0
  br i1 %51, label %52, label %65

52:                                               ; preds = %46
  %53 = load i64, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds [110 x i64], ptr @num, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = load i64, ptr %10, align 8, !tbaa !5
  %57 = sdiv i64 %56, %55
  store i64 %57, ptr %10, align 8, !tbaa !5
  %58 = load i64, ptr %12, align 8, !tbaa !5
  %59 = getelementptr inbounds [110 x i64], ptr @num, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = load i64, ptr %11, align 8, !tbaa !5
  %62 = sdiv i64 %61, %60
  store i64 %62, ptr %11, align 8, !tbaa !5
  %63 = load i64, ptr %9, align 8, !tbaa !5
  %64 = add nsw i64 %63, 1
  store i64 %64, ptr %9, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %52, %46
  br label %66

66:                                               ; preds = %65
  %67 = load i64, ptr %12, align 8, !tbaa !5
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %12, align 8, !tbaa !5
  br label %41, !llvm.loop !11

69:                                               ; preds = %45
  %70 = load i64, ptr %9, align 8, !tbaa !5
  %71 = srem i64 %70, 2
  %72 = icmp ne i64 %71, 0
  br i1 %72, label %73, label %80

73:                                               ; preds = %69
  %74 = load i64, ptr %10, align 8, !tbaa !5
  %75 = load i64, ptr %5, align 8, !tbaa !5
  %76 = sub nsw i64 %75, %74
  store i64 %76, ptr %5, align 8, !tbaa !5
  %77 = load i64, ptr %11, align 8, !tbaa !5
  %78 = load i64, ptr %6, align 8, !tbaa !5
  %79 = sub nsw i64 %78, %77
  store i64 %79, ptr %6, align 8, !tbaa !5
  br label %87

80:                                               ; preds = %69
  %81 = load i64, ptr %10, align 8, !tbaa !5
  %82 = load i64, ptr %5, align 8, !tbaa !5
  %83 = add nsw i64 %82, %81
  store i64 %83, ptr %5, align 8, !tbaa !5
  %84 = load i64, ptr %11, align 8, !tbaa !5
  %85 = load i64, ptr %6, align 8, !tbaa !5
  %86 = add nsw i64 %85, %84
  store i64 %86, ptr %6, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %80, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %88

88:                                               ; preds = %87
  %89 = load i64, ptr %7, align 8, !tbaa !5
  %90 = add nsw i64 %89, 1
  store i64 %90, ptr %7, align 8, !tbaa !5
  br label %29, !llvm.loop !12

91:                                               ; preds = %36
  %92 = load i64, ptr %5, align 8, !tbaa !5
  %93 = load i64, ptr %6, align 8, !tbaa !5
  %94 = sub nsw i64 %92, %93
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %94)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !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}
!12 = distinct !{!12, !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.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@num = external dso_local global [110 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %7 = load i64, ptr %3, align 8, !tbaa !5
  %8 = icmp sgt i64 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %0
  %.lcssa = phi i64 [ %7, %0 ], [ %39, %.lr.ph ]
  %9 = trunc i64 %.lcssa to i32
  %.not = icmp eq i32 %9, 31
  br i1 %.not, label %._crit_edge50, label %.lr.ph49

.lr.ph49:                                         ; preds = %.preheader
  %10 = shl nuw i32 1, %9
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = load i64, ptr %1, align 8, !tbaa !5
  %13 = add i64 %12, -1
  %14 = icmp sgt i64 %.lcssa, 0
  %15 = call i32 @llvm.smax.i32(i32 %10, i32 1)
  %smax56 = zext nneg i32 %15 to i64
  br i1 %14, label %.lr.ph42.us, label %.lr.ph49.split.preheader

.lr.ph49.split.preheader:                         ; preds = %.lr.ph49
  %16 = add nsw i64 %smax56, -1
  %17 = mul i64 %13, %16
  %18 = add i64 %12, %17
  %19 = mul i64 %11, %smax56
  %20 = add i64 %18, -1
  br label %._crit_edge50

.lr.ph42.us:                                      ; preds = %.lr.ph49, %._crit_edge.us
  %.03048.us = phi i64 [ %35, %._crit_edge.us ], [ 0, %.lr.ph49 ]
  %.03147.us = phi i64 [ %.132.us, %._crit_edge.us ], [ 0, %.lr.ph49 ]
  %.03346.us = phi i64 [ %.134.us, %._crit_edge.us ], [ 0, %.lr.ph49 ]
  br label %21

21:                                               ; preds = %.lr.ph42.us, %30
  %.041.us = phi i64 [ 0, %.lr.ph42.us ], [ %31, %30 ]
  %.02540.us = phi i64 [ %13, %.lr.ph42.us ], [ %.1.us, %30 ]
  %.02639.us = phi i64 [ %11, %.lr.ph42.us ], [ %.127.us, %30 ]
  %.02838.us = phi i64 [ 0, %.lr.ph42.us ], [ %.129.us, %30 ]
  %22 = shl nuw i64 1, %.041.us
  %23 = and i64 %22, %.03048.us
  %.not36.us = icmp eq i64 %23, 0
  br i1 %.not36.us, label %30, label %24

24:                                               ; preds = %21
  %25 = getelementptr inbounds [110 x i64], ptr @num, i64 0, i64 %.041.us
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = sdiv i64 %.02639.us, %26
  %28 = sdiv i64 %.02540.us, %26
  %29 = add nsw i64 %.02838.us, 1
  br label %30

30:                                               ; preds = %24, %21
  %.129.us = phi i64 [ %29, %24 ], [ %.02838.us, %21 ]
  %.127.us = phi i64 [ %27, %24 ], [ %.02639.us, %21 ]
  %.1.us = phi i64 [ %28, %24 ], [ %.02540.us, %21 ]
  %31 = add nuw nsw i64 %.041.us, 1
  %exitcond.not = icmp eq i64 %31, %.lcssa
  br i1 %exitcond.not, label %._crit_edge.us, label %21, !llvm.loop !9

._crit_edge.us:                                   ; preds = %30
  %32 = and i64 %.129.us, 1
  %.not.us = icmp eq i64 %32, 0
  %33 = sub i64 0, %.127.us
  %.134.p.us = select i1 %.not.us, i64 %.127.us, i64 %33
  %.134.us = add i64 %.134.p.us, %.03346.us
  %34 = sub i64 0, %.1.us
  %.132.p.us = select i1 %.not.us, i64 %.1.us, i64 %34
  %.132.us = add i64 %.132.p.us, %.03147.us
  %35 = add nuw nsw i64 %.03048.us, 1
  %exitcond57.not = icmp eq i64 %35, %smax56
  br i1 %exitcond57.not, label %._crit_edge50, label %.lr.ph42.us, !llvm.loop !11

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03537 = phi i64 [ %38, %.lr.ph ], [ 0, %0 ]
  %36 = getelementptr inbounds [110 x i64], ptr @num, i64 0, i64 %.03537
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %36)
  %38 = add nuw nsw i64 %.03537, 1
  %39 = load i64, ptr %3, align 8, !tbaa !5
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %.lr.ph, label %.preheader, !llvm.loop !12

._crit_edge50:                                    ; preds = %._crit_edge.us, %.lr.ph49.split.preheader, %.preheader
  %.033.lcssa = phi i64 [ 0, %.preheader ], [ %19, %.lr.ph49.split.preheader ], [ %.134.us, %._crit_edge.us ]
  %.031.lcssa = phi i64 [ 0, %.preheader ], [ %20, %.lr.ph49.split.preheader ], [ %.132.us, %._crit_edge.us ]
  %41 = sub nsw i64 %.033.lcssa, %.031.lcssa
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %41)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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