; LLVM IR from abeaumont/competitive-programming :: codeforces/1517 (c)

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

@xs = external dso_local global [505 x [505 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@__const.main.dy = external hidden unnamed_addr constant [4 x i32], align 16
@__const.main.dx = external hidden unnamed_addr constant [4 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; 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
  %7 = alloca [4 x i32], align 16
  %8 = alloca [4 x i32], align 16
  %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
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %26

26:                                               ; preds = %39, %0
  %27 = load i32, ptr %3, align 4, !tbaa !8
  %28 = load i32, ptr %2, align 4, !tbaa !8
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %42

31:                                               ; preds = %26
  %32 = load i32, ptr %3, align 4, !tbaa !8
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %33
  %35 = load i32, ptr %3, align 4, !tbaa !8
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [505 x i32], ptr %34, i64 0, i64 %36
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %37)
  br label %39

39:                                               ; preds = %31
  %40 = load i32, ptr %3, align 4, !tbaa !8
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !8
  br label %26, !llvm.loop !11

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

43:                                               ; preds = %126, %42
  %44 = load i32, ptr %4, align 4, !tbaa !8
  %45 = load i32, ptr %2, align 4, !tbaa !8
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %129

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %49 = load i32, ptr %4, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %50
  %52 = load i32, ptr %4, align 4, !tbaa !8
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [505 x i32], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !8
  store i32 %55, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.main.dy, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const.main.dx, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %56 = load i32, ptr %4, align 4, !tbaa !8
  store i32 %56, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %57 = load i32, ptr %4, align 4, !tbaa !8
  store i32 %57, ptr %10, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !8
  br label %58

58:                                               ; preds = %122, %48
  %59 = load i32, ptr %11, align 4, !tbaa !8
  %60 = load i32, ptr %6, align 4, !tbaa !8
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !8
  br label %64

64:                                               ; preds = %117, %63
  %65 = load i32, ptr %12, align 4, !tbaa !8
  %66 = icmp slt i32 %65, 4
  br i1 %66, label %68, label %67

67:                                               ; preds = %64
  store i32 11, ptr %5, align 4
  br label %120

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %69 = load i32, ptr %9, align 4, !tbaa !8
  %70 = load i32, ptr %12, align 4, !tbaa !8
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [4 x i32], ptr %7, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !8
  %74 = add nsw i32 %69, %73
  store i32 %74, ptr %13, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %75 = load i32, ptr %10, align 4, !tbaa !8
  %76 = load i32, ptr %12, align 4, !tbaa !8
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !8
  %80 = add nsw i32 %75, %79
  store i32 %80, ptr %14, align 4, !tbaa !8
  %81 = load i32, ptr %13, align 4, !tbaa !8
  %82 = icmp sge i32 %81, 0
  br i1 %82, label %83, label %113

83:                                               ; preds = %68
  %84 = load i32, ptr %13, align 4, !tbaa !8
  %85 = load i32, ptr %2, align 4, !tbaa !8
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %87, label %113

87:                                               ; preds = %83
  %88 = load i32, ptr %14, align 4, !tbaa !8
  %89 = icmp sge i32 %88, 0
  br i1 %89, label %90, label %113

90:                                               ; preds = %87
  %91 = load i32, ptr %14, align 4, !tbaa !8
  %92 = load i32, ptr %2, align 4, !tbaa !8
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %113

94:                                               ; preds = %90
  %95 = load i32, ptr %13, align 4, !tbaa !8
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %96
  %98 = load i32, ptr %14, align 4, !tbaa !8
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [505 x i32], ptr %97, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !8
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %113, label %103

103:                                              ; preds = %94
  %104 = load i32, ptr %6, align 4, !tbaa !8
  %105 = load i32, ptr %13, align 4, !tbaa !8
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %106
  %108 = load i32, ptr %14, align 4, !tbaa !8
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [505 x i32], ptr %107, i64 0, i64 %109
  store i32 %104, ptr %110, align 4, !tbaa !8
  %111 = load i32, ptr %13, align 4, !tbaa !8
  store i32 %111, ptr %9, align 4, !tbaa !8
  %112 = load i32, ptr %14, align 4, !tbaa !8
  store i32 %112, ptr %10, align 4, !tbaa !8
  store i32 11, ptr %5, align 4
  br label %114

113:                                              ; preds = %94, %90, %87, %83, %68
  store i32 0, ptr %5, align 4
  br label %114

114:                                              ; preds = %113, %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %115 = load i32, ptr %5, align 4
  switch i32 %115, label %120 [
    i32 0, label %116
  ]

116:                                              ; preds = %114
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %12, align 4, !tbaa !8
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %12, align 4, !tbaa !8
  br label %64, !llvm.loop !13

120:                                              ; preds = %114, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  %123 = load i32, ptr %11, align 4, !tbaa !8
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %11, align 4, !tbaa !8
  br label %58, !llvm.loop !14

125:                                              ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %4, align 4, !tbaa !8
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %4, align 4, !tbaa !8
  br label %43, !llvm.loop !15

129:                                              ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !8
  br label %130

130:                                              ; preds = %159, %129
  %131 = load i32, ptr %15, align 4, !tbaa !8
  %132 = load i32, ptr %2, align 4, !tbaa !8
  %133 = icmp slt i32 %131, %132
  br i1 %133, label %135, label %134

134:                                              ; preds = %130
  store i32 14, ptr %5, align 4
  br label %162

135:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !8
  br label %136

136:                                              ; preds = %153, %135
  %137 = load i32, ptr %16, align 4, !tbaa !8
  %138 = load i32, ptr %15, align 4, !tbaa !8
  %139 = icmp sle i32 %137, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %136
  store i32 17, ptr %5, align 4
  br label %156

141:                                              ; preds = %136
  %142 = load i32, ptr %15, align 4, !tbaa !8
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %143
  %145 = load i32, ptr %16, align 4, !tbaa !8
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [505 x i32], ptr %144, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !8
  %149 = icmp ne i32 %148, 0
  br i1 %149, label %152, label %150

150:                                              ; preds = %141
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %156

152:                                              ; preds = %141
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %16, align 4, !tbaa !8
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %16, align 4, !tbaa !8
  br label %136, !llvm.loop !16

156:                                              ; preds = %150, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  %157 = load i32, ptr %5, align 4
  switch i32 %157, label %162 [
    i32 17, label %158
  ]

158:                                              ; preds = %156
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %15, align 4, !tbaa !8
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %15, align 4, !tbaa !8
  br label %130, !llvm.loop !17

162:                                              ; preds = %156, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  %163 = load i32, ptr %5, align 4
  switch i32 %163, label %200 [
    i32 14, label %164
  ]

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

165:                                              ; preds = %196, %164
  %166 = load i32, ptr %17, align 4, !tbaa !8
  %167 = load i32, ptr %2, align 4, !tbaa !8
  %168 = icmp slt i32 %166, %167
  br i1 %168, label %170, label %169

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

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

171:                                              ; preds = %192, %170
  %172 = load i32, ptr %18, align 4, !tbaa !8
  %173 = load i32, ptr %17, align 4, !tbaa !8
  %174 = icmp sle i32 %172, %173
  br i1 %174, label %176, label %175

175:                                              ; preds = %171
  store i32 23, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %195

176:                                              ; preds = %171
  %177 = load i32, ptr %17, align 4, !tbaa !8
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %178
  %180 = load i32, ptr %18, align 4, !tbaa !8
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [505 x i32], ptr %179, i64 0, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !8
  %184 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %183)
  %185 = load i32, ptr %18, align 4, !tbaa !8
  %186 = load i32, ptr %17, align 4, !tbaa !8
  %187 = icmp eq i32 %185, %186
  %188 = zext i1 %187 to i64
  %189 = getelementptr inbounds [3 x i8], ptr @.str.1, i64 0, i64 %188
  %190 = load i8, ptr %189, align 1, !tbaa !18
  %191 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %184, i8 noundef signext %190)
  br label %192

192:                                              ; preds = %176
  %193 = load i32, ptr %18, align 4, !tbaa !8
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %18, align 4, !tbaa !8
  br label %171, !llvm.loop !19

195:                                              ; preds = %175
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %17, align 4, !tbaa !8
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %17, align 4, !tbaa !8
  br label %165, !llvm.loop !20

199:                                              ; preds = %169
  store i32 0, ptr %5, align 4
  br label %200

200:                                              ; preds = %199, %162
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %201 = load i32, ptr %5, align 4
  switch i32 %201, label %204 [
    i32 0, label %202
    i32 1, label %202
  ]

202:                                              ; preds = %200, %200
  %203 = load i32, ptr %1, align 4
  ret i32 %203

204:                                              ; preds = %200
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

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

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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

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

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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !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 = !{!10, !10, i64 0}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !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" }

@xs = external dso_local global [505 x [505 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@__const.main.dy = external hidden unnamed_addr constant [4 x i32], align 16
@__const.main.dx = external hidden unnamed_addr constant [4 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %8 = 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)
  %9 = load i32, ptr %1, align 4, !tbaa !8
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.loopexit

.preheader91:                                     ; preds = %.lr.ph
  %11 = icmp sgt i32 %20, 0
  br i1 %11, label %.lr.ph101.preheader, label %.loopexit

.lr.ph101.preheader:                              ; preds = %.preheader91
  %wide.trip.count = zext nneg i32 %20 to i64
  %.pre = load i32, ptr @__const.main.dy, align 16
  %.pre150 = load i32, ptr @__const.main.dx, align 16
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 4), align 4
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 4), align 4
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 8), align 8
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 8), align 8
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dy, i64 12), align 4
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.dx, i64 12), align 4
  br label %.lr.ph101

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %18 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %indvars.iv, i64 %indvars.iv
  %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) %18)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = load i32, ptr %1, align 4, !tbaa !8
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %indvars.iv.next, %21
  br i1 %22, label %.lr.ph, label %.preheader91, !llvm.loop !11

.preheader88:                                     ; preds = %._crit_edge
  br i1 %11, label %.preheader87.preheader, label %.loopexit

.preheader87.preheader:                           ; preds = %.preheader88
  %wide.trip.count134 = zext nneg i32 %20 to i64
  br label %.preheader87

.lr.ph101:                                        ; preds = %.lr.ph101.preheader, %._crit_edge
  %indvars.iv116 = phi i64 [ 0, %.lr.ph101.preheader ], [ %indvars.iv.next117, %._crit_edge ]
  %23 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %indvars.iv116, i64 %indvars.iv116
  %24 = load i32, ptr %23, align 4, !tbaa !8
  %25 = icmp sgt i32 %24, 1
  br i1 %25, label %.preheader89.preheader, label %._crit_edge

.preheader89.preheader:                           ; preds = %.lr.ph101
  %26 = trunc nuw nsw i64 %indvars.iv116 to i32
  br label %.preheader89

.preheader89:                                     ; preds = %.preheader89.preheader, %.loopexit90
  %.05999 = phi i32 [ %75, %.loopexit90 ], [ 1, %.preheader89.preheader ]
  %.06098 = phi i32 [ %.3, %.loopexit90 ], [ %26, %.preheader89.preheader ]
  %.06397 = phi i32 [ %.366, %.loopexit90 ], [ %26, %.preheader89.preheader ]
  %27 = add nsw i32 %.pre, %.06397
  %28 = add nsw i32 %.pre150, %.06098
  %29 = icmp sgt i32 %27, -1
  br i1 %29, label %30, label %39

._crit_edge:                                      ; preds = %.loopexit90, %.lr.ph101
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %exitcond119.not = icmp eq i64 %indvars.iv.next117, %wide.trip.count
  br i1 %exitcond119.not, label %.preheader88, label %.lr.ph101, !llvm.loop !13

30:                                               ; preds = %.preheader89
  %31 = icmp slt i32 %27, %20
  %32 = icmp ult i32 %28, %20
  %or.cond79 = select i1 %31, i1 %32, i1 false
  br i1 %or.cond79, label %33, label %39

33:                                               ; preds = %30
  %34 = zext nneg i32 %27 to i64
  %35 = zext nneg i32 %28 to i64
  %36 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %34, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !8
  %.not78 = icmp eq i32 %37, 0
  br i1 %.not78, label %38, label %39

38:                                               ; preds = %70, %58, %46, %33
  %.lcssa109 = phi i32 [ %27, %33 ], [ %40, %46 ], [ %52, %58 ], [ %64, %70 ]
  %.lcssa107 = phi i32 [ %28, %33 ], [ %41, %46 ], [ %53, %58 ], [ %65, %70 ]
  %.lcssa = phi ptr [ %36, %33 ], [ %49, %46 ], [ %61, %58 ], [ %73, %70 ]
  store i32 %24, ptr %.lcssa, align 4, !tbaa !8
  br label %.loopexit90

39:                                               ; preds = %33, %30, %.preheader89
  %40 = add nsw i32 %12, %.06397
  %41 = add nsw i32 %13, %.06098
  %42 = icmp sgt i32 %40, -1
  br i1 %42, label %43, label %51

43:                                               ; preds = %39
  %44 = icmp slt i32 %40, %20
  %45 = icmp ult i32 %41, %20
  %or.cond79.1 = select i1 %44, i1 %45, i1 false
  br i1 %or.cond79.1, label %46, label %51

46:                                               ; preds = %43
  %47 = zext nneg i32 %40 to i64
  %48 = zext nneg i32 %41 to i64
  %49 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %47, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !8
  %.not78.1 = icmp eq i32 %50, 0
  br i1 %.not78.1, label %38, label %51

51:                                               ; preds = %46, %43, %39
  %52 = add nsw i32 %14, %.06397
  %53 = add nsw i32 %15, %.06098
  %54 = icmp sgt i32 %52, -1
  br i1 %54, label %55, label %63

55:                                               ; preds = %51
  %56 = icmp slt i32 %52, %20
  %57 = icmp ult i32 %53, %20
  %or.cond79.2 = select i1 %56, i1 %57, i1 false
  br i1 %or.cond79.2, label %58, label %63

58:                                               ; preds = %55
  %59 = zext nneg i32 %52 to i64
  %60 = zext nneg i32 %53 to i64
  %61 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %59, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !8
  %.not78.2 = icmp eq i32 %62, 0
  br i1 %.not78.2, label %38, label %63

63:                                               ; preds = %58, %55, %51
  %64 = add nsw i32 %16, %.06397
  %65 = add nsw i32 %17, %.06098
  %66 = icmp sgt i32 %64, -1
  br i1 %66, label %67, label %.loopexit90

67:                                               ; preds = %63
  %68 = icmp slt i32 %64, %20
  %69 = icmp ult i32 %65, %20
  %or.cond79.3 = select i1 %68, i1 %69, i1 false
  br i1 %or.cond79.3, label %70, label %.loopexit90

70:                                               ; preds = %67
  %71 = zext nneg i32 %64 to i64
  %72 = zext nneg i32 %65 to i64
  %73 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %71, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !8
  %.not78.3 = icmp eq i32 %74, 0
  br i1 %.not78.3, label %38, label %.loopexit90

.loopexit90:                                      ; preds = %63, %67, %70, %38
  %.366 = phi i32 [ %.lcssa109, %38 ], [ %.06397, %70 ], [ %.06397, %67 ], [ %.06397, %63 ]
  %.3 = phi i32 [ %.lcssa107, %38 ], [ %.06098, %70 ], [ %.06098, %67 ], [ %.06098, %63 ]
  %75 = add nuw nsw i32 %.05999, 1
  %exitcond.not = icmp eq i32 %75, %24
  br i1 %exitcond.not, label %._crit_edge, label %.preheader89, !llvm.loop !14

.preheader87:                                     ; preds = %.preheader87.preheader, %.critedge
  %indvars.iv129 = phi i64 [ 0, %.preheader87.preheader ], [ %indvars.iv.next130, %.critedge ]
  %indvars.iv127 = phi i64 [ 1, %.preheader87.preheader ], [ %indvars.iv.next128, %.critedge ]
  br label %77

76:                                               ; preds = %77
  %indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
  %exitcond126.not = icmp eq i64 %indvars.iv.next121, %indvars.iv127
  br i1 %exitcond126.not, label %.critedge, label %77, !llvm.loop !15

77:                                               ; preds = %.preheader87, %76
  %indvars.iv120 = phi i64 [ 0, %.preheader87 ], [ %indvars.iv.next121, %76 ]
  %78 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %indvars.iv129, i64 %indvars.iv120
  %79 = load i32, ptr %78, align 4, !tbaa !8
  %.not75 = icmp eq i32 %79, 0
  br i1 %.not75, label %80, label %76

.critedge:                                        ; preds = %76
  %indvars.iv.next130 = add nuw nsw i64 %indvars.iv129, 1
  %indvars.iv.next128 = add nuw nsw i64 %indvars.iv127, 1
  %exitcond135.not = icmp eq i64 %indvars.iv.next130, %wide.trip.count134
  br i1 %exitcond135.not, label %.critedge81, label %.preheader87, !llvm.loop !16

80:                                               ; preds = %77
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  br label %.loopexit

.critedge81:                                      ; preds = %.critedge
  br i1 %11, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.critedge81, %82
  %indvars.iv145 = phi i64 [ %indvars.iv.next146, %82 ], [ 0, %.critedge81 ]
  %indvars.iv143 = phi i64 [ %indvars.iv.next144, %82 ], [ 1, %.critedge81 ]
  br label %86

82:                                               ; preds = %86
  %indvars.iv.next146 = add nuw nsw i64 %indvars.iv145, 1
  %83 = load i32, ptr %1, align 4, !tbaa !8
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv.next146, %84
  %indvars.iv.next144 = add nuw nsw i64 %indvars.iv143, 1
  br i1 %85, label %.preheader, label %.loopexit, !llvm.loop !17

86:                                               ; preds = %.preheader, %86
  %indvars.iv136 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next137, %86 ]
  %87 = getelementptr inbounds [505 x [505 x i32]], ptr @xs, i64 0, i64 %indvars.iv145, i64 %indvars.iv136
  %88 = load i32, ptr %87, align 4, !tbaa !8
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %88)
  %90 = icmp eq i64 %indvars.iv136, %indvars.iv145
  %91 = zext i1 %90 to i64
  %92 = getelementptr inbounds [3 x i8], ptr @.str.1, i64 0, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !18
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %89, i8 noundef signext %93)
  %indvars.iv.next137 = add nuw nsw i64 %indvars.iv136, 1
  %exitcond142.not = icmp eq i64 %indvars.iv.next137, %indvars.iv143
  br i1 %exitcond142.not, label %82, label %86, !llvm.loop !19

.loopexit:                                        ; preds = %82, %0, %.preheader91, %.preheader88, %.critedge81, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

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

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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) 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 #2

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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 memory(argmem: readwrite) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !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 = !{!10, !10, i64 0}
!19 = distinct !{!19, !12}


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