; LLVM IR from HarshCasper/NeoAlgo :: C-Plus-Plus/other/Median_in_row_wise_sorted_matrix.ll (Z5solvev)

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, 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
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = zext i32 %20 to i64
  %22 = call ptr @llvm.stacksave.p0()
  store ptr %22, ptr %3, align 8
  %23 = mul nuw i64 %19, %21
  %24 = alloca i32, i64 %23, align 16
  store i64 %19, ptr %4, align 8
  store i64 %21, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %49, %0
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

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

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

31:                                               ; preds = %45, %30
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

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

36:                                               ; preds = %31
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = mul nsw i64 %38, %21
  %40 = getelementptr inbounds i32, ptr %24, i64 %39
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %40, i64 %42
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %43)
  br label %45

45:                                               ; preds = %36
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %8, align 4, !tbaa !5
  br label %31, !llvm.loop !9

48:                                               ; preds = %35
  br label %49

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

52:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2147483647, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 -2147483648, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %53 = load i32, ptr %1, align 4, !tbaa !5
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = mul nsw i32 %53, %54
  %56 = sdiv i32 %55, 2
  %57 = add nsw i32 1, %56
  store i32 %57, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %102, %52
  %59 = load i32, ptr %12, align 4, !tbaa !5
  %60 = load i32, ptr %1, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %58
  %64 = load i32, ptr %12, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = mul nsw i64 %65, %21
  %67 = getelementptr inbounds i32, ptr %24, i64 %66
  %68 = getelementptr inbounds i32, ptr %67, i64 0
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %72, label %79

72:                                               ; preds = %63
  %73 = load i32, ptr %12, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = mul nsw i64 %74, %21
  %76 = getelementptr inbounds i32, ptr %24, i64 %75
  %77 = getelementptr inbounds i32, ptr %76, i64 0
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr %9, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %72, %63
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = mul nsw i64 %81, %21
  %83 = getelementptr inbounds i32, ptr %24, i64 %82
  %84 = load i32, ptr %2, align 4, !tbaa !5
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i32, ptr %83, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = load i32, ptr %10, align 4, !tbaa !5
  %90 = icmp sgt i32 %88, %89
  br i1 %90, label %91, label %101

91:                                               ; preds = %79
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = mul nsw i64 %93, %21
  %95 = getelementptr inbounds i32, ptr %24, i64 %94
  %96 = load i32, ptr %2, align 4, !tbaa !5
  %97 = sub nsw i32 %96, 1
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i32, ptr %95, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  store i32 %100, ptr %10, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %91, %79
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %12, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %12, align 4, !tbaa !5
  br label %58, !llvm.loop !12

105:                                              ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %157, %105
  %107 = load i32, ptr %9, align 4, !tbaa !5
  %108 = load i32, ptr %10, align 4, !tbaa !5
  %109 = icmp slt i32 %107, %108
  br i1 %109, label %110, label %158

110:                                              ; preds = %106
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = load i32, ptr %9, align 4, !tbaa !5
  %113 = add nsw i32 %111, %112
  %114 = sdiv i32 %113, 2
  store i32 %114, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %145, %110
  %116 = load i32, ptr %15, align 4, !tbaa !5
  %117 = load i32, ptr %1, align 4, !tbaa !5
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %115
  store i32 13, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %148

120:                                              ; preds = %115
  %121 = load i32, ptr %15, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = mul nsw i64 %122, %21
  %124 = getelementptr inbounds i32, ptr %24, i64 %123
  %125 = load i32, ptr %15, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = mul nsw i64 %126, %21
  %128 = getelementptr inbounds i32, ptr %24, i64 %127
  %129 = load i32, ptr %2, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds i32, ptr %128, i64 %130
  %132 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef %124, ptr noundef %131, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %133 = load i32, ptr %15, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = mul nsw i64 %134, %21
  %136 = getelementptr inbounds i32, ptr %24, i64 %135
  %137 = ptrtoint ptr %132 to i64
  %138 = ptrtoint ptr %136 to i64
  %139 = sub i64 %137, %138
  %140 = sdiv exact i64 %139, 4
  %141 = load i32, ptr %13, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = add nsw i64 %142, %140
  %144 = trunc i64 %143 to i32
  store i32 %144, ptr %13, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %120
  %146 = load i32, ptr %15, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %15, align 4, !tbaa !5
  br label %115, !llvm.loop !13

148:                                              ; preds = %119
  %149 = load i32, ptr %13, align 4, !tbaa !5
  %150 = load i32, ptr %11, align 4, !tbaa !5
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %152, label %155

152:                                              ; preds = %148
  %153 = load i32, ptr %14, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %9, align 4, !tbaa !5
  br label %157

155:                                              ; preds = %148
  %156 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %156, ptr %10, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %155, %152
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %106, !llvm.loop !14

158:                                              ; preds = %106
  %159 = load i32, ptr %9, align 4, !tbaa !5
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  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
  %160 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %160)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret i32 %159
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

; 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 uwtable
declare dso_local noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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 }

@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = zext i32 %6 to i64
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = zext i32 %8 to i64
  %10 = call ptr @llvm.stacksave.p0()
  %11 = mul nuw i64 %9, %7
  %12 = alloca i32, i64 %11, align 16
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  %.pre79 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %14, label %.preheader39.lr.ph, label %._crit_edge59

.preheader39.lr.ph:                               ; preds = %0
  %15 = icmp sgt i32 %.pre79, 0
  br i1 %15, label %.preheader39, label %._crit_edge42.thread

._crit_edge42.thread:                             ; preds = %.preheader39.lr.ph
  %16 = mul nsw i32 %.pre79, %13
  %.fr81 = freeze i32 %16
  br label %.lr.ph47

.preheader39:                                     ; preds = %.preheader39.lr.ph, %._crit_edge
  %17 = phi i32 [ %48, %._crit_edge ], [ %13, %.preheader39.lr.ph ]
  %18 = phi i32 [ %49, %._crit_edge ], [ %.pre79, %.preheader39.lr.ph ]
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %._crit_edge ], [ 0, %.preheader39.lr.ph ]
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader39
  %20 = mul nuw nsw i64 %indvars.iv70, %9
  %21 = getelementptr inbounds i32, ptr %12, i64 %20
  br label %52

._crit_edge42:                                    ; preds = %._crit_edge
  %22 = mul nsw i32 %49, %48
  %.fr = freeze i32 %22
  %23 = icmp sgt i32 %48, 0
  br i1 %23, label %.lr.ph47, label %._crit_edge59

.lr.ph47:                                         ; preds = %._crit_edge42.thread, %._crit_edge42
  %.in = phi i32 [ %.fr81, %._crit_edge42.thread ], [ %.fr, %._crit_edge42 ]
  %24 = phi i32 [ %13, %._crit_edge42.thread ], [ %48, %._crit_edge42 ]
  %25 = phi i32 [ %.pre79, %._crit_edge42.thread ], [ %49, %._crit_edge42 ]
  %26 = sdiv i32 %.in, 2
  %27 = sext i32 %25 to i64
  %wide.trip.count = zext nneg i32 %24 to i64
  %min.iters.check = icmp ugt i32 %24, 7
  %ident.check.not = icmp eq i32 %8, 1
  %or.cond = select i1 %min.iters.check, i1 %ident.check.not, i1 false
  br i1 %or.cond, label %vector.ph, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph47
  %indvars.iv73.ph = phi i64 [ 0, %.lr.ph47 ], [ %n.vec, %middle.block ]
  %.03044.ph = phi i32 [ -2147483648, %.lr.ph47 ], [ %46, %middle.block ]
  %.03143.ph = phi i32 [ 2147483647, %.lr.ph47 ], [ %47, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %28 = mul nuw nsw i64 %indvars.iv73.ph, %9
  %29 = getelementptr inbounds i32, ptr %12, i64 %28
  %30 = load i32, ptr %29, align 16, !tbaa !5
  %spec.select.prol = call i32 @llvm.smin.i32(i32 %30, i32 %.03143.ph)
  %31 = getelementptr i32, ptr %29, i64 %27
  %32 = getelementptr i8, ptr %31, i64 -4
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %.1.prol = call i32 @llvm.smax.i32(i32 %33, i32 %.03044.ph)
  %indvars.iv.next74.prol = or disjoint i64 %indvars.iv73.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %spec.select.lcssa112.unr = phi i32 [ poison, %scalar.ph.preheader ], [ %spec.select.prol, %scalar.ph.prol ]
  %.1.lcssa111.unr = phi i32 [ poison, %scalar.ph.preheader ], [ %.1.prol, %scalar.ph.prol ]
  %indvars.iv73.unr = phi i64 [ %indvars.iv73.ph, %scalar.ph.preheader ], [ %indvars.iv.next74.prol, %scalar.ph.prol ]
  %.03044.unr = phi i32 [ %.03044.ph, %scalar.ph.preheader ], [ %.1.prol, %scalar.ph.prol ]
  %.03143.unr = phi i32 [ %.03143.ph, %scalar.ph.preheader ], [ %spec.select.prol, %scalar.ph.prol ]
  %34 = add nsw i64 %wide.trip.count, -1
  %35 = icmp eq i64 %indvars.iv73.ph, %34
  br i1 %35, label %.preheader, label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph47
  %n.vec = and i64 %wide.trip.count, 2147483640
  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> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %43, %vector.body ]
  %vec.phi102 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %44, %vector.body ]
  %vec.phi103 = phi <4 x i32> [ <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, %vector.ph ], [ %38, %vector.body ]
  %vec.phi104 = phi <4 x i32> [ <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, %vector.ph ], [ %39, %vector.body ]
  %36 = getelementptr inbounds i32, ptr %12, i64 %index
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  %wide.load = load <4 x i32>, ptr %36, align 16, !tbaa !5
  %wide.load105 = load <4 x i32>, ptr %37, align 16, !tbaa !5
  %38 = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi103)
  %39 = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %wide.load105, <4 x i32> %vec.phi104)
  %40 = getelementptr i32, ptr %36, i64 %27
  %41 = getelementptr i8, ptr %40, i64 -4
  %42 = getelementptr i8, ptr %40, i64 12
  %wide.load106 = load <4 x i32>, ptr %41, align 4, !tbaa !5
  %wide.load107 = load <4 x i32>, ptr %42, align 4, !tbaa !5
  %43 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load106, <4 x i32> %vec.phi)
  %44 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load107, <4 x i32> %vec.phi102)
  %index.next = add nuw i64 %index, 8
  %45 = icmp eq i64 %index.next, %n.vec
  br i1 %45, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %43, <4 x i32> %44)
  %46 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
  %rdx.minmax108 = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %38, <4 x i32> %39)
  %47 = call i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %rdx.minmax108)
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader, label %scalar.ph.preheader

._crit_edge.loopexit:                             ; preds = %52
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader39
  %48 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %17, %.preheader39 ]
  %49 = phi i32 [ %55, %._crit_edge.loopexit ], [ %18, %.preheader39 ]
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %50 = sext i32 %48 to i64
  %51 = icmp slt i64 %indvars.iv.next71, %50
  br i1 %51, label %.preheader39, label %._crit_edge42, !llvm.loop !13

52:                                               ; preds = %.lr.ph, %52
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %52 ]
  %53 = getelementptr inbounds i32, ptr %21, i64 %indvars.iv
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %53)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next, %56
  br i1 %57, label %52, label %._crit_edge.loopexit, !llvm.loop !15

.preheader:                                       ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %spec.select.lcssa = phi i32 [ %47, %middle.block ], [ %spec.select.lcssa112.unr, %scalar.ph.prol.loopexit ], [ %spec.select.1, %scalar.ph ]
  %.1.lcssa = phi i32 [ %46, %middle.block ], [ %.1.lcssa111.unr, %scalar.ph.prol.loopexit ], [ %.1.1, %scalar.ph ]
  %58 = icmp slt i32 %spec.select.lcssa, %.1.lcssa
  br i1 %58, label %.lr.ph58.split, label %._crit_edge59

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv73 = phi i64 [ %indvars.iv.next74.1, %scalar.ph ], [ %indvars.iv73.unr, %scalar.ph.prol.loopexit ]
  %.03044 = phi i32 [ %.1.1, %scalar.ph ], [ %.03044.unr, %scalar.ph.prol.loopexit ]
  %.03143 = phi i32 [ %spec.select.1, %scalar.ph ], [ %.03143.unr, %scalar.ph.prol.loopexit ]
  %59 = mul nuw nsw i64 %indvars.iv73, %9
  %60 = getelementptr inbounds i32, ptr %12, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %spec.select = call i32 @llvm.smin.i32(i32 %61, i32 %.03143)
  %62 = getelementptr i32, ptr %60, i64 %27
  %63 = getelementptr i8, ptr %62, i64 -4
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %.1 = call i32 @llvm.smax.i32(i32 %64, i32 %.03044)
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %65 = mul nuw nsw i64 %indvars.iv.next74, %9
  %66 = getelementptr inbounds i32, ptr %12, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %spec.select.1 = call i32 @llvm.smin.i32(i32 %67, i32 %spec.select)
  %68 = getelementptr i32, ptr %66, i64 %27
  %69 = getelementptr i8, ptr %68, i64 -4
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %.1.1 = call i32 @llvm.smax.i32(i32 %70, i32 %.1)
  %indvars.iv.next74.1 = add nuw nsw i64 %indvars.iv73, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next74.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.preheader, label %scalar.ph, !llvm.loop !16

.lr.ph58.split:                                   ; preds = %.preheader, %._crit_edge54
  %71 = phi i32 [ %76, %._crit_edge54 ], [ %24, %.preheader ]
  %.257 = phi i32 [ %.3, %._crit_edge54 ], [ %.1.lcssa, %.preheader ]
  %.23356 = phi i32 [ %.334, %._crit_edge54 ], [ %spec.select.lcssa, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %72 = add nsw i32 %.257, %.23356
  %73 = sdiv i32 %72, 2
  store i32 %73, ptr %3, align 4, !tbaa !5
  %74 = icmp sgt i32 %71, 0
  br i1 %74, label %.lr.ph53, label %._crit_edge54

._crit_edge54.loopexit:                           ; preds = %.lr.ph53
  %.pre80 = load i32, ptr %3, align 4
  br label %._crit_edge54

._crit_edge54:                                    ; preds = %._crit_edge54.loopexit, %.lr.ph58.split
  %75 = phi i32 [ %73, %.lr.ph58.split ], [ %.pre80, %._crit_edge54.loopexit ]
  %76 = phi i32 [ %71, %.lr.ph58.split ], [ %91, %._crit_edge54.loopexit ]
  %.027.lcssa = phi i32 [ 0, %.lr.ph58.split ], [ %90, %._crit_edge54.loopexit ]
  %.not = icmp sgt i32 %.027.lcssa, %26
  %77 = add nsw i32 %75, 1
  %.334 = select i1 %.not, i32 %.23356, i32 %77
  %.3 = select i1 %.not, i32 %75, i32 %.257
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  %78 = icmp slt i32 %.334, %.3
  br i1 %78, label %.lr.ph58.split, label %._crit_edge59, !llvm.loop !17

.lr.ph53:                                         ; preds = %.lr.ph58.split, %.lr.ph53
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.lr.ph53 ], [ 0, %.lr.ph58.split ]
  %.02750 = phi i32 [ %90, %.lr.ph53 ], [ 0, %.lr.ph58.split ]
  %79 = mul nuw nsw i64 %indvars.iv76, %9
  %80 = getelementptr inbounds i32, ptr %12, i64 %79
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i32, ptr %80, i64 %82
  %84 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull %80, ptr noundef nonnull %83, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %85 = ptrtoint ptr %84 to i64
  %86 = ptrtoint ptr %80 to i64
  %87 = sub i64 %85, %86
  %88 = lshr exact i64 %87, 2
  %89 = trunc i64 %88 to i32
  %90 = add i32 %.02750, %89
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = icmp slt i64 %indvars.iv.next77, %92
  br i1 %93, label %.lr.ph53, label %._crit_edge54.loopexit, !llvm.loop !18

._crit_edge59:                                    ; preds = %._crit_edge54, %0, %._crit_edge42, %.preheader
  %.233.lcssa = phi i32 [ %spec.select.lcssa, %.preheader ], [ 2147483647, %._crit_edge42 ], [ 2147483647, %0 ], [ %.334, %._crit_edge54 ]
  call void @llvm.stackrestore.p0(ptr %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 %.233.lcssa
}

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

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 #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

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

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

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

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass