; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ (BZOJ3265（1061加强版）)

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

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@a = external dso_local global [10100 x [1010 x double]], align 16
@b = external dso_local global [10100 x double], align 16
@c = external dso_local global [1010 x double], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z7simplexv() #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 norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %13 = call noundef i32 @_Z4readv()
  store i32 %13, ptr @N, align 4, !tbaa !5
  %14 = call noundef i32 @_Z4readv()
  store i32 %14, ptr @M, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %25, %2
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr @N, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %28

20:                                               ; preds = %15
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1010 x double], ptr @c, i64 0, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  br label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %6, align 4, !tbaa !5
  br label %15, !llvm.loop !11

28:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %67, %28
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr @M, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %70

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %35 = call noundef i32 @_Z4readv()
  store i32 %35, ptr %11, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %61, %34
  %37 = load i32, ptr %11, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr %11, align 4, !tbaa !5
  %39 = icmp ne i32 %37, 0
  br i1 %39, label %40, label %62

40:                                               ; preds = %36
  %41 = call noundef i32 @_Z4readv()
  store i32 %41, ptr %9, align 4, !tbaa !5
  %42 = call noundef i32 @_Z4readv()
  store i32 %42, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %43, ptr %12, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %58, %40
  %45 = load i32, ptr %12, align 4, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %44
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10100 x [1010 x double]], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %12, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1010 x double], ptr %52, i64 0, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !13
  %57 = fadd double %56, 1.000000e+00
  store double %57, ptr %55, align 8, !tbaa !13
  br label %58

58:                                               ; preds = %49
  %59 = load i32, ptr %12, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %12, align 4, !tbaa !5
  br label %44, !llvm.loop !15

61:                                               ; preds = %48
  br label %36, !llvm.loop !16

62:                                               ; preds = %36
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [10100 x double], ptr @b, i64 0, i64 %64
  %66 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %67

67:                                               ; preds = %62
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !17

70:                                               ; preds = %33
  %71 = call noundef double @_Z7simplexv()
  %72 = fadd double %71, 5.000000e-01
  %73 = fptosi double %72 to i32
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %73)
  ret i32 0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z4readv() #3

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

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

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 = { 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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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

@N = external dso_local local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [10100 x [1010 x double]], align 16
@b = external dso_local global [10100 x double], align 16
@c = external dso_local global [1010 x double], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z7simplexv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = tail call noundef i32 @_Z4readv()
  store i32 %3, ptr @N, align 4, !tbaa !5
  %4 = tail call noundef i32 @_Z4readv()
  store i32 %4, ptr @M, align 4, !tbaa !5
  %5 = load i32, ptr @N, align 4, !tbaa !5
  %.not19 = icmp slt i32 %5, 1
  br i1 %.not19, label %.preheader, label %.lr.ph

.preheader.loopexit:                              ; preds = %.lr.ph
  %.pre = load i32, ptr @M, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %2
  %6 = phi i32 [ %.pre, %.preheader.loopexit ], [ %4, %2 ]
  %.not1626 = icmp slt i32 %6, 1
  br i1 %.not1626, label %._crit_edge29, label %.lr.ph28

.lr.ph:                                           ; preds = %2, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %2 ]
  %7 = getelementptr inbounds [1010 x double], ptr @c, i64 0, i64 %indvars.iv
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %.not.not = icmp slt i64 %indvars.iv, %10
  br i1 %.not.not, label %.lr.ph, label %.preheader.loopexit, !llvm.loop !9

._crit_edge29:                                    ; preds = %._crit_edge, %.preheader
  %11 = tail call noundef double @_Z7simplexv()
  %12 = fadd double %11, 5.000000e-01
  %13 = fptosi double %12 to i32
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %13)
  ret i32 0

.lr.ph28:                                         ; preds = %.preheader, %._crit_edge
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %._crit_edge ], [ 1, %.preheader ]
  %15 = tail call noundef i32 @_Z4readv()
  %.not1724 = icmp eq i32 %15, 0
  br i1 %.not1724, label %._crit_edge, label %.lr.ph25

.loopexit:                                        ; preds = %.lr.ph23, %middle.block, %.lr.ph25
  %.not17 = icmp eq i32 %16, 0
  br i1 %.not17, label %._crit_edge, label %.lr.ph25, !llvm.loop !11

.lr.ph25:                                         ; preds = %.lr.ph28, %.loopexit
  %.in = phi i32 [ %16, %.loopexit ], [ %15, %.lr.ph28 ]
  %16 = add nsw i32 %.in, -1
  %17 = tail call noundef i32 @_Z4readv()
  %18 = tail call noundef i32 @_Z4readv()
  %.not1821 = icmp sgt i32 %17, %18
  br i1 %.not1821, label %.loopexit, label %.lr.ph23.preheader

.lr.ph23.preheader:                               ; preds = %.lr.ph25
  %19 = sext i32 %17 to i64
  %20 = add i32 %18, 1
  %21 = sub i32 %18, %17
  %22 = zext i32 %21 to i64
  %23 = add nuw nsw i64 %22, 1
  %min.iters.check = icmp ult i32 %21, 3
  br i1 %min.iters.check, label %.lr.ph23.preheader38, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph23.preheader
  %n.vec = and i64 %23, 8589934588
  %ind.end = add nsw i64 %n.vec, %19
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %19
  %24 = getelementptr inbounds [10100 x [1010 x double]], ptr @a, i64 0, i64 %indvars.iv34, i64 %offset.idx
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load = load <2 x double>, ptr %24, align 8, !tbaa !12
  %wide.load37 = load <2 x double>, ptr %25, align 8, !tbaa !12
  %26 = fadd <2 x double> %wide.load, <double 1.000000e+00, double 1.000000e+00>
  %27 = fadd <2 x double> %wide.load37, <double 1.000000e+00, double 1.000000e+00>
  store <2 x double> %26, ptr %24, align 8, !tbaa !12
  store <2 x double> %27, ptr %25, align 8, !tbaa !12
  %index.next = add nuw i64 %index, 4
  %28 = icmp eq i64 %index.next, %n.vec
  br i1 %28, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %23, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph23.preheader38

.lr.ph23.preheader38:                             ; preds = %middle.block, %.lr.ph23.preheader
  %indvars.iv31.ph = phi i64 [ %19, %.lr.ph23.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph23

.lr.ph23:                                         ; preds = %.lr.ph23.preheader38, %.lr.ph23
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %.lr.ph23 ], [ %indvars.iv31.ph, %.lr.ph23.preheader38 ]
  %29 = getelementptr inbounds [10100 x [1010 x double]], ptr @a, i64 0, i64 %indvars.iv34, i64 %indvars.iv31
  %30 = load double, ptr %29, align 8, !tbaa !12
  %31 = fadd double %30, 1.000000e+00
  store double %31, ptr %29, align 8, !tbaa !12
  %indvars.iv.next32 = add nsw i64 %indvars.iv31, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next32 to i32
  %exitcond.not = icmp eq i32 %20, %lftr.wideiv
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph23, !llvm.loop !17

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph28
  %32 = getelementptr inbounds [10100 x double], ptr @b, i64 0, i64 %indvars.iv34
  %33 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %32)
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %34 = load i32, ptr @M, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %.not16.not = icmp slt i64 %indvars.iv34, %35
  br i1 %.not16.not, label %.lr.ph28, label %._crit_edge29, !llvm.loop !18
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z4readv() local_unnamed_addr #2

; 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 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 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 #2 = { 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 #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"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !10, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !10, !16, !15}
!18 = distinct !{!18, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass