; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2715（暴力）)

; 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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; 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
  %6 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  br label %7

7:                                                ; preds = %45, %0
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %9 = xor i32 %8, -1
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %49

11:                                               ; preds = %7
  store i64 0, ptr %6, align 8, !tbaa !5
  store i64 1, ptr %3, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %42, %11
  %13 = load i64, ptr %3, align 8, !tbaa !5
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = icmp slt i64 %13, %14
  br i1 %15, label %16, label %45

16:                                               ; preds = %12
  store i64 0, ptr %5, align 8, !tbaa !5
  %17 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %17, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %31, %16
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = icmp sle i64 %19, %20
  br i1 %21, label %22, label %34

22:                                               ; preds = %18
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = add nsw i64 %24, %23
  store i64 %25, ptr %5, align 8, !tbaa !5
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = icmp sge i64 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %22
  br label %34

30:                                               ; preds = %22
  br label %31

31:                                               ; preds = %30
  %32 = load i64, ptr %4, align 8, !tbaa !5
  %33 = add nsw i64 %32, 1
  store i64 %33, ptr %4, align 8, !tbaa !5
  br label %18, !llvm.loop !9

34:                                               ; preds = %29, %18
  %35 = load i64, ptr %5, align 8, !tbaa !5
  %36 = load i64, ptr %2, align 8, !tbaa !5
  %37 = icmp eq i64 %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = load i64, ptr %6, align 8, !tbaa !5
  %40 = add nsw i64 %39, 1
  store i64 %40, ptr %6, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %38, %34
  br label %42

42:                                               ; preds = %41
  %43 = load i64, ptr %3, align 8, !tbaa !5
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %3, align 8, !tbaa !5
  br label %12, !llvm.loop !11

45:                                               ; preds = %12
  %46 = load i64, ptr %6, align 8, !tbaa !5
  %47 = add nsw i64 %46, 1
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %47)
  br label %7, !llvm.loop !12

49:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

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

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not25 = icmp eq i32 %2, -1
  br i1 %.not25, label %._crit_edge26, label %.preheader20

.preheader20:                                     ; preds = %0, %._crit_edge
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = icmp sgt i64 %3, 1
  br i1 %4, label %.preheader.preheader, label %._crit_edge

.preheader.preheader:                             ; preds = %.preheader20
  %5 = add nsw i64 %3, -1
  %xtraiter = and i64 %5, 1
  %6 = icmp eq i64 %3, 2
  br i1 %6, label %._crit_edge.loopexit.unr-lcssa, label %.preheader.preheader.new

.preheader.preheader.new:                         ; preds = %.preheader.preheader
  %unroll_iter = and i64 %5, -2
  br label %.preheader

.preheader:                                       ; preds = %14, %.preheader.preheader.new
  %.024 = phi i64 [ 0, %.preheader.preheader.new ], [ %spec.select.1, %14 ]
  %.01423 = phi i64 [ 1, %.preheader.preheader.new ], [ %17, %14 ]
  %niter = phi i64 [ 0, %.preheader.preheader.new ], [ %niter.next.1, %14 ]
  br label %7

7:                                                ; preds = %7, %.preheader
  %.01122 = phi i64 [ 0, %.preheader ], [ %8, %7 ]
  %.01321 = phi i64 [ %.01423, %.preheader ], [ %9, %7 ]
  %8 = add nuw nsw i64 %.01122, %.01321
  %.not19 = icmp sge i64 %8, %3
  %9 = add nuw nsw i64 %.01321, 1
  %.not18 = icmp sge i64 %.01321, %3
  %or.cond = or i1 %.not19, %.not18
  br i1 %or.cond, label %.preheader.1, label %7, !llvm.loop !9

.preheader.1:                                     ; preds = %7
  %10 = icmp eq i64 %8, %3
  %11 = zext i1 %10 to i64
  %spec.select = add nuw nsw i64 %.024, %11
  br label %12

12:                                               ; preds = %12, %.preheader.1
  %.01122.1 = phi i64 [ 0, %.preheader.1 ], [ %13, %12 ]
  %.01321.1.in = phi i64 [ %.01423, %.preheader.1 ], [ %.01321.1, %12 ]
  %.01321.1 = add nuw nsw i64 %.01321.1.in, 1
  %13 = add nuw nsw i64 %.01122.1, %.01321.1
  %.not19.1 = icmp sge i64 %13, %3
  %.not18.1 = icmp sge i64 %.01321.1, %3
  %or.cond.1 = or i1 %.not19.1, %.not18.1
  br i1 %or.cond.1, label %14, label %12, !llvm.loop !9

14:                                               ; preds = %12
  %15 = icmp eq i64 %13, %3
  %16 = zext i1 %15 to i64
  %spec.select.1 = add nuw nsw i64 %spec.select, %16
  %17 = add nuw nsw i64 %.01423, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.preheader, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %14, %.preheader.preheader
  %spec.select.lcssa.ph = phi i64 [ poison, %.preheader.preheader ], [ %spec.select.1, %14 ]
  %.024.unr = phi i64 [ 0, %.preheader.preheader ], [ %spec.select.1, %14 ]
  %.01423.unr = phi i64 [ 1, %.preheader.preheader ], [ %17, %14 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.preheader.epil

.preheader.epil:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.preheader.epil
  %.01122.epil = phi i64 [ %18, %.preheader.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %.01321.epil = phi i64 [ %19, %.preheader.epil ], [ %.01423.unr, %._crit_edge.loopexit.unr-lcssa ]
  %18 = add nuw nsw i64 %.01122.epil, %.01321.epil
  %.not19.epil = icmp sge i64 %18, %3
  %19 = add nuw nsw i64 %.01321.epil, 1
  %.not18.epil = icmp sge i64 %.01321.epil, %3
  %or.cond.epil = or i1 %.not19.epil, %.not18.epil
  br i1 %or.cond.epil, label %._crit_edge.loopexit.epilog-lcssa, label %.preheader.epil, !llvm.loop !9

._crit_edge.loopexit.epilog-lcssa:                ; preds = %.preheader.epil
  %20 = icmp eq i64 %18, %3
  %21 = zext i1 %20 to i64
  %spec.select.epil = add nuw nsw i64 %.024.unr, %21
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader20
  %.0.lcssa = phi i64 [ 0, %.preheader20 ], [ %spec.select.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select.epil, %._crit_edge.loopexit.epilog-lcssa ]
  %22 = add nsw i64 %.0.lcssa, 1
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %22)
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not = icmp eq i32 %24, -1
  br i1 %.not, label %._crit_edge26, label %.preheader20, !llvm.loop !12

._crit_edge26:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret i32 0
}

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

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

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

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

attributes #0 = { mustprogress nofree norecurse 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass