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

; 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 [10005 x [1005 x double]], align 16
@b = external dso_local global [10005 x double], align 16
@c = external dso_local global [10005 x double], align 16
@.str = 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
  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
  %12 = call noundef i32 @_Z4readv()
  store i32 %12, ptr @N, align 4, !tbaa !5
  %13 = call noundef i32 @_Z4readv()
  store i32 %13, 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 %14

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

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

19:                                               ; preds = %14
  %20 = call noundef i32 @_Z4readv()
  %21 = sitofp i32 %20 to double
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [10005 x double], ptr @c, i64 0, i64 %23
  store double %21, ptr %24, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %19
  %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 %14, !llvm.loop !13

28:                                               ; preds = %18
  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 = %59, %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 %62

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
  %35 = call noundef i32 @_Z4readv()
  store i32 %35, ptr %9, align 4, !tbaa !5
  %36 = call noundef i32 @_Z4readv()
  store i32 %36, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %37 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %37, ptr %11, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %50, %34
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %53

43:                                               ; preds = %38
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10005 x [1005 x double]], ptr @a, i64 0, i64 %45
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1005 x double], ptr %46, i64 0, i64 %48
  store double 1.000000e+00, ptr %49, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %43
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %11, align 4, !tbaa !5
  br label %38, !llvm.loop !15

53:                                               ; preds = %42
  %54 = call noundef i32 @_Z4readv()
  %55 = sitofp i32 %54 to double
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [10005 x double], ptr @b, i64 0, i64 %57
  store double %55, ptr %58, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %59

59:                                               ; preds = %53
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !16

62:                                               ; preds = %33
  %63 = call noundef double @_Z7simplexv()
  %64 = fadd double %63, 5.000000e-01
  %65 = fptosi double %64 to i32
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %65)
  ret i32 0
}

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

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


; 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 [10005 x [1005 x double]], align 16
@b = external dso_local local_unnamed_addr global [10005 x double], align 16
@c = external dso_local local_unnamed_addr global [10005 x double], align 16
@.str = 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
  %.not16 = icmp slt i32 %5, 1
  br i1 %.not16, 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 ]
  %.not1421 = icmp slt i32 %6, 1
  br i1 %.not1421, label %._crit_edge24, label %.lr.ph23

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

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

.lr.ph23:                                         ; preds = %.preheader, %._crit_edge
  %indvars.iv29 = phi i64 [ %indvars.iv.next30, %._crit_edge ], [ 1, %.preheader ]
  %16 = tail call noundef i32 @_Z4readv()
  %17 = tail call noundef i32 @_Z4readv()
  %.not1518 = icmp sgt i32 %16, %17
  br i1 %.not1518, label %._crit_edge, label %.lr.ph20

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

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph20
  %indvars.iv26.ph = phi i64 [ %18, %.lr.ph20 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph20
  %n.vec = and i64 %22, 8589934588
  %ind.end = add nsw i64 %n.vec, %18
  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, %18
  %23 = getelementptr inbounds [10005 x [1005 x double]], ptr @a, i64 0, i64 %indvars.iv29, i64 %offset.idx
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %23, align 8, !tbaa !9
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %24, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %22, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.lr.ph23
  %26 = tail call noundef i32 @_Z4readv()
  %27 = sitofp i32 %26 to double
  %28 = getelementptr inbounds [10005 x double], ptr @b, i64 0, i64 %indvars.iv29
  store double %27, ptr %28, align 8, !tbaa !9
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %29 = load i32, ptr @M, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %.not14.not = icmp slt i64 %indvars.iv29, %30
  br i1 %.not14.not, label %.lr.ph23, label %._crit_edge24, !llvm.loop !16

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %scalar.ph ], [ %indvars.iv26.ph, %scalar.ph.preheader ]
  %31 = getelementptr inbounds [10005 x [1005 x double]], ptr @a, i64 0, i64 %indvars.iv29, i64 %indvars.iv26
  store double 1.000000e+00, ptr %31, align 8, !tbaa !9
  %indvars.iv.next27 = add nsw i64 %indvars.iv26, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next27 to i32
  %exitcond.not = icmp eq i32 %19, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !17
}

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

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


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