; LLVM IR from xirc/cp-algorithm :: atcoder/abc195/C (main)

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %6 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %14
  %16 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 1000000000000000, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 5, ptr %5, align 8, !tbaa !8
  br label %18

18:                                               ; preds = %46, %0
  %19 = load i64, ptr %4, align 8, !tbaa !8
  %20 = icmp sge i64 %19, 1000
  br i1 %20, label %21, label %51

21:                                               ; preds = %18
  %22 = load i64, ptr %2, align 8, !tbaa !8
  %23 = load i64, ptr %4, align 8, !tbaa !8
  %24 = sdiv i64 %22, %23
  %25 = icmp sge i64 %24, 1
  br i1 %25, label %26, label %46

26:                                               ; preds = %21
  %27 = load i64, ptr %2, align 8, !tbaa !8
  %28 = load i64, ptr %4, align 8, !tbaa !8
  %29 = sdiv i64 %27, %28
  %30 = sub nsw i64 %29, 1
  %31 = load i64, ptr %4, align 8, !tbaa !8
  %32 = mul nsw i64 %30, %31
  %33 = load i64, ptr %5, align 8, !tbaa !8
  %34 = mul nsw i64 %32, %33
  %35 = load i64, ptr %3, align 8, !tbaa !8
  %36 = add nsw i64 %35, %34
  store i64 %36, ptr %3, align 8, !tbaa !8
  %37 = load i64, ptr %2, align 8, !tbaa !8
  %38 = load i64, ptr %4, align 8, !tbaa !8
  %39 = srem i64 %37, %38
  %40 = load i64, ptr %5, align 8, !tbaa !8
  %41 = mul nsw i64 %39, %40
  %42 = add nsw i64 %41, 1
  %43 = load i64, ptr %3, align 8, !tbaa !8
  %44 = add nsw i64 %43, %42
  store i64 %44, ptr %3, align 8, !tbaa !8
  %45 = load i64, ptr %4, align 8, !tbaa !8
  store i64 %45, ptr %2, align 8, !tbaa !8
  br label %46

46:                                               ; preds = %26, %21
  %47 = load i64, ptr %4, align 8, !tbaa !8
  %48 = sdiv i64 %47, 1000
  store i64 %48, ptr %4, align 8, !tbaa !8
  %49 = load i64, ptr %5, align 8, !tbaa !8
  %50 = sub nsw i64 %49, 1
  store i64 %50, ptr %5, align 8, !tbaa !8
  br label %18, !llvm.loop !11

51:                                               ; preds = %18
  %52 = load i64, ptr %3, align 8, !tbaa !8
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %52)
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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

attributes #0 = { 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 #1 = { "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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%"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" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %.promoted = load i64, ptr %1, align 8, !tbaa !8
  %.promoted.fr = freeze i64 %.promoted
  %14 = icmp sgt i64 %.promoted.fr, 999999999999999
  br i1 %14, label %.thread, label %20

.thread:                                          ; preds = %0
  %15 = urem i64 %.promoted.fr, 1000000000000000
  %16 = sub nuw nsw i64 %.promoted.fr, %15
  %17 = add nsw i64 %16, -1000000000000000
  %18 = urem i64 %.promoted.fr, 1000000000000000
  %reass.add = add nsw i64 %18, %17
  %reass.mul = mul i64 %reass.add, 5
  %19 = add i64 %reass.mul, 2
  br label %.thread26

20:                                               ; preds = %0
  %21 = icmp sgt i64 %.promoted.fr, 999999999999
  br i1 %21, label %.thread26, label %28

.thread26:                                        ; preds = %20, %.thread
  %.125 = phi i64 [ %19, %.thread ], [ 1, %20 ]
  %.0131624 = phi i64 [ 1000000000000000, %.thread ], [ %.promoted.fr, %20 ]
  %22 = urem i64 %.0131624, 1000000000000
  %23 = sub nuw nsw i64 %.0131624, %22
  %24 = add nuw nsw i64 %23, 4611685018427387904
  %25 = urem i64 %.0131624, 1000000000000
  %reass.add.1 = add nuw nsw i64 %25, %24
  %reass.mul.1 = shl i64 %reass.add.1, 2
  %26 = add i64 %.125, %reass.mul.1
  %27 = add i64 %26, 1
  br label %.thread31

28:                                               ; preds = %20
  %29 = icmp sgt i64 %.promoted.fr, 999999999
  br i1 %29, label %.thread31, label %36

.thread31:                                        ; preds = %28, %.thread26
  %.1.130 = phi i64 [ %27, %.thread26 ], [ 1, %28 ]
  %.01316.129 = phi i64 [ 1000000000000, %.thread26 ], [ %.promoted.fr, %28 ]
  %30 = urem i64 %.01316.129, 1000000000
  %31 = sub nuw nsw i64 %.01316.129, %30
  %32 = add nsw i64 %31, -1000000000
  %33 = urem i64 %.01316.129, 1000000000
  %reass.add.2 = add nsw i64 %33, %32
  %reass.mul.2 = mul nsw i64 %reass.add.2, 3
  %34 = add i64 %.1.130, %reass.mul.2
  %35 = add i64 %34, 1
  br label %.thread36

36:                                               ; preds = %28
  %37 = icmp sgt i64 %.promoted.fr, 999999
  br i1 %37, label %.thread36, label %44

.thread36:                                        ; preds = %36, %.thread31
  %.1.235 = phi i64 [ %35, %.thread31 ], [ 1, %36 ]
  %.01316.234 = phi i64 [ 1000000000, %.thread31 ], [ %.promoted.fr, %36 ]
  %.lhs.trunc = trunc i64 %.01316.234 to i32
  %38 = urem i32 %.lhs.trunc, 1000000
  %.zext = zext nneg i32 %38 to i64
  %39 = sub nuw nsw i64 %.01316.234, %.zext
  %40 = add nuw i64 %39, 9223372036853775808
  %.lhs.trunc41 = trunc i64 %.01316.234 to i32
  %41 = urem i32 %.lhs.trunc41, 1000000
  %.zext42 = zext nneg i32 %41 to i64
  %reass.add.3 = add nuw i64 %40, %.zext42
  %reass.mul.3 = shl i64 %reass.add.3, 1
  %42 = add i64 %.1.235, %reass.mul.3
  %43 = add i64 %42, 1
  br label %46

44:                                               ; preds = %36
  %45 = icmp sgt i64 %.promoted.fr, 999
  br i1 %45, label %46, label %52

46:                                               ; preds = %.thread36, %44
  %.1.340 = phi i64 [ %43, %.thread36 ], [ 1, %44 ]
  %.01316.339 = phi i64 [ 1000000, %.thread36 ], [ %.promoted.fr, %44 ]
  %.lhs.trunc43 = trunc i64 %.01316.339 to i32
  %47 = urem i32 %.lhs.trunc43, 1000
  %.zext44 = zext nneg i32 %47 to i64
  %48 = sub nuw nsw i64 %.01316.339, %.zext44
  %49 = add nsw i64 %48, -1000
  %.lhs.trunc45 = trunc i64 %.01316.339 to i32
  %50 = urem i32 %.lhs.trunc45, 1000
  %.zext46 = zext nneg i32 %50 to i64
  %reass.add.4 = add nsw i64 %49, %.zext46
  %51 = add i64 %.1.340, %reass.add.4
  store i64 1000, ptr %1, align 8, !tbaa !8
  br label %52

52:                                               ; preds = %46, %44
  %.1.4 = phi i64 [ %51, %46 ], [ 0, %44 ]
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.1.4)
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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

attributes #0 = { 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 #1 = { "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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,TailCallElimPass