; LLVM IR from ravireddy07/cpp-book :: src/Matrices (LongestSquareWithAllOneTopDown)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z15solutionTopDownPPiiiS0_ii(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #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 ptr, align 8
  %9 = alloca ptr, align 8
  %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
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = 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) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %22, i64 8)
  %24 = extractvalue { i64, i1 } %23, 1
  %25 = extractvalue { i64, i1 } %23, 0
  %26 = select i1 %24, i64 -1, i64 %25
  %27 = call noalias noundef nonnull ptr @_Znam(i64 noundef %26) #7
  store ptr %27, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %29, i64 8)
  %31 = extractvalue { i64, i1 } %30, 1
  %32 = extractvalue { i64, i1 } %30, 0
  %33 = select i1 %31, i64 -1, i64 %32
  %34 = call noalias noundef nonnull ptr @_Znam(i64 noundef %33) #7
  store ptr %34, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %63, %2
  %36 = load i32, ptr %10, align 4, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %66

40:                                               ; preds = %35
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %42, i64 4)
  %44 = extractvalue { i64, i1 } %43, 1
  %45 = extractvalue { i64, i1 } %43, 0
  %46 = select i1 %44, i64 -1, i64 %45
  %47 = call noalias noundef nonnull ptr @_Znam(i64 noundef %46) #7
  %48 = load ptr, ptr %9, align 8, !tbaa !9
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %48, i64 %50
  store ptr %47, ptr %51, align 8, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %53, i64 4)
  %55 = extractvalue { i64, i1 } %54, 1
  %56 = extractvalue { i64, i1 } %54, 0
  %57 = select i1 %55, i64 -1, i64 %56
  %58 = call noalias noundef nonnull ptr @_Znam(i64 noundef %57) #7
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = load i32, ptr %10, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  store ptr %58, ptr %62, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %40
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %10, align 4, !tbaa !5
  br label %35, !llvm.loop !11

66:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %100, %66
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %103

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

73:                                               ; preds = %96, %72
  %74 = load i32, ptr %13, align 4, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %99

78:                                               ; preds = %73
  %79 = load ptr, ptr %9, align 8, !tbaa !9
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds ptr, ptr %79, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  %84 = load i32, ptr %13, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %83, i64 %85
  store i32 -1, ptr %86, align 4, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !9
  %88 = load i32, ptr %11, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds ptr, ptr %87, i64 %89
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = load i32, ptr %13, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds i32, ptr %91, i64 %93
  %95 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %94)
  br label %96

96:                                               ; preds = %78
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %13, align 4, !tbaa !5
  br label %73, !llvm.loop !13

99:                                               ; preds = %77
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %11, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %11, align 4, !tbaa !5
  br label %67, !llvm.loop !14

103:                                              ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %123, %103
  %105 = load i32, ptr %14, align 4, !tbaa !5
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %126

109:                                              ; preds = %104
  %110 = load ptr, ptr %8, align 8, !tbaa !9
  %111 = getelementptr inbounds ptr, ptr %110, i64 0
  %112 = load ptr, ptr %111, align 8, !tbaa !9
  %113 = load i32, ptr %14, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds i32, ptr %112, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = load ptr, ptr %9, align 8, !tbaa !9
  %118 = getelementptr inbounds ptr, ptr %117, i64 0
  %119 = load ptr, ptr %118, align 8, !tbaa !9
  %120 = load i32, ptr %14, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  store i32 %116, ptr %122, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %109
  %124 = load i32, ptr %14, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %14, align 4, !tbaa !5
  br label %104, !llvm.loop !15

126:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %127

127:                                              ; preds = %146, %126
  %128 = load i32, ptr %15, align 4, !tbaa !5
  %129 = load i32, ptr %6, align 4, !tbaa !5
  %130 = icmp slt i32 %128, %129
  br i1 %130, label %132, label %131

131:                                              ; preds = %127
  store i32 14, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %149

132:                                              ; preds = %127
  %133 = load ptr, ptr %8, align 8, !tbaa !9
  %134 = load i32, ptr %15, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds ptr, ptr %133, i64 %135
  %137 = load ptr, ptr %136, align 8, !tbaa !9
  %138 = getelementptr inbounds i32, ptr %137, i64 0
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = load ptr, ptr %9, align 8, !tbaa !9
  %141 = load i32, ptr %15, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds ptr, ptr %140, i64 %142
  %144 = load ptr, ptr %143, align 8, !tbaa !9
  %145 = getelementptr inbounds i32, ptr %144, i64 0
  store i32 %139, ptr %145, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %132
  %147 = load i32, ptr %15, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %15, align 4, !tbaa !5
  br label %127, !llvm.loop !16

149:                                              ; preds = %131
  %150 = load ptr, ptr %8, align 8, !tbaa !9
  %151 = load i32, ptr %6, align 4, !tbaa !5
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = load ptr, ptr %9, align 8, !tbaa !9
  %154 = load i32, ptr %6, align 4, !tbaa !5
  %155 = sub nsw i32 %154, 1
  %156 = load i32, ptr %7, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = call noundef i32 @_Z15solutionTopDownPPiiiS0_ii(ptr noundef %150, i32 noundef %151, i32 noundef %152, ptr noundef %153, i32 noundef %155, i32 noundef %157)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %197, %149
  %160 = load i32, ptr %17, align 4, !tbaa !5
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = icmp slt i32 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 17, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %200

164:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %193, %164
  %166 = load i32, ptr %18, align 4, !tbaa !5
  %167 = load i32, ptr %7, align 4, !tbaa !5
  %168 = icmp slt i32 %166, %167
  br i1 %168, label %170, label %169

169:                                              ; preds = %165
  store i32 20, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %196

170:                                              ; preds = %165
  %171 = load ptr, ptr %9, align 8, !tbaa !9
  %172 = load i32, ptr %17, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds ptr, ptr %171, i64 %173
  %175 = load ptr, ptr %174, align 8, !tbaa !9
  %176 = load i32, ptr %18, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds i32, ptr %175, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = load i32, ptr %16, align 4, !tbaa !5
  %181 = icmp sgt i32 %179, %180
  br i1 %181, label %182, label %192

182:                                              ; preds = %170
  %183 = load ptr, ptr %9, align 8, !tbaa !9
  %184 = load i32, ptr %17, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds ptr, ptr %183, i64 %185
  %187 = load ptr, ptr %186, align 8, !tbaa !9
  %188 = load i32, ptr %18, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds i32, ptr %187, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  store i32 %191, ptr %16, align 4, !tbaa !5
  br label %192

192:                                              ; preds = %182, %170
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr %18, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %18, align 4, !tbaa !5
  br label %165, !llvm.loop !17

196:                                              ; preds = %169
  br label %197

197:                                              ; preds = %196
  %198 = load i32, ptr %17, align 4, !tbaa !5
  %199 = add nsw i32 %198, 1
  store i32 %199, ptr %17, align 4, !tbaa !5
  br label %159, !llvm.loop !18

200:                                              ; preds = %163
  %201 = load i32, ptr %16, align 4, !tbaa !5
  %202 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %201)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %203 = load i32, ptr %3, align 4
  ret i32 %203
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #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 = { 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 = { "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 = { nobuiltin allocsize(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 }
attributes #7 = { builtin allocsize(0) }

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"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" }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z15solutionTopDownPPiiiS0_ii(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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 nocapture noundef readnone %1) local_unnamed_addr #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = icmp slt i32 %7, 0
  %10 = shl nsw i64 %8, 3
  %11 = select i1 %9, i64 -1, i64 %10
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #7
  %13 = call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #7
  %14 = icmp sgt i32 %7, 0
  %.pre101.pre = load i32, ptr %4, align 4, !tbaa !5
  br i1 %14, label %.lr.ph, label %.preheader52

.lr.ph:                                           ; preds = %2
  %15 = sext i32 %.pre101.pre to i64
  %16 = icmp slt i32 %.pre101.pre, 0
  %17 = shl nsw i64 %15, 2
  %18 = select i1 %16, i64 -1, i64 %17
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %20

.preheader54:                                     ; preds = %20
  br i1 %14, label %.preheader53.lr.ph, label %.preheader52

.preheader53.lr.ph:                               ; preds = %.preheader54
  %19 = icmp sgt i32 %.pre101.pre, 0
  br i1 %19, label %.preheader53, label %.lr.ph62.preheader

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #7
  %22 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv
  store ptr %21, ptr %22, align 8, !tbaa !9
  %23 = call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #7
  %24 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv
  store ptr %23, ptr %24, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader54, label %20, !llvm.loop !11

.preheader53:                                     ; preds = %.preheader53.lr.ph, %._crit_edge
  %25 = phi i32 [ %35, %._crit_edge ], [ %7, %.preheader53.lr.ph ]
  %26 = phi i32 [ %36, %._crit_edge ], [ %.pre101.pre, %.preheader53.lr.ph ]
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %._crit_edge ], [ 0, %.preheader53.lr.ph ]
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph57, label %._crit_edge

.lr.ph57:                                         ; preds = %.preheader53
  %28 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv80
  %29 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv80
  %.pre = load ptr, ptr %28, align 8, !tbaa !9
  %.pre99 = load ptr, ptr %29, align 8, !tbaa !9
  br label %39

.preheader52:                                     ; preds = %._crit_edge, %2, %.preheader54
  %30 = phi i32 [ %7, %.preheader54 ], [ %7, %2 ], [ %35, %._crit_edge ]
  %31 = phi i32 [ %.pre101.pre, %.preheader54 ], [ %.pre101.pre, %2 ], [ %36, %._crit_edge ]
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph60, label %.preheader51

.lr.ph60:                                         ; preds = %.preheader52
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = load ptr, ptr %13, align 8, !tbaa !9
  br label %49

._crit_edge.loopexit:                             ; preds = %39
  %.pre100 = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader53
  %35 = phi i32 [ %.pre100, %._crit_edge.loopexit ], [ %25, %.preheader53 ]
  %36 = phi i32 [ %43, %._crit_edge.loopexit ], [ %26, %.preheader53 ]
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %37 = sext i32 %35 to i64
  %38 = icmp slt i64 %indvars.iv.next81, %37
  br i1 %38, label %.preheader53, label %.preheader52, !llvm.loop !13

39:                                               ; preds = %.lr.ph57, %39
  %indvars.iv77 = phi i64 [ 0, %.lr.ph57 ], [ %indvars.iv.next78, %39 ]
  %40 = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv77
  store i32 -1, ptr %40, align 4, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %.pre99, i64 %indvars.iv77
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next78, %44
  br i1 %45, label %39, label %._crit_edge.loopexit, !llvm.loop !15

.preheader51.loopexit:                            ; preds = %49
  %.pre102 = load i32, ptr %3, align 4, !tbaa !5
  br label %.preheader51

.preheader51:                                     ; preds = %.preheader51.loopexit, %.preheader52
  %46 = phi i32 [ %53, %.preheader51.loopexit ], [ %31, %.preheader52 ]
  %47 = phi i32 [ %.pre102, %.preheader51.loopexit ], [ %30, %.preheader52 ]
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph62.preheader, label %._crit_edge63

.lr.ph62.preheader:                               ; preds = %.preheader53.lr.ph, %.preheader51
  br label %.lr.ph62

49:                                               ; preds = %.lr.ph60, %49
  %indvars.iv83 = phi i64 [ 0, %.lr.ph60 ], [ %indvars.iv.next84, %49 ]
  %50 = getelementptr inbounds i32, ptr %33, i64 %indvars.iv83
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %34, i64 %indvars.iv83
  store i32 %51, ptr %52, align 4, !tbaa !5
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = icmp slt i64 %indvars.iv.next84, %54
  br i1 %55, label %49, label %.preheader51.loopexit, !llvm.loop !16

._crit_edge63.loopexit:                           ; preds = %.lr.ph62
  %.pre103 = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge63

._crit_edge63:                                    ; preds = %._crit_edge63.loopexit, %.preheader51
  %56 = phi i32 [ %46, %.preheader51 ], [ %.pre103, %._crit_edge63.loopexit ]
  %.lcssa = phi i32 [ %47, %.preheader51 ], [ %79, %._crit_edge63.loopexit ]
  %57 = add nsw i32 %.lcssa, -1
  %58 = add nsw i32 %56, -1
  %59 = call noundef i32 @_Z15solutionTopDownPPiiiS0_ii(ptr noundef nonnull %12, i32 noundef %.lcssa, i32 noundef %56, ptr noundef nonnull %13, i32 noundef %57, i32 noundef %58)
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %.preheader.lr.ph, label %._crit_edge71

.preheader.lr.ph:                                 ; preds = %._crit_edge63
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %.preheader.us.preheader, label %._crit_edge71

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count97 = zext nneg i32 %60 to i64
  %wide.trip.count92 = zext nneg i32 %62 to i64
  %min.iters.check = icmp ult i32 %62, 8
  %n.vec = and i64 %wide.trip.count92, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count92
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge67.us
  %indvars.iv94 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next95, %._crit_edge67.us ]
  %.04369.us = phi i32 [ 0, %.preheader.us.preheader ], [ %spec.select.us.lcssa, %._crit_edge67.us ]
  %64 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv94
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader.us
  %minmax.ident.splatinsert = insertelement <4 x i32> poison, i32 %.04369.us, i64 0
  %minmax.ident.splat = shufflevector <4 x i32> %minmax.ident.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> [ %minmax.ident.splat, %vector.ph ], [ %68, %vector.body ]
  %vec.phi114 = phi <4 x i32> [ %minmax.ident.splat, %vector.ph ], [ %69, %vector.body ]
  %66 = getelementptr inbounds i32, ptr %65, i64 %index
  %67 = getelementptr inbounds i8, ptr %66, i64 16
  %wide.load = load <4 x i32>, ptr %66, align 4, !tbaa !5
  %wide.load115 = load <4 x i32>, ptr %67, align 4, !tbaa !5
  %68 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %69 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load115, <4 x i32> %vec.phi114)
  %index.next = add nuw i64 %index, 8
  %70 = icmp eq i64 %index.next, %n.vec
  br i1 %70, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %68, <4 x i32> %69)
  %71 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
  br i1 %cmp.n, label %._crit_edge67.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader.us
  %indvars.iv89.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  %.164.us.ph = phi i32 [ %.04369.us, %.preheader.us ], [ %71, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %scalar.ph ], [ %indvars.iv89.ph, %scalar.ph.preheader ]
  %.164.us = phi i32 [ %spec.select.us, %scalar.ph ], [ %.164.us.ph, %scalar.ph.preheader ]
  %72 = getelementptr inbounds i32, ptr %65, i64 %indvars.iv89
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %spec.select.us = call i32 @llvm.smax.i32(i32 %73, i32 %.164.us)
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %exitcond93.not = icmp eq i64 %indvars.iv.next90, %wide.trip.count92
  br i1 %exitcond93.not, label %._crit_edge67.us, label %scalar.ph, !llvm.loop !20

._crit_edge67.us:                                 ; preds = %scalar.ph, %middle.block
  %spec.select.us.lcssa = phi i32 [ %71, %middle.block ], [ %spec.select.us, %scalar.ph ]
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %exitcond98.not = icmp eq i64 %indvars.iv.next95, %wide.trip.count97
  br i1 %exitcond98.not, label %._crit_edge71, label %.preheader.us, !llvm.loop !21

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %.lr.ph62
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %.lr.ph62 ], [ 0, %.lr.ph62.preheader ]
  %74 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv86
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv86
  %78 = load ptr, ptr %77, align 8, !tbaa !9
  store i32 %76, ptr %78, align 4, !tbaa !5
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next87, %80
  br i1 %81, label %.lr.ph62, label %._crit_edge63.loopexit, !llvm.loop !22

._crit_edge71:                                    ; preds = %._crit_edge67.us, %.preheader.lr.ph, %._crit_edge63
  %.043.lcssa = phi i32 [ 0, %._crit_edge63 ], [ 0, %.preheader.lr.ph ], [ %spec.select.us.lcssa, %._crit_edge67.us ]
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.043.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %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)) local_unnamed_addr #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

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

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

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 = { 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 = { "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 = { nobuiltin allocsize(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 }
attributes #7 = { builtin allocsize(0) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12, !18, !19}
!18 = !{!"llvm.loop.isvectorized", i32 1}
!19 = !{!"llvm.loop.unroll.runtime.disable"}
!20 = distinct !{!20, !12, !19, !18}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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