; LLVM IR from xirc/cp-algorithm :: atcoder/abc191/D/main.ll (Z5solvelll)

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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@__PRETTY_FUNCTION__._Z5solvelll = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvelll(i64 noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = sub nsw i64 %17, %18
  %20 = sdiv i64 %19, 10000
  %21 = sub nsw i64 %20, 1
  %22 = mul nsw i64 %21, 10000
  store i64 %22, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = load i64, ptr %6, align 8, !tbaa !5
  %25 = add nsw i64 %23, %24
  %26 = sdiv i64 %25, 10000
  %27 = add nsw i64 %26, 1
  %28 = mul nsw i64 %27, 10000
  store i64 %28, ptr %8, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = sub nsw i64 %30, %31
  %33 = icmp sle i64 %29, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %3
  br label %37

35:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 20, ptr noundef @__PRETTY_FUNCTION__._Z5solvelll) #6
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %4, align 8, !tbaa !5
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = add nsw i64 %39, %40
  %42 = icmp sge i64 %38, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  br label %46

44:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 21, ptr noundef @__PRETTY_FUNCTION__._Z5solvelll) #6
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %47 = load i64, ptr %7, align 8, !tbaa !5
  store i64 %47, ptr %10, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %99, %46
  %49 = load i64, ptr %10, align 8, !tbaa !5
  %50 = load i64, ptr %8, align 8, !tbaa !5
  %51 = icmp sle i64 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %102

53:                                               ; preds = %48
  %54 = load i64, ptr %10, align 8, !tbaa !5
  %55 = srem i64 %54, 10000
  %56 = icmp eq i64 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  br label %60

58:                                               ; preds = %53
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 25, ptr noundef @__PRETTY_FUNCTION__._Z5solvelll) #6
  unreachable

59:                                               ; No predecessors!
  br label %60

60:                                               ; preds = %59, %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %61 = load i64, ptr %10, align 8, !tbaa !5
  %62 = load i64, ptr %4, align 8, !tbaa !5
  %63 = sub nsw i64 %61, %62
  %64 = call noundef i64 @_ZSt3absl(i64 noundef %63)
  store i64 %64, ptr %12, align 8, !tbaa !5
  %65 = load i64, ptr %12, align 8, !tbaa !5
  %66 = load i64, ptr %6, align 8, !tbaa !5
  %67 = icmp sgt i64 %65, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %60
  store i32 4, ptr %11, align 4
  br label %96

69:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %70 = load i64, ptr %6, align 8, !tbaa !5
  %71 = load i64, ptr %6, align 8, !tbaa !5
  %72 = mul nsw i64 %70, %71
  %73 = load i64, ptr %12, align 8, !tbaa !5
  %74 = load i64, ptr %12, align 8, !tbaa !5
  %75 = mul nsw i64 %73, %74
  %76 = sub nsw i64 %72, %75
  store i64 %76, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %77 = load i64, ptr %13, align 8, !tbaa !5
  %78 = sitofp i64 %77 to x86_fp80
  %79 = call x86_fp80 @sqrtl(x86_fp80 noundef %78) #5
  %80 = call noundef x86_fp80 @_ZSt5floore(x86_fp80 noundef %79)
  %81 = fptosi x86_fp80 %80 to i64
  store i64 %81, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %82 = load i64, ptr %5, align 8, !tbaa !5
  %83 = load i64, ptr %14, align 8, !tbaa !5
  %84 = add nsw i64 %82, %83
  %85 = call noundef i64 @_Z6flooril(i64 noundef %84)
  store i64 %85, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %86 = load i64, ptr %5, align 8, !tbaa !5
  %87 = load i64, ptr %14, align 8, !tbaa !5
  %88 = sub nsw i64 %86, %87
  %89 = call noundef i64 @_Z5ceilil(i64 noundef %88)
  store i64 %89, ptr %16, align 8, !tbaa !5
  %90 = load i64, ptr %15, align 8, !tbaa !5
  %91 = load i64, ptr %16, align 8, !tbaa !5
  %92 = sub nsw i64 %90, %91
  %93 = add nsw i64 %92, 1
  %94 = load i64, ptr %9, align 8, !tbaa !5
  %95 = add nsw i64 %94, %93
  store i64 %95, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  store i32 0, ptr %11, align 4
  br label %96

96:                                               ; preds = %69, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %97 = load i32, ptr %11, align 4
  switch i32 %97, label %104 [
    i32 0, label %98
    i32 4, label %99
  ]

98:                                               ; preds = %96
  br label %99

99:                                               ; preds = %98, %96
  %100 = load i64, ptr %10, align 8, !tbaa !5
  %101 = add nsw i64 %100, 10000
  store i64 %101, ptr %10, align 8, !tbaa !5
  br label %48, !llvm.loop !9

102:                                              ; preds = %52
  %103 = load i64, ptr %9, align 8, !tbaa !5
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i64 %103

104:                                              ; preds = %96
  unreachable
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

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

; Function Attrs: nounwind
declare x86_fp80 @sqrtl(x86_fp80 noundef) #4

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

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

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

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 = { 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 #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 = { 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 }
attributes #6 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@__PRETTY_FUNCTION__._Z5solvelll = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z5solvelll(i64 noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = sub nsw i64 %0, %2
  %5 = srem i64 %4, 10000
  %6 = sub nsw i64 %4, %5
  %7 = add i64 %6, -10000
  %8 = add nsw i64 %2, %0
  %9 = srem i64 %8, 10000
  %10 = sub nsw i64 %8, %9
  %11 = add i64 %10, 10000
  %.not = icmp sgt i64 %7, %4
  br i1 %.not, label %12, label %13

12:                                               ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 20, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5solvelll) #4
  unreachable

13:                                               ; preds = %3
  %.not37 = icmp slt i64 %11, %8
  br i1 %.not37, label %14, label %.preheader

.preheader:                                       ; preds = %13
  %.not3840 = icmp sgt i64 %7, %11
  br i1 %.not3840, label %._crit_edge, label %.lr.ph

14:                                               ; preds = %13
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 21, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5solvelll) #4
  unreachable

._crit_edge:                                      ; preds = %35, %.preheader
  %.0.lcssa = phi i64 [ 0, %.preheader ], [ %.1, %35 ]
  ret i64 %.0.lcssa

.lr.ph:                                           ; preds = %.preheader, %35
  %.042 = phi i64 [ %.1, %35 ], [ 0, %.preheader ]
  %.03241 = phi i64 [ %36, %35 ], [ %7, %.preheader ]
  %15 = srem i64 %.03241, 10000
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 25, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5solvelll) #4
  unreachable

18:                                               ; preds = %.lr.ph
  %19 = sub nsw i64 %.03241, %0
  %20 = tail call noundef i64 @_ZSt3absl(i64 noundef %19)
  %21 = icmp sgt i64 %20, %2
  br i1 %21, label %35, label %22

22:                                               ; preds = %18
  %add = add nsw i64 %20, %2
  %sub = sub nsw i64 %2, %20
  %23 = mul nsw i64 %add, %sub
  %24 = sitofp i64 %23 to x86_fp80
  %25 = tail call x86_fp80 @sqrtl(x86_fp80 noundef %24) #5
  %26 = tail call noundef x86_fp80 @_ZSt5floore(x86_fp80 noundef %25)
  %27 = fptosi x86_fp80 %26 to i64
  %28 = add nsw i64 %27, %1
  %29 = tail call noundef i64 @_Z6flooril(i64 noundef %28)
  %30 = sub nsw i64 %1, %27
  %31 = tail call noundef i64 @_Z5ceilil(i64 noundef %30)
  %32 = add i64 %.042, 1
  %33 = add i64 %32, %29
  %34 = sub i64 %33, %31
  br label %35

35:                                               ; preds = %18, %22
  %.1 = phi i64 [ %34, %22 ], [ %.042, %18 ]
  %36 = add nsw i64 %.03241, 10000
  %.not38 = icmp sgt i64 %36, %11
  br i1 %.not38, label %._crit_edge, label %.lr.ph, !llvm.loop !5
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare x86_fp80 @sqrtl(x86_fp80 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z5ceilil(i64 noundef) 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 = { 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 #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 nofree nounwind willreturn memory(write) "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 = { noreturn nounwind }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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