; LLVM IR from lzyrapx/Competitive-Programming :: ACdream (1077（数学）（LCM）)

; 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_ostream" = type { ptr, %"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 }

@n = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@_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
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %60, %19, %14, %9, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %4 = xor i32 %3, -1
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %64

6:                                                ; preds = %2
  store i64 0, ptr @ans, align 8, !tbaa !5
  %7 = load i64, ptr @n, align 8, !tbaa !5
  %8 = icmp eq i64 %7, 1
  br i1 %8, label %9, label %11

9:                                                ; preds = %6
  %10 = call i32 @puts(ptr noundef @.str.1)
  br label %2, !llvm.loop !9

11:                                               ; preds = %6
  %12 = load i64, ptr @n, align 8, !tbaa !5
  %13 = icmp eq i64 %12, 2
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = call i32 @puts(ptr noundef @.str.2)
  br label %2, !llvm.loop !9

16:                                               ; preds = %11
  %17 = load i64, ptr @n, align 8, !tbaa !5
  %18 = icmp eq i64 %17, 3
  br i1 %18, label %19, label %21

19:                                               ; preds = %16
  %20 = call i32 @puts(ptr noundef @.str.3)
  br label %2, !llvm.loop !9

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load i64, ptr @n, align 8, !tbaa !5
  %25 = and i64 %24, 1
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %36

27:                                               ; preds = %23
  %28 = load i64, ptr @n, align 8, !tbaa !5
  %29 = mul nsw i64 1, %28
  %30 = load i64, ptr @n, align 8, !tbaa !5
  %31 = sub nsw i64 %30, 1
  %32 = mul nsw i64 %29, %31
  %33 = load i64, ptr @n, align 8, !tbaa !5
  %34 = sub nsw i64 %33, 2
  %35 = mul nsw i64 %32, %34
  store i64 %35, ptr @ans, align 8, !tbaa !5
  br label %60

36:                                               ; preds = %23
  %37 = load i64, ptr @n, align 8, !tbaa !5
  %38 = srem i64 %37, 3
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %40, label %50

40:                                               ; preds = %36
  %41 = load i64, ptr @n, align 8, !tbaa !5
  %42 = sub nsw i64 %41, 1
  %43 = mul nsw i64 1, %42
  %44 = load i64, ptr @n, align 8, !tbaa !5
  %45 = sub nsw i64 %44, 2
  %46 = mul nsw i64 %43, %45
  %47 = load i64, ptr @n, align 8, !tbaa !5
  %48 = sub nsw i64 %47, 3
  %49 = mul nsw i64 %46, %48
  store i64 %49, ptr @ans, align 8, !tbaa !5
  br label %59

50:                                               ; preds = %36
  %51 = load i64, ptr @n, align 8, !tbaa !5
  %52 = mul nsw i64 1, %51
  %53 = load i64, ptr @n, align 8, !tbaa !5
  %54 = sub nsw i64 %53, 1
  %55 = mul nsw i64 %52, %54
  %56 = load i64, ptr @n, align 8, !tbaa !5
  %57 = sub nsw i64 %56, 3
  %58 = mul nsw i64 %55, %57
  store i64 %58, ptr @ans, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %50, %40
  br label %60

60:                                               ; preds = %59, %27
  %61 = load i64, ptr @ans, align 8, !tbaa !5
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %61)
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %62, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %2, !llvm.loop !9

64:                                               ; preds = %2
  ret i32 0
}

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

declare i32 @puts(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2 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) #2 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)) #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 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 = { 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" }

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


; 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_ostream" = type { ptr, %"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 }

@n = external dso_local global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@_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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not2 = icmp eq i32 %1, -1
  br i1 %.not2, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.backedge
  store i64 0, ptr @ans, align 8, !tbaa !5
  %2 = load i64, ptr @n, align 8, !tbaa !5
  switch i64 %2, label %10 [
    i64 1, label %3
    i64 2, label %6
    i64 3, label %8
  ]

3:                                                ; preds = %.lr.ph
  %4 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

.backedge:                                        ; preds = %3, %6, %8, %24
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %5, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

6:                                                ; preds = %.lr.ph
  %7 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.backedge

8:                                                ; preds = %.lr.ph
  %9 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.backedge

10:                                               ; preds = %.lr.ph
  %11 = and i64 %2, 1
  %.not1 = icmp eq i64 %11, 0
  br i1 %.not1, label %15, label %12

12:                                               ; preds = %10
  %13 = add nsw i64 %2, -1
  %14 = mul nsw i64 %13, %2
  br label %24

15:                                               ; preds = %10
  %16 = srem i64 %2, 3
  %17 = icmp eq i64 %16, 0
  %18 = add nsw i64 %2, -1
  br i1 %17, label %19, label %22

19:                                               ; preds = %15
  %20 = add nsw i64 %2, -2
  %21 = mul nsw i64 %18, %20
  br label %24

22:                                               ; preds = %15
  %23 = mul nsw i64 %18, %2
  br label %24

24:                                               ; preds = %19, %22, %12
  %.sink = phi i64 [ -3, %19 ], [ -3, %22 ], [ -2, %12 ]
  %.sink3 = phi i64 [ %21, %19 ], [ %23, %22 ], [ %14, %12 ]
  %25 = add nsw i64 %2, %.sink
  %26 = mul nsw i64 %.sink3, %25
  store i64 %26, ptr @ans, align 8, !tbaa !5
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %26)
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %27, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %.backedge

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

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

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

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


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