; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ/BZOJ3112（对偶原则+单纯形）.ll (Z7simplexv)

; 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 [1001 x [10010 x double]], align 16
@b = external dso_local global [10010 x double], align 16
@c = external dso_local global [10010 x double], align 16
@ans = external dso_local global double, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z7simplexv() #0 {
  %1 = alloca double, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %88, %0
  br label %8

8:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store double 1.000000e+09, ptr %4, align 8, !tbaa !9
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %21, %8
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr @M, align 4, !tbaa !5
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %13, label %24

13:                                               ; preds = %9
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [10010 x double], ptr @c, i64 0, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fcmp ogt double %17, 0x3EB0C6F7A0B5ED8D
  br i1 %18, label %19, label %20

19:                                               ; preds = %13
  br label %24

20:                                               ; preds = %13
  br label %21

21:                                               ; preds = %20
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !5
  br label %9, !llvm.loop !11

24:                                               ; preds = %19, %9
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr @M, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  %28 = icmp eq i32 %25, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = load double, ptr @ans, align 8, !tbaa !9
  store double %30, ptr %1, align 8
  store i32 1, ptr %5, align 4
  br label %86

31:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %76, %31
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load i32, ptr @N, align 4, !tbaa !5
  %35 = icmp sle i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %79

37:                                               ; preds = %32
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %39
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [10010 x double], ptr %40, i64 0, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = fcmp ogt double %44, 0x3EB0C6F7A0B5ED8D
  br i1 %45, label %46, label %75

46:                                               ; preds = %37
  %47 = load double, ptr %4, align 8, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [10010 x double], ptr @b, i64 0, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %53
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [10010 x double], ptr %54, i64 0, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = fdiv double %51, %58
  %60 = fcmp ogt double %47, %59
  br i1 %60, label %61, label %75

61:                                               ; preds = %46
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [10010 x double], ptr @b, i64 0, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %67
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [10010 x double], ptr %68, i64 0, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fdiv double %65, %72
  store double %73, ptr %4, align 8, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %74, ptr %2, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %61, %46, %37
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %6, align 4, !tbaa !5
  br label %32, !llvm.loop !13

79:                                               ; preds = %36
  %80 = load double, ptr %4, align 8, !tbaa !9
  %81 = fcmp oeq double %80, 1.000000e+09
  br i1 %81, label %82, label %83

82:                                               ; preds = %79
  store double 1.000000e+09, ptr %1, align 8
  store i32 1, ptr %5, align 4
  br label %86

83:                                               ; preds = %79
  %84 = load i32, ptr %2, align 4, !tbaa !5
  %85 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z5pivotii(i32 noundef %84, i32 noundef %85)
  store i32 0, ptr %5, align 4
  br label %86

86:                                               ; preds = %83, %82, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %87 = load i32, ptr %5, align 4
  switch i32 %87, label %89 [
    i32 0, label %88
  ]

88:                                               ; preds = %86
  br label %7, !llvm.loop !14

89:                                               ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %90 = load double, ptr %1, align 8
  ret double %90
}

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

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 = { inlinehint 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 = { 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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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 [1001 x [10010 x double]], align 16
@b = external dso_local local_unnamed_addr global [10010 x double], align 16
@c = external dso_local local_unnamed_addr global [10010 x double], align 16
@ans = external dso_local local_unnamed_addr global double, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z7simplexv() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %48, %0
  %.023 = phi i32 [ 0, %0 ], [ %.2.lcssa, %48 ]
  %2 = load i32, ptr @M, align 4, !tbaa !5
  %.not34 = icmp slt i32 %2, 1
  %.pre = add i32 %2, 1
  br i1 %.not34, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %wide.trip.count = zext i32 %.pre to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %6
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %6 ]
  %3 = getelementptr inbounds [10010 x double], ptr @c, i64 0, i64 %indvars.iv
  %4 = load double, ptr %3, align 8, !tbaa !9
  %5 = fcmp ogt double %4, 0x3EB0C6F7A0B5ED8D
  br i1 %5, label %._crit_edge.loopexit, label %6

6:                                                ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.thread, label %.lr.ph, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %7 = trunc nuw nsw i64 %indvars.iv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %._crit_edge.loopexit
  %.022.lcssa = phi i32 [ %7, %._crit_edge.loopexit ], [ 1, %1 ]
  %8 = icmp eq i32 %.022.lcssa, %.pre
  br i1 %8, label %._crit_edge.thread, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %.not2940 = icmp slt i32 %9, 1
  br i1 %.not2940, label %.loopexit, label %.lr.ph44

.lr.ph44:                                         ; preds = %.preheader
  %10 = zext nneg i32 %.022.lcssa to i64
  %11 = zext nneg i32 %9 to i64
  %xtraiter = and i64 %11, 1
  %12 = icmp eq i32 %9, 1
  br i1 %12, label %._crit_edge45.unr-lcssa, label %.lr.ph44.new

.lr.ph44.new:                                     ; preds = %.lr.ph44
  %unroll_iter = and i64 %11, 2147483646
  br label %25

._crit_edge.thread:                               ; preds = %._crit_edge, %6
  %13 = load double, ptr @ans, align 8, !tbaa !9
  br label %.loopexit

._crit_edge45.unr-lcssa:                          ; preds = %47, %.lr.ph44
  %.2.lcssa.ph = phi i32 [ poison, %.lr.ph44 ], [ %.2.1, %47 ]
  %.1.lcssa.ph = phi double [ poison, %.lr.ph44 ], [ %.1.1, %47 ]
  %indvars.iv49.unr = phi i64 [ 1, %.lr.ph44 ], [ %indvars.iv.next50.1, %47 ]
  %.02142.unr = phi double [ 1.000000e+09, %.lr.ph44 ], [ %.1.1, %47 ]
  %.12441.unr = phi i32 [ %.023, %.lr.ph44 ], [ %.2.1, %47 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge45, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge45.unr-lcssa
  %14 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %indvars.iv49.unr, i64 %10
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = fcmp ogt double %15, 0x3EB0C6F7A0B5ED8D
  br i1 %16, label %17, label %._crit_edge45

17:                                               ; preds = %.epil.preheader
  %18 = getelementptr inbounds [10010 x double], ptr @b, i64 0, i64 %indvars.iv49.unr
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fdiv double %19, %15
  %21 = fcmp ogt double %.02142.unr, %20
  br i1 %21, label %22, label %._crit_edge45

22:                                               ; preds = %17
  %23 = trunc nuw nsw i64 %indvars.iv49.unr to i32
  br label %._crit_edge45

._crit_edge45:                                    ; preds = %.epil.preheader, %17, %22, %._crit_edge45.unr-lcssa
  %.2.lcssa = phi i32 [ %.2.lcssa.ph, %._crit_edge45.unr-lcssa ], [ %23, %22 ], [ %.12441.unr, %17 ], [ %.12441.unr, %.epil.preheader ]
  %.1.lcssa = phi double [ %.1.lcssa.ph, %._crit_edge45.unr-lcssa ], [ %20, %22 ], [ %.02142.unr, %17 ], [ %.02142.unr, %.epil.preheader ]
  %24 = fcmp oeq double %.1.lcssa, 1.000000e+09
  br i1 %24, label %.loopexit, label %48

25:                                               ; preds = %47, %.lr.ph44.new
  %indvars.iv49 = phi i64 [ 1, %.lr.ph44.new ], [ %indvars.iv.next50.1, %47 ]
  %.02142 = phi double [ 1.000000e+09, %.lr.ph44.new ], [ %.1.1, %47 ]
  %.12441 = phi i32 [ %.023, %.lr.ph44.new ], [ %.2.1, %47 ]
  %niter = phi i64 [ 0, %.lr.ph44.new ], [ %niter.next.1, %47 ]
  %26 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %indvars.iv49, i64 %10
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fcmp ogt double %27, 0x3EB0C6F7A0B5ED8D
  br i1 %28, label %29, label %36

29:                                               ; preds = %25
  %30 = getelementptr inbounds [10010 x double], ptr @b, i64 0, i64 %indvars.iv49
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fdiv double %31, %27
  %33 = fcmp ogt double %.02142, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %29
  %35 = trunc nuw nsw i64 %indvars.iv49 to i32
  br label %36

36:                                               ; preds = %25, %29, %34
  %.2 = phi i32 [ %35, %34 ], [ %.12441, %29 ], [ %.12441, %25 ]
  %.1 = phi double [ %32, %34 ], [ %.02142, %29 ], [ %.02142, %25 ]
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %37 = getelementptr inbounds [1001 x [10010 x double]], ptr @a, i64 0, i64 %indvars.iv.next50, i64 %10
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = fcmp ogt double %38, 0x3EB0C6F7A0B5ED8D
  br i1 %39, label %40, label %47

40:                                               ; preds = %36
  %41 = getelementptr inbounds [10010 x double], ptr @b, i64 0, i64 %indvars.iv.next50
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = fdiv double %42, %38
  %44 = fcmp ogt double %.1, %43
  br i1 %44, label %45, label %47

45:                                               ; preds = %40
  %46 = trunc nuw nsw i64 %indvars.iv.next50 to i32
  br label %47

47:                                               ; preds = %45, %40, %36
  %.2.1 = phi i32 [ %46, %45 ], [ %.2, %40 ], [ %.2, %36 ]
  %.1.1 = phi double [ %43, %45 ], [ %.1, %40 ], [ %.1, %36 ]
  %indvars.iv.next50.1 = add nuw nsw i64 %indvars.iv49, 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_edge45.unr-lcssa, label %25, !llvm.loop !13

48:                                               ; preds = %._crit_edge45
  tail call void @_Z5pivotii(i32 noundef %.2.lcssa, i32 noundef %.022.lcssa)
  br label %1, !llvm.loop !14

.loopexit:                                        ; preds = %.preheader, %._crit_edge45, %._crit_edge.thread
  %.126.ph = phi double [ %13, %._crit_edge.thread ], [ 1.000000e+09, %._crit_edge45 ], [ 1.000000e+09, %.preheader ]
  ret double %.126.ph
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z5pivotii(i32 noundef, i32 noundef) local_unnamed_addr #1

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

!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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass