; LLVM IR from manishbisht/Competitive-Programming :: Codeforces/Codeforces Round #369 (Div. 2) (Chris and Magic Square)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

@n = external dso_local global i64, align 8
@a = external dso_local global [505 x [505 x i64]], align 16
@b = external dso_local global [505 x i64], align 16
@i = external dso_local global i64, align 8
@j = external dso_local global i64, align 8
@c = external dso_local global [505 x i64], align 16
@temp = external dso_local global i64, align 8
@t = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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
  store i32 0, ptr %1, align 4
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %3 = load i64, ptr @n, align 8, !tbaa !5
  %4 = icmp eq i64 %3, 1
  br i1 %4, label %5, label %8

5:                                                ; preds = %0
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %7 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %203

8:                                                ; preds = %0
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %51, %8
  %10 = load i64, ptr @i, align 8, !tbaa !5
  %11 = load i64, ptr @n, align 8, !tbaa !5
  %12 = icmp slt i64 %10, %11
  br i1 %12, label %13, label %54

13:                                               ; preds = %9
  %14 = load i64, ptr @i, align 8, !tbaa !5
  %15 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %14
  store i64 0, ptr %15, align 8, !tbaa !5
  store i64 0, ptr @j, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %47, %13
  %17 = load i64, ptr @j, align 8, !tbaa !5
  %18 = load i64, ptr @n, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %20, label %50

20:                                               ; preds = %16
  %21 = load i64, ptr @i, align 8, !tbaa !5
  %22 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %21
  %23 = load i64, ptr @j, align 8, !tbaa !5
  %24 = getelementptr inbounds [505 x i64], ptr %22, i64 0, i64 %23
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load i64, ptr @i, align 8, !tbaa !5
  %27 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %26
  %28 = load i64, ptr @j, align 8, !tbaa !5
  %29 = getelementptr inbounds [505 x i64], ptr %27, i64 0, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %20
  %33 = load i64, ptr @i, align 8, !tbaa !5
  store i64 %33, ptr @temp, align 8, !tbaa !5
  br label %46

34:                                               ; preds = %20
  %35 = load i64, ptr @i, align 8, !tbaa !5
  %36 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr @i, align 8, !tbaa !5
  %39 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %38
  %40 = load i64, ptr @j, align 8, !tbaa !5
  %41 = getelementptr inbounds [505 x i64], ptr %39, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = add nsw i64 %37, %42
  %44 = load i64, ptr @i, align 8, !tbaa !5
  %45 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %44
  store i64 %43, ptr %45, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %34, %32
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr @j, align 8, !tbaa !5
  %49 = add nsw i64 %48, 1
  store i64 %49, ptr @j, align 8, !tbaa !5
  br label %16, !llvm.loop !9

50:                                               ; preds = %16
  br label %51

51:                                               ; preds = %50
  %52 = load i64, ptr @i, align 8, !tbaa !5
  %53 = add nsw i64 %52, 1
  store i64 %53, ptr @i, align 8, !tbaa !5
  br label %9, !llvm.loop !11

54:                                               ; preds = %9
  %55 = load i64, ptr @temp, align 8, !tbaa !5
  %56 = icmp eq i64 %55, 0
  br i1 %56, label %57, label %64

57:                                               ; preds = %54
  %58 = load i64, ptr getelementptr inbounds ([505 x i64], ptr @c, i64 0, i64 1), align 8, !tbaa !5
  %59 = load i64, ptr @c, align 16, !tbaa !5
  %60 = sub nsw i64 %58, %59
  store i64 %60, ptr @t, align 8, !tbaa !5
  %61 = load i64, ptr @c, align 16, !tbaa !5
  %62 = load i64, ptr @t, align 8, !tbaa !5
  %63 = add nsw i64 %61, %62
  store i64 %63, ptr @c, align 16, !tbaa !5
  br label %77

64:                                               ; preds = %54
  %65 = load i64, ptr @c, align 16, !tbaa !5
  %66 = load i64, ptr @temp, align 8, !tbaa !5
  %67 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = sub nsw i64 %65, %68
  store i64 %69, ptr @t, align 8, !tbaa !5
  %70 = load i64, ptr @temp, align 8, !tbaa !5
  %71 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !5
  %73 = load i64, ptr @t, align 8, !tbaa !5
  %74 = add nsw i64 %72, %73
  %75 = load i64, ptr @temp, align 8, !tbaa !5
  %76 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %75
  store i64 %74, ptr %76, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %64, %57
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %96, %77
  %79 = load i64, ptr @i, align 8, !tbaa !5
  %80 = load i64, ptr @n, align 8, !tbaa !5
  %81 = sub nsw i64 %80, 1
  %82 = icmp slt i64 %79, %81
  br i1 %82, label %83, label %99

83:                                               ; preds = %78
  %84 = load i64, ptr @i, align 8, !tbaa !5
  %85 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %84
  %86 = load i64, ptr %85, align 8, !tbaa !5
  %87 = load i64, ptr @i, align 8, !tbaa !5
  %88 = add nsw i64 %87, 1
  %89 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !5
  %91 = icmp ne i64 %86, %90
  br i1 %91, label %92, label %95

92:                                               ; preds = %83
  %93 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %93, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %204

95:                                               ; preds = %83
  br label %96

96:                                               ; preds = %95
  %97 = load i64, ptr @i, align 8, !tbaa !5
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr @i, align 8, !tbaa !5
  br label %78, !llvm.loop !12

99:                                               ; preds = %78
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %100

100:                                              ; preds = %140, %99
  %101 = load i64, ptr @i, align 8, !tbaa !5
  %102 = load i64, ptr @n, align 8, !tbaa !5
  %103 = icmp slt i64 %101, %102
  br i1 %103, label %104, label %143

104:                                              ; preds = %100
  %105 = load i64, ptr @i, align 8, !tbaa !5
  %106 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %105
  store i64 0, ptr %106, align 8, !tbaa !5
  store i64 0, ptr @j, align 8, !tbaa !5
  br label %107

107:                                              ; preds = %136, %104
  %108 = load i64, ptr @j, align 8, !tbaa !5
  %109 = load i64, ptr @n, align 8, !tbaa !5
  %110 = icmp slt i64 %108, %109
  br i1 %110, label %111, label %139

111:                                              ; preds = %107
  %112 = load i64, ptr @j, align 8, !tbaa !5
  %113 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %112
  %114 = load i64, ptr @i, align 8, !tbaa !5
  %115 = getelementptr inbounds [505 x i64], ptr %113, i64 0, i64 %114
  %116 = load i64, ptr %115, align 8, !tbaa !5
  %117 = icmp eq i64 %116, 0
  br i1 %117, label %118, label %124

118:                                              ; preds = %111
  %119 = load i64, ptr @t, align 8, !tbaa !5
  %120 = load i64, ptr @j, align 8, !tbaa !5
  %121 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %120
  %122 = load i64, ptr @i, align 8, !tbaa !5
  %123 = getelementptr inbounds [505 x i64], ptr %121, i64 0, i64 %122
  store i64 %119, ptr %123, align 8, !tbaa !5
  br label %124

124:                                              ; preds = %118, %111
  %125 = load i64, ptr @i, align 8, !tbaa !5
  %126 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %125
  %127 = load i64, ptr %126, align 8, !tbaa !5
  %128 = load i64, ptr @j, align 8, !tbaa !5
  %129 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %128
  %130 = load i64, ptr @i, align 8, !tbaa !5
  %131 = getelementptr inbounds [505 x i64], ptr %129, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !5
  %133 = add nsw i64 %127, %132
  %134 = load i64, ptr @i, align 8, !tbaa !5
  %135 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %134
  store i64 %133, ptr %135, align 8, !tbaa !5
  br label %136

136:                                              ; preds = %124
  %137 = load i64, ptr @j, align 8, !tbaa !5
  %138 = add nsw i64 %137, 1
  store i64 %138, ptr @j, align 8, !tbaa !5
  br label %107, !llvm.loop !13

139:                                              ; preds = %107
  br label %140

140:                                              ; preds = %139
  %141 = load i64, ptr @i, align 8, !tbaa !5
  %142 = add nsw i64 %141, 1
  store i64 %142, ptr @i, align 8, !tbaa !5
  br label %100, !llvm.loop !14

143:                                              ; preds = %100
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %144

144:                                              ; preds = %162, %143
  %145 = load i64, ptr @i, align 8, !tbaa !5
  %146 = load i64, ptr @n, align 8, !tbaa !5
  %147 = sub nsw i64 %146, 1
  %148 = icmp slt i64 %145, %147
  br i1 %148, label %149, label %165

149:                                              ; preds = %144
  %150 = load i64, ptr @i, align 8, !tbaa !5
  %151 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %150
  %152 = load i64, ptr %151, align 8, !tbaa !5
  %153 = load i64, ptr @i, align 8, !tbaa !5
  %154 = add nsw i64 %153, 1
  %155 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %154
  %156 = load i64, ptr %155, align 8, !tbaa !5
  %157 = icmp ne i64 %152, %156
  br i1 %157, label %158, label %161

158:                                              ; preds = %149
  %159 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %160 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %159, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %204

161:                                              ; preds = %149
  br label %162

162:                                              ; preds = %161
  %163 = load i64, ptr @i, align 8, !tbaa !5
  %164 = add nsw i64 %163, 1
  store i64 %164, ptr @i, align 8, !tbaa !5
  br label %144, !llvm.loop !15

165:                                              ; preds = %144
  store i64 0, ptr getelementptr inbounds ([505 x i64], ptr @b, i64 0, i64 500), align 16, !tbaa !5
  store i64 0, ptr getelementptr inbounds ([505 x i64], ptr @c, i64 0, i64 500), align 16, !tbaa !5
  %166 = load i64, ptr @n, align 8, !tbaa !5
  %167 = sub nsw i64 %166, 1
  store i64 %167, ptr @j, align 8, !tbaa !5
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %168

168:                                              ; preds = %189, %165
  %169 = load i64, ptr @i, align 8, !tbaa !5
  %170 = load i64, ptr @n, align 8, !tbaa !5
  %171 = icmp slt i64 %169, %170
  br i1 %171, label %172, label %192

172:                                              ; preds = %168
  %173 = load i64, ptr getelementptr inbounds ([505 x i64], ptr @b, i64 0, i64 500), align 16, !tbaa !5
  %174 = load i64, ptr @i, align 8, !tbaa !5
  %175 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %174
  %176 = load i64, ptr @i, align 8, !tbaa !5
  %177 = getelementptr inbounds [505 x i64], ptr %175, i64 0, i64 %176
  %178 = load i64, ptr %177, align 8, !tbaa !5
  %179 = add nsw i64 %173, %178
  store i64 %179, ptr getelementptr inbounds ([505 x i64], ptr @b, i64 0, i64 500), align 16, !tbaa !5
  %180 = load i64, ptr getelementptr inbounds ([505 x i64], ptr @c, i64 0, i64 500), align 16, !tbaa !5
  %181 = load i64, ptr @i, align 8, !tbaa !5
  %182 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %181
  %183 = load i64, ptr @j, align 8, !tbaa !5
  %184 = getelementptr inbounds [505 x i64], ptr %182, i64 0, i64 %183
  %185 = load i64, ptr %184, align 8, !tbaa !5
  %186 = add nsw i64 %180, %185
  store i64 %186, ptr getelementptr inbounds ([505 x i64], ptr @c, i64 0, i64 500), align 16, !tbaa !5
  %187 = load i64, ptr @j, align 8, !tbaa !5
  %188 = add nsw i64 %187, -1
  store i64 %188, ptr @j, align 8, !tbaa !5
  br label %189

189:                                              ; preds = %172
  %190 = load i64, ptr @i, align 8, !tbaa !5
  %191 = add nsw i64 %190, 1
  store i64 %191, ptr @i, align 8, !tbaa !5
  br label %168, !llvm.loop !16

192:                                              ; preds = %168
  %193 = load i64, ptr getelementptr inbounds ([505 x i64], ptr @b, i64 0, i64 500), align 16, !tbaa !5
  %194 = load i64, ptr getelementptr inbounds ([505 x i64], ptr @c, i64 0, i64 500), align 16, !tbaa !5
  %195 = icmp ne i64 %193, %194
  br i1 %195, label %196, label %199

196:                                              ; preds = %192
  %197 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %198 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %197, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %204

199:                                              ; preds = %192
  %200 = load i64, ptr @t, align 8, !tbaa !5
  %201 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %200)
  %202 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %201, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %203

203:                                              ; preds = %199, %5
  store i32 0, ptr %1, align 4
  br label %204

204:                                              ; preds = %203, %196, %158, %92
  %205 = load i32, ptr %1, align 4
  ret i32 %205
}

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #1 align 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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!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 = !{!"long long", !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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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

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

@n = external dso_local global i64, align 8
@a = external dso_local global [505 x [505 x i64]], align 16
@b = external dso_local local_unnamed_addr global [505 x i64], align 16
@i = external dso_local local_unnamed_addr global i64, align 8
@j = external dso_local local_unnamed_addr global i64, align 8
@c = external dso_local local_unnamed_addr global [505 x i64], align 16
@temp = external dso_local local_unnamed_addr global i64, align 8
@t = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %2 = load i64, ptr @n, align 8, !tbaa !5
  %3 = icmp eq i64 %2, 1
  br i1 %3, label %5, label %.preheader18

.preheader18:                                     ; preds = %0
  store i64 0, ptr @i, align 8, !tbaa !5
  %4 = icmp sgt i64 %2, 0
  br i1 %4, label %.lr.ph23.split, label %._crit_edge24

5:                                                ; preds = %0
  %6 = tail 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 %120

.lr.ph23.split:                                   ; preds = %.preheader18, %._crit_edge
  %7 = phi i64 [ %27, %._crit_edge ], [ %2, %.preheader18 ]
  %storemerge22 = phi i64 [ %29, %._crit_edge ], [ 0, %.preheader18 ]
  %8 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %storemerge22
  store i64 0, ptr %8, align 8, !tbaa !5
  store i64 0, ptr @j, align 8, !tbaa !5
  %9 = icmp sgt i64 %7, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph23.split, %23
  %10 = phi i64 [ %13, %23 ], [ %storemerge22, %.lr.ph23.split ]
  %storemerge1621 = phi i64 [ %24, %23 ], [ 0, %.lr.ph23.split ]
  %11 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %10, i64 %storemerge1621
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %13 = load i64, ptr @i, align 8, !tbaa !5
  %14 = load i64, ptr @j, align 8, !tbaa !5
  %15 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %13, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %.lr.ph
  store i64 %13, ptr @temp, align 8, !tbaa !5
  br label %23

19:                                               ; preds = %.lr.ph
  %20 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %13
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = add nsw i64 %21, %16
  store i64 %22, ptr %20, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %18, %19
  %24 = add nsw i64 %14, 1
  store i64 %24, ptr @j, align 8, !tbaa !5
  %25 = load i64, ptr @n, align 8, !tbaa !5
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %23, %.lr.ph23.split
  %27 = phi i64 [ %7, %.lr.ph23.split ], [ %25, %23 ]
  %28 = phi i64 [ %storemerge22, %.lr.ph23.split ], [ %13, %23 ]
  %29 = add nsw i64 %28, 1
  store i64 %29, ptr @i, align 8, !tbaa !5
  %30 = icmp slt i64 %29, %27
  br i1 %30, label %.lr.ph23.split, label %._crit_edge24, !llvm.loop !11

._crit_edge24:                                    ; preds = %._crit_edge, %.preheader18
  %.lcssa20 = phi i64 [ %2, %.preheader18 ], [ %27, %._crit_edge ]
  %31 = load i64, ptr @temp, align 8, !tbaa !5
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %33, label %37

33:                                               ; preds = %._crit_edge24
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @c, i64 8), align 8, !tbaa !5
  %35 = load i64, ptr @c, align 16, !tbaa !5
  %36 = sub nsw i64 %34, %35
  store i64 %34, ptr @c, align 16, !tbaa !5
  br label %42

37:                                               ; preds = %._crit_edge24
  %38 = load i64, ptr @c, align 16, !tbaa !5
  %39 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %31
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = sub nsw i64 %38, %40
  store i64 %38, ptr %39, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %37, %33
  %43 = phi i64 [ %34, %33 ], [ %38, %37 ]
  %44 = phi i64 [ %36, %33 ], [ %41, %37 ]
  store i64 %44, ptr @t, align 8
  %45 = add nsw i64 %.lcssa20, -1
  %smax = tail call i64 @llvm.smax.i64(i64 %45, i64 0)
  br label %46

46:                                               ; preds = %74, %42
  %storemerge9 = phi i64 [ 0, %42 ], [ %75, %74 ]
  %exitcond.not = icmp eq i64 %storemerge9, %smax
  br i1 %exitcond.not, label %.preheader17, label %74

.preheader17:                                     ; preds = %46
  %47 = icmp sgt i64 %.lcssa20, 0
  br i1 %47, label %.lr.ph29.us.preheader, label %.preheader.preheader

.lr.ph29.us.preheader:                            ; preds = %.preheader17
  %xtraiter = and i64 %.lcssa20, 1
  %48 = icmp eq i64 %45, 0
  %unroll_iter = and i64 %.lcssa20, 9223372036854775806
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph29.us

.lr.ph29.us:                                      ; preds = %.lr.ph29.us.preheader, %._crit_edge30.us
  %storemerge1033.us = phi i64 [ %73, %._crit_edge30.us ], [ 0, %.lr.ph29.us.preheader ]
  %49 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %storemerge1033.us
  br i1 %48, label %._crit_edge30.us.unr-lcssa, label %.lr.ph29.us.new

.lr.ph29.us.new:                                  ; preds = %.lr.ph29.us, %63
  %50 = phi i64 [ %65, %63 ], [ 0, %.lr.ph29.us ]
  %storemerge1427.us = phi i64 [ %66, %63 ], [ 0, %.lr.ph29.us ]
  %niter = phi i64 [ %niter.next.1, %63 ], [ 0, %.lr.ph29.us ]
  %51 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1427.us, i64 %storemerge1033.us
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = icmp eq i64 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %.lr.ph29.us.new
  store i64 %44, ptr %51, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %54, %.lr.ph29.us.new
  %56 = phi i64 [ %44, %54 ], [ %52, %.lr.ph29.us.new ]
  %57 = add nsw i64 %56, %50
  %58 = or disjoint i64 %storemerge1427.us, 1
  %59 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %58, i64 %storemerge1033.us
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %55
  store i64 %44, ptr %59, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %62, %55
  %64 = phi i64 [ %44, %62 ], [ %60, %55 ]
  %65 = add nsw i64 %64, %57
  %66 = add nuw nsw i64 %storemerge1427.us, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge30.us.unr-lcssa, label %.lr.ph29.us.new, !llvm.loop !13

._crit_edge30.us.unr-lcssa:                       ; preds = %63, %.lr.ph29.us
  %.lcssa80.ph = phi i64 [ poison, %.lr.ph29.us ], [ %65, %63 ]
  %.unr = phi i64 [ 0, %.lr.ph29.us ], [ %65, %63 ]
  %storemerge1427.us.unr = phi i64 [ 0, %.lr.ph29.us ], [ %66, %63 ]
  br i1 %lcmp.mod.not, label %._crit_edge30.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge30.us.unr-lcssa
  %67 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1427.us.unr, i64 %storemerge1033.us
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = icmp eq i64 %68, 0
  br i1 %69, label %70, label %._crit_edge30.us.epilog-lcssa

70:                                               ; preds = %.epil.preheader
  store i64 %44, ptr %67, align 8, !tbaa !5
  br label %._crit_edge30.us.epilog-lcssa

._crit_edge30.us.epilog-lcssa:                    ; preds = %70, %.epil.preheader
  %71 = phi i64 [ %44, %70 ], [ %68, %.epil.preheader ]
  %72 = add nsw i64 %71, %.unr
  br label %._crit_edge30.us

._crit_edge30.us:                                 ; preds = %._crit_edge30.us.unr-lcssa, %._crit_edge30.us.epilog-lcssa
  %.lcssa80 = phi i64 [ %.lcssa80.ph, %._crit_edge30.us.unr-lcssa ], [ %72, %._crit_edge30.us.epilog-lcssa ]
  store i64 %.lcssa80, ptr %49, align 8, !tbaa !5
  %73 = add nuw nsw i64 %storemerge1033.us, 1
  %exitcond59.not = icmp eq i64 %73, %.lcssa20
  br i1 %exitcond59.not, label %..preheader_crit_edge, label %.lr.ph29.us, !llvm.loop !14

74:                                               ; preds = %46
  %75 = add nuw i64 %storemerge9, 1
  %76 = getelementptr inbounds [505 x i64], ptr @c, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !5
  %.not15 = icmp eq i64 %43, %77
  br i1 %.not15, label %46, label %78, !llvm.loop !15

78:                                               ; preds = %74
  store i64 %storemerge9, ptr @i, align 8, !tbaa !5
  %79 = tail 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.1)
  br label %120

..preheader_crit_edge:                            ; preds = %._crit_edge30.us
  store i64 %.lcssa20, ptr @j, align 8, !tbaa !5
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %..preheader_crit_edge, %.preheader17
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %80
  %storemerge11 = phi i64 [ %83, %80 ], [ 0, %.preheader.preheader ]
  %exitcond60.not = icmp eq i64 %storemerge11, %smax
  br i1 %exitcond60.not, label %88, label %80

80:                                               ; preds = %.preheader
  %81 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %storemerge11
  %82 = load i64, ptr %81, align 8, !tbaa !5
  %83 = add nuw i64 %storemerge11, 1
  %84 = getelementptr inbounds [505 x i64], ptr @b, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !5
  %.not13 = icmp eq i64 %82, %85
  br i1 %.not13, label %.preheader, label %86, !llvm.loop !16

86:                                               ; preds = %80
  store i64 %storemerge11, ptr @i, align 8, !tbaa !5
  %87 = tail 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.1)
  br label %120

88:                                               ; preds = %.preheader
  store i64 0, ptr getelementptr inbounds (i8, ptr @b, i64 4000), align 16, !tbaa !5
  store i64 0, ptr getelementptr inbounds (i8, ptr @c, i64 4000), align 16, !tbaa !5
  store i64 %45, ptr @j, align 8, !tbaa !5
  br i1 %47, label %.lr.ph42.preheader, label %.thread

.lr.ph42.preheader:                               ; preds = %88
  %xtraiter86 = and i64 %.lcssa20, 1
  %89 = icmp eq i64 %45, 0
  br i1 %89, label %.unr-lcssa, label %.lr.ph42.preheader.new

.lr.ph42.preheader.new:                           ; preds = %.lr.ph42.preheader
  %unroll_iter93 = and i64 %.lcssa20, 9223372036854775806
  br label %.lr.ph42

.thread:                                          ; preds = %88
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %118

.lr.ph42:                                         ; preds = %.lr.ph42, %.lr.ph42.preheader.new
  %storemerge1240 = phi i64 [ 0, %.lr.ph42.preheader.new ], [ %108, %.lr.ph42 ]
  %90 = phi i64 [ 0, %.lr.ph42.preheader.new ], [ %103, %.lr.ph42 ]
  %91 = phi i64 [ 0, %.lr.ph42.preheader.new ], [ %106, %.lr.ph42 ]
  %92 = phi i64 [ %45, %.lr.ph42.preheader.new ], [ %107, %.lr.ph42 ]
  %niter94 = phi i64 [ 0, %.lr.ph42.preheader.new ], [ %niter94.next.1, %.lr.ph42 ]
  %93 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1240, i64 %storemerge1240
  %94 = load i64, ptr %93, align 16, !tbaa !5
  %95 = add nsw i64 %94, %90
  %96 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1240, i64 %92
  %97 = load i64, ptr %96, align 8, !tbaa !5
  %98 = add nsw i64 %97, %91
  %99 = add nsw i64 %92, -1
  %100 = or disjoint i64 %storemerge1240, 1
  %101 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %100, i64 %100
  %102 = load i64, ptr %101, align 16, !tbaa !5
  %103 = add nsw i64 %102, %95
  %104 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %100, i64 %99
  %105 = load i64, ptr %104, align 8, !tbaa !5
  %106 = add nsw i64 %105, %98
  %107 = add nsw i64 %92, -2
  %108 = add nuw nsw i64 %storemerge1240, 2
  %niter94.next.1 = add i64 %niter94, 2
  %niter94.ncmp.1 = icmp eq i64 %niter94.next.1, %unroll_iter93
  br i1 %niter94.ncmp.1, label %.unr-lcssa, label %.lr.ph42, !llvm.loop !17

.unr-lcssa:                                       ; preds = %.lr.ph42, %.lr.ph42.preheader
  %.lcssa78.ph = phi i64 [ poison, %.lr.ph42.preheader ], [ %103, %.lr.ph42 ]
  %.lcssa.ph = phi i64 [ poison, %.lr.ph42.preheader ], [ %106, %.lr.ph42 ]
  %storemerge1240.unr = phi i64 [ 0, %.lr.ph42.preheader ], [ %108, %.lr.ph42 ]
  %.unr87 = phi i64 [ 0, %.lr.ph42.preheader ], [ %103, %.lr.ph42 ]
  %.unr88 = phi i64 [ 0, %.lr.ph42.preheader ], [ %106, %.lr.ph42 ]
  %.unr89 = phi i64 [ %45, %.lr.ph42.preheader ], [ %107, %.lr.ph42 ]
  %lcmp.mod90.not = icmp eq i64 %xtraiter86, 0
  br i1 %lcmp.mod90.not, label %115, label %.lr.ph42.epil

.lr.ph42.epil:                                    ; preds = %.unr-lcssa
  %109 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1240.unr, i64 %storemerge1240.unr
  %110 = load i64, ptr %109, align 8, !tbaa !5
  %111 = add nsw i64 %110, %.unr87
  %112 = getelementptr inbounds [505 x [505 x i64]], ptr @a, i64 0, i64 %storemerge1240.unr, i64 %.unr89
  %113 = load i64, ptr %112, align 8, !tbaa !5
  %114 = add nsw i64 %113, %.unr88
  br label %115

115:                                              ; preds = %.unr-lcssa, %.lr.ph42.epil
  %.lcssa78 = phi i64 [ %.lcssa78.ph, %.unr-lcssa ], [ %111, %.lr.ph42.epil ]
  %.lcssa = phi i64 [ %.lcssa.ph, %.unr-lcssa ], [ %114, %.lr.ph42.epil ]
  store i64 %.lcssa78, ptr getelementptr inbounds (i8, ptr @b, i64 4000), align 16, !tbaa !5
  store i64 %.lcssa, ptr getelementptr inbounds (i8, ptr @c, i64 4000), align 16, !tbaa !5
  store i64 -1, ptr @j, align 8, !tbaa !5
  store i64 %.lcssa20, ptr @i, align 8, !tbaa !5
  %.not = icmp eq i64 %.lcssa78, %.lcssa
  br i1 %.not, label %118, label %116

116:                                              ; preds = %115
  %117 = tail 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.1)
  br label %120

118:                                              ; preds = %.thread, %115
  %119 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %44)
  br label %120

120:                                              ; preds = %5, %118, %116, %86, %78
  %.sink = phi ptr [ %6, %5 ], [ %119, %118 ], [ %117, %116 ], [ %87, %86 ], [ %79, %78 ]
  %121 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !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}
!12 = !{!"llvm.loop.unswitch.partial.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass