; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ (2301（莫比乌斯反演）)

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

@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6mobiusv() #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 uwtable
declare dso_local noundef i32 @_Z4calcii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_Z6mobiusv()
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %4

4:                                                ; preds = %8, %0
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %7 = icmp ne i32 %5, 0
  br i1 %7, label %8, label %47

8:                                                ; preds = %4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @a, ptr noundef @b, ptr noundef @c, ptr noundef @d, ptr noundef @k)
  %10 = load i32, ptr @a, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @a, align 4, !tbaa !5
  %12 = load i32, ptr @c, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr @c, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %14 = load i32, ptr @b, align 4, !tbaa !5
  %15 = load i32, ptr @k, align 4, !tbaa !5
  %16 = sdiv i32 %14, %15
  %17 = load i32, ptr @d, align 4, !tbaa !5
  %18 = load i32, ptr @k, align 4, !tbaa !5
  %19 = sdiv i32 %17, %18
  %20 = call noundef i32 @_Z4calcii(i32 noundef %16, i32 noundef %19)
  %21 = load i32, ptr @a, align 4, !tbaa !5
  %22 = load i32, ptr @k, align 4, !tbaa !5
  %23 = sdiv i32 %21, %22
  %24 = load i32, ptr @d, align 4, !tbaa !5
  %25 = load i32, ptr @k, align 4, !tbaa !5
  %26 = sdiv i32 %24, %25
  %27 = call noundef i32 @_Z4calcii(i32 noundef %23, i32 noundef %26)
  %28 = sub nsw i32 %20, %27
  %29 = load i32, ptr @c, align 4, !tbaa !5
  %30 = load i32, ptr @k, align 4, !tbaa !5
  %31 = sdiv i32 %29, %30
  %32 = load i32, ptr @b, align 4, !tbaa !5
  %33 = load i32, ptr @k, align 4, !tbaa !5
  %34 = sdiv i32 %32, %33
  %35 = call noundef i32 @_Z4calcii(i32 noundef %31, i32 noundef %34)
  %36 = sub nsw i32 %28, %35
  %37 = load i32, ptr @a, align 4, !tbaa !5
  %38 = load i32, ptr @k, align 4, !tbaa !5
  %39 = sdiv i32 %37, %38
  %40 = load i32, ptr @c, align 4, !tbaa !5
  %41 = load i32, ptr @k, align 4, !tbaa !5
  %42 = sdiv i32 %40, %41
  %43 = call noundef i32 @_Z4calcii(i32 noundef %39, i32 noundef %42)
  %44 = add nsw i32 %36, %43
  store i32 %44, ptr %2, align 4, !tbaa !5
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %45)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %4, !llvm.loop !9

47:                                               ; preds = %4
  ret i32 0
}

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

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

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 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 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 #4 = { "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 }

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


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

@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6mobiusv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4calcii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  tail call void @_Z6mobiusv()
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not3 = icmp eq i32 %2, 0
  br i1 %.not3, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @a, ptr noundef nonnull @b, ptr noundef nonnull @c, ptr noundef nonnull @d, ptr noundef nonnull @k)
  %5 = load i32, ptr @a, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @a, align 4, !tbaa !5
  %7 = load i32, ptr @c, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @c, align 4, !tbaa !5
  %9 = load i32, ptr @b, align 4, !tbaa !5
  %10 = load i32, ptr @k, align 4, !tbaa !5
  %11 = sdiv i32 %9, %10
  %12 = load i32, ptr @d, align 4, !tbaa !5
  %13 = sdiv i32 %12, %10
  %14 = tail call noundef i32 @_Z4calcii(i32 noundef %11, i32 noundef %13)
  %15 = load i32, ptr @a, align 4, !tbaa !5
  %16 = load i32, ptr @k, align 4, !tbaa !5
  %17 = sdiv i32 %15, %16
  %18 = load i32, ptr @d, align 4, !tbaa !5
  %19 = sdiv i32 %18, %16
  %20 = tail call noundef i32 @_Z4calcii(i32 noundef %17, i32 noundef %19)
  %21 = load i32, ptr @c, align 4, !tbaa !5
  %22 = load i32, ptr @k, align 4, !tbaa !5
  %23 = sdiv i32 %21, %22
  %24 = load i32, ptr @b, align 4, !tbaa !5
  %25 = sdiv i32 %24, %22
  %26 = tail call noundef i32 @_Z4calcii(i32 noundef %23, i32 noundef %25)
  %27 = load i32, ptr @a, align 4, !tbaa !5
  %28 = load i32, ptr @k, align 4, !tbaa !5
  %29 = sdiv i32 %27, %28
  %30 = load i32, ptr @c, align 4, !tbaa !5
  %31 = sdiv i32 %30, %28
  %32 = tail call noundef i32 @_Z4calcii(i32 noundef %29, i32 noundef %31)
  %33 = add i32 %20, %26
  %34 = sub i32 %14, %33
  %35 = add nsw i32 %34, %32
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %35)
  %37 = load i32, ptr @t, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %37, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %0
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = { 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 = { 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" }

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


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