; LLVM IR from upupming/algorithm :: acwing/算法竞赛进阶指南/0x08-总结与练习/123. 士兵 (main)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@x = external dso_local global [10010 x i32], align 16
@y = external dso_local global [10010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

8:                                                ; preds = %22, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %25

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %15
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %19
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 4 dereferenceable(4) %20)
  br label %22

22:                                               ; preds = %13
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !9

25:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @y, i64 %27
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @y, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %48, %25
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %51

34:                                               ; preds = %29
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = sdiv i32 %39, 2
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sub nsw i32 %38, %43
  %45 = call i32 @llvm.abs.i32(i32 %44, i1 true)
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = add nsw i32 %46, %45
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %34
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %4, align 4, !tbaa !5
  br label %29, !llvm.loop !11

51:                                               ; preds = %33
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr @x, i64 %53
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @x, ptr noundef %54)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %67, %51
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %55
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sub nsw i32 %65, %61
  store i32 %66, ptr %64, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %60
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %5, align 4, !tbaa !5
  br label %55, !llvm.loop !12

70:                                               ; preds = %59
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr @x, i64 %72
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @x, ptr noundef %73)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %93, %70
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = icmp slt i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %96

79:                                               ; preds = %74
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = sdiv i32 %84, 2
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sub nsw i32 %83, %88
  %90 = call i32 @llvm.abs.i32(i32 %89, i1 true)
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = add nsw i32 %91, %90
  store i32 %92, ptr %3, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %79
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %6, align 4, !tbaa !5
  br label %74, !llvm.loop !13

96:                                               ; preds = %78
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %97)
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %98, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@x = external dso_local global [10010 x i32], align 16
@y = external dso_local global [10010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %26, %.lr.ph ]
  %4 = getelementptr inbounds i32, ptr @y, i64 %.pre-phi
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @y, ptr noundef nonnull %4)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph32, label %._crit_edge33

.lr.ph32:                                         ; preds = %._crit_edge
  %7 = lshr i32 %5, 1
  %8 = zext nneg i32 %7 to i64
  %9 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %wide.trip.count = zext nneg i32 %5 to i64
  %min.iters.check = icmp ult i32 %5, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph32
  %indvars.iv50.ph = phi i64 [ 0, %.lr.ph32 ], [ %n.vec, %middle.block ]
  %.01929.ph = phi i32 [ 0, %.lr.ph32 ], [ %20, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph32
  %n.vec = and i64 %wide.trip.count, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %10, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %17, %vector.body ]
  %vec.phi67 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %18, %vector.body ]
  %11 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %index
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %wide.load = load <4 x i32>, ptr %11, align 16, !tbaa !5
  %wide.load68 = load <4 x i32>, ptr %12, align 16, !tbaa !5
  %13 = sub nsw <4 x i32> %wide.load, %broadcast.splat
  %14 = sub nsw <4 x i32> %wide.load68, %broadcast.splat
  %15 = tail call <4 x i32> @llvm.abs.v4i32(<4 x i32> %13, i1 true)
  %16 = tail call <4 x i32> @llvm.abs.v4i32(<4 x i32> %14, i1 true)
  %17 = add <4 x i32> %15, %vec.phi
  %18 = add <4 x i32> %16, %vec.phi67
  %index.next = add nuw i64 %index, 8
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %18, %17
  %20 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge33, label %scalar.ph.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %21 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %indvars.iv
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %23 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %indvars.iv
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge33:                                    ; preds = %scalar.ph, %middle.block, %._crit_edge
  %.019.lcssa = phi i32 [ 0, %._crit_edge ], [ %20, %middle.block ], [ %41, %scalar.ph ]
  %28 = sext i32 %5 to i64
  %29 = getelementptr inbounds i32, ptr @x, i64 %28
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @x, ptr noundef nonnull %29)
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph38.preheader, label %._crit_edge39

.lr.ph38.preheader:                               ; preds = %._crit_edge33
  %wide.trip.count56 = zext nneg i32 %30 to i64
  %min.iters.check71 = icmp ult i32 %30, 8
  br i1 %min.iters.check71, label %.lr.ph38.preheader104, label %vector.ph72

.lr.ph38.preheader104:                            ; preds = %middle.block69, %.lr.ph38.preheader
  %indvars.iv53.ph = phi i64 [ 0, %.lr.ph38.preheader ], [ %n.vec74, %middle.block69 ]
  br label %.lr.ph38

vector.ph72:                                      ; preds = %.lr.ph38.preheader
  %n.vec74 = and i64 %wide.trip.count56, 2147483640
  br label %vector.body76

vector.body76:                                    ; preds = %vector.body76, %vector.ph72
  %index77 = phi i64 [ 0, %vector.ph72 ], [ %index.next81, %vector.body76 ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph72 ], [ %vec.ind.next, %vector.body76 ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %32 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %index77
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %wide.load79 = load <4 x i32>, ptr %32, align 16, !tbaa !5
  %wide.load80 = load <4 x i32>, ptr %33, align 16, !tbaa !5
  %34 = sub nsw <4 x i32> %wide.load79, %vec.ind
  %35 = sub nsw <4 x i32> %wide.load80, %step.add
  store <4 x i32> %34, ptr %32, align 16, !tbaa !5
  store <4 x i32> %35, ptr %33, align 16, !tbaa !5
  %index.next81 = add nuw i64 %index77, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %36 = icmp eq i64 %index.next81, %n.vec74
  br i1 %36, label %middle.block69, label %vector.body76, !llvm.loop !14

middle.block69:                                   ; preds = %vector.body76
  %cmp.n82 = icmp eq i64 %n.vec74, %wide.trip.count56
  br i1 %cmp.n82, label %._crit_edge39, label %.lr.ph38.preheader104

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %scalar.ph ], [ %indvars.iv50.ph, %scalar.ph.preheader ]
  %.01929 = phi i32 [ %41, %scalar.ph ], [ %.01929.ph, %scalar.ph.preheader ]
  %37 = getelementptr inbounds [10010 x i32], ptr @y, i64 0, i64 %indvars.iv50
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sub nsw i32 %38, %10
  %40 = tail call i32 @llvm.abs.i32(i32 %39, i1 true)
  %41 = add nuw nsw i32 %40, %.01929
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next51, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge33, label %scalar.ph, !llvm.loop !15

._crit_edge39:                                    ; preds = %.lr.ph38, %middle.block69, %._crit_edge33
  %42 = sext i32 %30 to i64
  %43 = getelementptr inbounds i32, ptr @x, i64 %42
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @x, ptr noundef nonnull %43)
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph44, label %._crit_edge45

.lr.ph44:                                         ; preds = %._crit_edge39
  %46 = lshr i32 %44, 1
  %47 = zext nneg i32 %46 to i64
  %48 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %wide.trip.count61 = zext nneg i32 %44 to i64
  %min.iters.check85 = icmp ult i32 %44, 8
  br i1 %min.iters.check85, label %scalar.ph84.preheader, label %vector.ph86

scalar.ph84.preheader:                            ; preds = %middle.block83, %.lr.ph44
  %indvars.iv58.ph = phi i64 [ 0, %.lr.ph44 ], [ %n.vec88, %middle.block83 ]
  %.141.ph = phi i32 [ %.019.lcssa, %.lr.ph44 ], [ %60, %middle.block83 ]
  br label %scalar.ph84

vector.ph86:                                      ; preds = %.lr.ph44
  %n.vec88 = and i64 %wide.trip.count61, 2147483640
  %50 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.019.lcssa, i64 0
  %broadcast.splatinsert96 = insertelement <4 x i32> poison, i32 %49, i64 0
  %broadcast.splat97 = shufflevector <4 x i32> %broadcast.splatinsert96, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body90

vector.body90:                                    ; preds = %vector.body90, %vector.ph86
  %index91 = phi i64 [ 0, %vector.ph86 ], [ %index.next98, %vector.body90 ]
  %vec.phi92 = phi <4 x i32> [ %50, %vector.ph86 ], [ %57, %vector.body90 ]
  %vec.phi93 = phi <4 x i32> [ zeroinitializer, %vector.ph86 ], [ %58, %vector.body90 ]
  %51 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %index91
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  %wide.load94 = load <4 x i32>, ptr %51, align 16, !tbaa !5
  %wide.load95 = load <4 x i32>, ptr %52, align 16, !tbaa !5
  %53 = sub nsw <4 x i32> %wide.load94, %broadcast.splat97
  %54 = sub nsw <4 x i32> %wide.load95, %broadcast.splat97
  %55 = tail call <4 x i32> @llvm.abs.v4i32(<4 x i32> %53, i1 true)
  %56 = tail call <4 x i32> @llvm.abs.v4i32(<4 x i32> %54, i1 true)
  %57 = add <4 x i32> %55, %vec.phi92
  %58 = add <4 x i32> %56, %vec.phi93
  %index.next98 = add nuw i64 %index91, 8
  %59 = icmp eq i64 %index.next98, %n.vec88
  br i1 %59, label %middle.block83, label %vector.body90, !llvm.loop !16

middle.block83:                                   ; preds = %vector.body90
  %bin.rdx99 = add <4 x i32> %58, %57
  %60 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx99)
  %cmp.n100 = icmp eq i64 %n.vec88, %wide.trip.count61
  br i1 %cmp.n100, label %._crit_edge45, label %scalar.ph84.preheader

.lr.ph38:                                         ; preds = %.lr.ph38.preheader104, %.lr.ph38
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %.lr.ph38 ], [ %indvars.iv53.ph, %.lr.ph38.preheader104 ]
  %61 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %indvars.iv53
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = trunc nuw nsw i64 %indvars.iv53 to i32
  %64 = sub nsw i32 %62, %63
  store i32 %64, ptr %61, align 4, !tbaa !5
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond57.not = icmp eq i64 %indvars.iv.next54, %wide.trip.count56
  br i1 %exitcond57.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !17

._crit_edge45:                                    ; preds = %scalar.ph84, %middle.block83, %._crit_edge39
  %.1.lcssa = phi i32 [ %.019.lcssa, %._crit_edge39 ], [ %60, %middle.block83 ], [ %71, %scalar.ph84 ]
  %65 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.1.lcssa)
  %66 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

scalar.ph84:                                      ; preds = %scalar.ph84.preheader, %scalar.ph84
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %scalar.ph84 ], [ %indvars.iv58.ph, %scalar.ph84.preheader ]
  %.141 = phi i32 [ %71, %scalar.ph84 ], [ %.141.ph, %scalar.ph84.preheader ]
  %67 = getelementptr inbounds [10010 x i32], ptr @x, i64 0, i64 %indvars.iv58
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sub nsw i32 %68, %49
  %70 = tail call i32 @llvm.abs.i32(i32 %69, i1 true)
  %71 = add nuw nsw i32 %70, %.141
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond62.not = icmp eq i64 %indvars.iv.next59, %wide.trip.count61
  br i1 %exitcond62.not, label %._crit_edge45, label %scalar.ph84, !llvm.loop !18
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1 immarg) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #5

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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !11, !12}
!15 = distinct !{!15, !10, !12, !11}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10, !12, !11}


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