; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ (BZOJ3550（单纯形）（权限题）)

; 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 [1010 x [1010 x double]], align 16
@b = external dso_local global [1010 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

; 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %12 = call noundef i32 @_Z4readv()
  store i32 %12, ptr @N, align 4, !tbaa !5
  %13 = call noundef i32 @_Z4readv()
  store i32 %13, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %26, %2
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load i32, ptr @N, align 4, !tbaa !5
  %17 = mul nsw i32 3, %16
  %18 = icmp sle i32 %15, %17
  br i1 %18, label %20, label %19

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

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

26:                                               ; preds = %20
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !5
  br label %14, !llvm.loop !13

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

30:                                               ; preds = %62, %29
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = load i32, ptr @N, align 4, !tbaa !5
  %33 = mul nsw i32 2, %32
  %34 = add nsw i32 %33, 1
  %35 = icmp sle i32 %31, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %65

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %38 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %38, ptr %10, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %53, %37
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = load i32, ptr @N, align 4, !tbaa !5
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = add nsw i32 %41, %42
  %44 = icmp slt i32 %40, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %39
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %56

46:                                               ; preds = %39
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1010 x [1010 x double]], ptr @a, i64 0, i64 %48
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1010 x double], ptr %49, i64 0, i64 %51
  store double 1.000000e+00, ptr %52, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %46
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !5
  br label %39, !llvm.loop !15

56:                                               ; preds = %45
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = sitofp i32 %57 to double
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1010 x double], ptr @b, i64 0, i64 %60
  store double %58, ptr %61, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %56
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %8, align 4, !tbaa !5
  br label %30, !llvm.loop !16

65:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %66 = load i32, ptr @N, align 4, !tbaa !5
  %67 = mul nsw i32 2, %66
  %68 = add nsw i32 %67, 2
  store i32 %68, ptr %11, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %90, %65
  %70 = load i32, ptr %11, align 4, !tbaa !5
  %71 = load i32, ptr @N, align 4, !tbaa !5
  %72 = mul nsw i32 5, %71
  %73 = add nsw i32 %72, 2
  %74 = icmp slt i32 %70, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %69
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %93

76:                                               ; preds = %69
  %77 = load i32, ptr %11, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1010 x [1010 x double]], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = load i32, ptr @N, align 4, !tbaa !5
  %82 = mul nsw i32 2, %81
  %83 = sub nsw i32 %80, %82
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1010 x double], ptr %79, i64 0, i64 %85
  store double 1.000000e+00, ptr %86, align 8, !tbaa !11
  %87 = load i32, ptr %11, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1010 x double], ptr @b, i64 0, i64 %88
  store double 1.000000e+00, ptr %89, align 8, !tbaa !11
  br label %90

90:                                               ; preds = %76
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %11, align 4, !tbaa !5
  br label %69, !llvm.loop !17

93:                                               ; preds = %75
  %94 = load i32, ptr @N, align 4, !tbaa !5
  %95 = mul nsw i32 3, %94
  store i32 %95, ptr @M, align 4, !tbaa !5
  %96 = load i32, ptr @N, align 4, !tbaa !5
  %97 = mul nsw i32 5, %96
  store i32 %97, ptr @N, align 4, !tbaa !5
  %98 = load i32, ptr @N, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr @N, align 4, !tbaa !5
  %100 = call noundef double @_Z7simplexv()
  %101 = fadd double %100, 5.000000e-01
  %102 = fptosi double %101 to i32
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %102)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %104 = load i32, ptr %3, align 4
  ret i32 %104
}

; 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}
!17 = distinct !{!17, !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 [1010 x [1010 x double]], align 16
@b = external dso_local local_unnamed_addr global [1010 x double], align 16
@c = external dso_local local_unnamed_addr global [1010 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()
  %5 = load i32, ptr @N, align 4, !tbaa !5
  %6 = mul nsw i32 %5, 3
  %.not27 = icmp slt i32 %5, 1
  br i1 %.not27, label %.preheader23, label %.lr.ph

.preheader23:                                     ; preds = %.lr.ph, %2
  %.lcssa26 = phi i32 [ %5, %2 ], [ %15, %.lr.ph ]
  %.lcssa25 = phi i32 [ %6, %2 ], [ %16, %.lr.ph ]
  %7 = shl i32 %.lcssa26, 1
  %.not2232 = icmp slt i32 %.lcssa26, 0
  br i1 %.not2232, label %._crit_edge34, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader23
  %8 = sitofp i32 %4 to double
  %9 = or disjoint i32 %7, 1
  %smax = tail call i32 @llvm.smax.i32(i32 %9, i32 1)
  %10 = add nuw i32 %smax, 1
  %wide.trip.count = zext i32 %10 to i64
  %.not = icmp eq i32 %.lcssa26, 0
  %11 = add nuw i32 %.lcssa26, 1
  br label %.preheader

.lr.ph:                                           ; preds = %2, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %2 ]
  %12 = tail call noundef i32 @_Z4readv()
  %13 = sitofp i32 %12 to double
  %14 = getelementptr inbounds [1010 x double], ptr @c, i64 0, i64 %indvars.iv
  store double %13, ptr %14, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @N, align 4, !tbaa !5
  %16 = mul nsw i32 %15, 3
  %17 = sext i32 %16 to i64
  %.not.not = icmp slt i64 %indvars.iv, %17
  br i1 %.not.not, label %.lr.ph, label %.preheader23, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvar = phi i32 [ 0, %.preheader.lr.ph ], [ %indvar.next, %._crit_edge ]
  %indvars.iv44 = phi i64 [ 1, %.preheader.lr.ph ], [ %indvars.iv.next45, %._crit_edge ]
  %18 = add i32 %11, %indvar
  %19 = add i32 %indvar, 2
  %smax55 = tail call i32 @llvm.smax.i32(i32 %18, i32 %19)
  %reass.sub = sub i32 %smax55, %indvar
  %20 = add i32 %reass.sub, -2
  %21 = zext i32 %20 to i64
  %22 = add nuw nsw i64 %21, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph31

.lr.ph31:                                         ; preds = %.preheader
  %23 = trunc i64 %indvars.iv44 to i32
  %24 = add i32 %.lcssa26, %23
  %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.ph31
  %indvars.iv46.ph = phi i64 [ %indvars.iv44, %.lr.ph31 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph31
  %n.vec = and i64 %22, 8589934588
  %ind.end = add nuw i64 %indvars.iv44, %n.vec
  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 %indvars.iv44, %index
  %25 = getelementptr inbounds [1010 x [1010 x double]], ptr @a, i64 0, i64 %indvars.iv44, i64 %offset.idx
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %25, align 8, !tbaa !9
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %26, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, 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_edge34:                                    ; preds = %._crit_edge, %.preheader23
  %28 = mul nsw i32 %.lcssa26, 5
  %29 = icmp slt i32 %7, %28
  br i1 %29, label %.lr.ph38, label %._crit_edge39

.lr.ph38:                                         ; preds = %._crit_edge34
  %30 = add i32 %7, 2
  %31 = xor i32 %7, -1
  %32 = sext i32 %30 to i64
  %33 = sext i32 %28 to i64
  br label %43

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.preheader
  %34 = getelementptr inbounds [1010 x double], ptr @b, i64 0, i64 %indvars.iv44
  store double %8, ptr %34, align 8, !tbaa !9
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond = icmp eq i64 %indvars.iv.next45, %wide.trip.count
  %indvar.next = add i32 %indvar, 1
  br i1 %exitcond, label %._crit_edge34, label %.preheader, !llvm.loop !16

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %scalar.ph ], [ %indvars.iv46.ph, %scalar.ph.preheader ]
  %35 = getelementptr inbounds [1010 x [1010 x double]], ptr @a, i64 0, i64 %indvars.iv44, i64 %indvars.iv46
  store double 1.000000e+00, ptr %35, align 8, !tbaa !9
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %36 = trunc nuw i64 %indvars.iv.next47 to i32
  %37 = icmp sgt i32 %24, %36
  br i1 %37, label %scalar.ph, label %._crit_edge, !llvm.loop !17

._crit_edge39:                                    ; preds = %43, %._crit_edge34
  store i32 %.lcssa25, ptr @M, align 4, !tbaa !5
  %38 = add nsw i32 %28, 1
  store i32 %38, ptr @N, align 4, !tbaa !5
  %39 = tail call noundef double @_Z7simplexv()
  %40 = fadd double %39, 5.000000e-01
  %41 = fptosi double %40 to i32
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %41)
  ret i32 0

43:                                               ; preds = %.lr.ph38, %43
  %indvars.iv50 = phi i64 [ %32, %.lr.ph38 ], [ %indvars.iv.next51, %43 ]
  %44 = trunc nsw i64 %indvars.iv50 to i32
  %45 = add i32 %44, %31
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1010 x [1010 x double]], ptr @a, i64 0, i64 %indvars.iv50, i64 %46
  store double 1.000000e+00, ptr %47, align 8, !tbaa !9
  %48 = getelementptr inbounds [1010 x double], ptr @b, i64 0, i64 %indvars.iv50
  store double 1.000000e+00, ptr %48, align 8, !tbaa !9
  %indvars.iv.next51 = add nsw i64 %indvars.iv50, 1
  %.not41 = icmp sgt i64 %indvars.iv50, %33
  br i1 %.not41, label %._crit_edge39, label %43, !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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 = { 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" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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}
!18 = distinct !{!18, !12}


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