; LLVM IR from kazunetakahashi/atcoder :: 2018/0610_ABC099 (D)

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

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

@N = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@D = external dso_local global [40 x [40 x i64]], align 16
@c = external dso_local global [510 x [510 x i64]], align 16
@total = external dso_local global [3 x [40 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

18:                                               ; preds = %41, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @C, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %44

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

24:                                               ; preds = %37, %23
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = load i32, ptr @C, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %40

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [40 x [40 x i64]], ptr @D, i64 0, i64 %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [40 x i64], ptr %32, i64 0, i64 %34
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %37

37:                                               ; preds = %29
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !5
  br label %24, !llvm.loop !9

40:                                               ; preds = %28
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

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

45:                                               ; preds = %76, %44
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = load i32, ptr @N, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %79

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

51:                                               ; preds = %72, %50
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = load i32, ptr @N, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %75

56:                                               ; preds = %51
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [510 x [510 x i64]], ptr @c, i64 0, i64 %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [510 x i64], ptr %59, i64 0, i64 %61
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %62)
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [510 x [510 x i64]], ptr @c, i64 0, i64 %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [510 x i64], ptr %66, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !12
  %71 = add nsw i64 %70, -1
  store i64 %71, ptr %69, align 8, !tbaa !12
  br label %72

72:                                               ; preds = %56
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !5
  br label %51, !llvm.loop !14

75:                                               ; preds = %55
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %5, align 4, !tbaa !5
  br label %45, !llvm.loop !15

79:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @total, ptr noundef getelementptr inbounds (i64, ptr @total, i64 120), ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %129, %79
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = load i32, ptr @C, align 4, !tbaa !5
  %83 = icmp slt i32 %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %132

85:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %125, %85
  %87 = load i32, ptr %9, align 4, !tbaa !5
  %88 = load i32, ptr @N, align 4, !tbaa !5
  %89 = icmp slt i32 %87, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %86
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %128

91:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %121, %91
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = load i32, ptr @N, align 4, !tbaa !5
  %95 = icmp slt i32 %93, %94
  br i1 %95, label %97, label %96

96:                                               ; preds = %92
  store i32 20, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %124

97:                                               ; preds = %92
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [510 x [510 x i64]], ptr @c, i64 0, i64 %99
  %101 = load i32, ptr %10, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [510 x i64], ptr %100, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !12
  %105 = getelementptr inbounds [40 x [40 x i64]], ptr @D, i64 0, i64 %104
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [40 x i64], ptr %105, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !12
  %110 = load i32, ptr %9, align 4, !tbaa !5
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = add nsw i32 %110, %111
  %113 = srem i32 %112, 3
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [3 x [40 x i64]], ptr @total, i64 0, i64 %114
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [40 x i64], ptr %115, i64 0, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !12
  %120 = add nsw i64 %119, %109
  store i64 %120, ptr %118, align 8, !tbaa !12
  br label %121

121:                                              ; preds = %97
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %10, align 4, !tbaa !5
  br label %92, !llvm.loop !16

124:                                              ; preds = %96
  br label %125

125:                                              ; preds = %124
  %126 = load i32, ptr %9, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %9, align 4, !tbaa !5
  br label %86, !llvm.loop !17

128:                                              ; preds = %90
  br label %129

129:                                              ; preds = %128
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %8, align 4, !tbaa !5
  br label %80, !llvm.loop !18

132:                                              ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 100000009907, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %189, %132
  %134 = load i32, ptr %12, align 4, !tbaa !5
  %135 = load i32, ptr @C, align 4, !tbaa !5
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 23, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %192

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

139:                                              ; preds = %185, %138
  %140 = load i32, ptr %13, align 4, !tbaa !5
  %141 = load i32, ptr @C, align 4, !tbaa !5
  %142 = icmp slt i32 %140, %141
  br i1 %142, label %144, label %143

143:                                              ; preds = %139
  store i32 26, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %188

144:                                              ; preds = %139
  %145 = load i32, ptr %12, align 4, !tbaa !5
  %146 = load i32, ptr %13, align 4, !tbaa !5
  %147 = icmp eq i32 %145, %146
  br i1 %147, label %148, label %149

148:                                              ; preds = %144
  br label %185

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

150:                                              ; preds = %181, %149
  %151 = load i32, ptr %14, align 4, !tbaa !5
  %152 = load i32, ptr @C, align 4, !tbaa !5
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %150
  store i32 29, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %184

155:                                              ; preds = %150
  %156 = load i32, ptr %12, align 4, !tbaa !5
  %157 = load i32, ptr %14, align 4, !tbaa !5
  %158 = icmp eq i32 %156, %157
  br i1 %158, label %163, label %159

159:                                              ; preds = %155
  %160 = load i32, ptr %13, align 4, !tbaa !5
  %161 = load i32, ptr %14, align 4, !tbaa !5
  %162 = icmp eq i32 %160, %161
  br i1 %162, label %163, label %164

163:                                              ; preds = %159, %155
  br label %181

164:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !12
  %165 = load i32, ptr %12, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [40 x i64], ptr @total, i64 0, i64 %166
  %168 = load i64, ptr %167, align 8, !tbaa !12
  %169 = load i32, ptr %13, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [40 x i64], ptr getelementptr inbounds ([3 x [40 x i64]], ptr @total, i64 0, i64 1), i64 0, i64 %170
  %172 = load i64, ptr %171, align 8, !tbaa !12
  %173 = add nsw i64 %168, %172
  %174 = load i32, ptr %14, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [40 x i64], ptr getelementptr inbounds ([3 x [40 x i64]], ptr @total, i64 0, i64 2), i64 0, i64 %175
  %177 = load i64, ptr %176, align 8, !tbaa !12
  %178 = add nsw i64 %173, %177
  store i64 %178, ptr %15, align 8, !tbaa !12
  %179 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %15)
  %180 = load i64, ptr %179, align 8, !tbaa !12
  store i64 %180, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %181

181:                                              ; preds = %164, %163
  %182 = load i32, ptr %14, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %14, align 4, !tbaa !5
  br label %150, !llvm.loop !19

184:                                              ; preds = %154
  br label %185

185:                                              ; preds = %184, %148
  %186 = load i32, ptr %13, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %13, align 4, !tbaa !5
  br label %139, !llvm.loop !20

188:                                              ; preds = %143
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %12, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %12, align 4, !tbaa !5
  br label %133, !llvm.loop !21

192:                                              ; preds = %137
  %193 = load i64, ptr %11, align 8, !tbaa !12
  %194 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %193)
  %195 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %194, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %196 = load i32, ptr %1, align 4
  ret i32 %196
}

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

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

; Function Attrs: 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)) #3 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 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)) #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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

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

@N = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@D = external dso_local global [40 x [40 x i64]], align 16
@c = external dso_local global [510 x [510 x i64]], align 16
@total = external dso_local global [3 x [40 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) @C)
  %6 = load i32, ptr @C, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader56, label %.preheader55

.preheader56:                                     ; preds = %0, %._crit_edge
  %8 = phi i32 [ %12, %._crit_edge ], [ %6, %0 ]
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %._crit_edge ], [ 0, %0 ]
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %.preheader56.._crit_edge_crit_edge

.preheader56.._crit_edge_crit_edge:               ; preds = %.preheader56
  %.pre117 = sext i32 %8 to i64
  br label %._crit_edge

.preheader55:                                     ; preds = %._crit_edge, %0
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader54, label %._crit_edge63

._crit_edge:                                      ; preds = %.lr.ph, %.preheader56.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre117, %.preheader56.._crit_edge_crit_edge ], [ %17, %.lr.ph ]
  %12 = phi i32 [ %8, %.preheader56.._crit_edge_crit_edge ], [ %16, %.lr.ph ]
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %13 = icmp slt i64 %indvars.iv.next87, %.pre-phi
  br i1 %13, label %.preheader56, label %.preheader55, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader56, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader56 ]
  %14 = getelementptr inbounds [40 x [40 x i64]], ptr @D, i64 0, i64 %indvars.iv86, i64 %indvars.iv
  %15 = 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) %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @C, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.preheader54:                                     ; preds = %.preheader55, %._crit_edge61
  %19 = phi i32 [ %37, %._crit_edge61 ], [ %10, %.preheader55 ]
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %._crit_edge61 ], [ 0, %.preheader55 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph60, label %.preheader54.._crit_edge61_crit_edge

.preheader54.._crit_edge61_crit_edge:             ; preds = %.preheader54
  %.pre118 = sext i32 %19 to i64
  br label %._crit_edge61

._crit_edge63:                                    ; preds = %._crit_edge61, %.preheader55
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @total, ptr noundef nonnull getelementptr inbounds (i8, ptr @total, i64 960), ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %21 = load i32, ptr @C, align 4
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.preheader53.lr.ph, label %._crit_edge70.thread120

._crit_edge70.thread120:                          ; preds = %._crit_edge63
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 100000009907, ptr %2, align 8, !tbaa !13
  br label %._crit_edge78

.preheader53.lr.ph:                               ; preds = %._crit_edge63
  %23 = load i32, ptr @N, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.preheader53.us.preheader, label %._crit_edge70.thread

._crit_edge70.thread:                             ; preds = %.preheader53.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 100000009907, ptr %2, align 8, !tbaa !13
  br label %.preheader51.preheader

.preheader53.us.preheader:                        ; preds = %.preheader53.lr.ph
  %wide.trip.count106 = zext nneg i32 %21 to i64
  %wide.trip.count101 = zext nneg i32 %23 to i64
  br label %.preheader53.us

.preheader53.us:                                  ; preds = %.preheader53.us.preheader, %._crit_edge68.split.us.us
  %indvars.iv103 = phi i64 [ 0, %.preheader53.us.preheader ], [ %indvars.iv.next104, %._crit_edge68.split.us.us ]
  br label %.preheader52.us.us

.preheader52.us.us:                               ; preds = %._crit_edge66.us.us, %.preheader53.us
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %._crit_edge66.us.us ], [ 0, %.preheader53.us ]
  br label %25

25:                                               ; preds = %25, %.preheader52.us.us
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %25 ], [ 0, %.preheader52.us.us ]
  %26 = getelementptr inbounds [510 x [510 x i64]], ptr @c, i64 0, i64 %indvars.iv98, i64 %indvars.iv95
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds [40 x [40 x i64]], ptr @D, i64 0, i64 %27, i64 %indvars.iv103
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = add nuw nsw i64 %indvars.iv95, %indvars.iv98
  %31 = trunc nuw nsw i64 %30 to i32
  %32 = urem i32 %31, 3
  %33 = zext nneg i32 %32 to i64
  %34 = getelementptr inbounds [3 x [40 x i64]], ptr @total, i64 0, i64 %33, i64 %indvars.iv103
  %35 = load i64, ptr %34, align 8, !tbaa !13
  %36 = add nsw i64 %35, %29
  store i64 %36, ptr %34, align 8, !tbaa !13
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next96, %wide.trip.count101
  br i1 %exitcond.not, label %._crit_edge66.us.us, label %25, !llvm.loop !15

._crit_edge66.us.us:                              ; preds = %25
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %exitcond102.not = icmp eq i64 %indvars.iv.next99, %wide.trip.count101
  br i1 %exitcond102.not, label %._crit_edge68.split.us.us, label %.preheader52.us.us, !llvm.loop !16

._crit_edge68.split.us.us:                        ; preds = %._crit_edge66.us.us
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %exitcond107.not = icmp eq i64 %indvars.iv.next104, %wide.trip.count106
  br i1 %exitcond107.not, label %._crit_edge70, label %.preheader53.us, !llvm.loop !17

._crit_edge61:                                    ; preds = %.lr.ph60, %.preheader54.._crit_edge61_crit_edge
  %.pre-phi119 = phi i64 [ %.pre118, %.preheader54.._crit_edge61_crit_edge ], [ %44, %.lr.ph60 ]
  %37 = phi i32 [ %19, %.preheader54.._crit_edge61_crit_edge ], [ %43, %.lr.ph60 ]
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %38 = icmp slt i64 %indvars.iv.next93, %.pre-phi119
  br i1 %38, label %.preheader54, label %._crit_edge63, !llvm.loop !18

.lr.ph60:                                         ; preds = %.preheader54, %.lr.ph60
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %.lr.ph60 ], [ 0, %.preheader54 ]
  %39 = getelementptr inbounds [510 x [510 x i64]], ptr @c, i64 0, i64 %indvars.iv92, i64 %indvars.iv89
  %40 = 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) %39)
  %41 = load i64, ptr %39, align 8, !tbaa !13
  %42 = add nsw i64 %41, -1
  store i64 %42, ptr %39, align 8, !tbaa !13
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %43 = load i32, ptr @N, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next90, %44
  br i1 %45, label %.lr.ph60, label %._crit_edge61, !llvm.loop !19

._crit_edge70:                                    ; preds = %._crit_edge68.split.us.us
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 100000009907, ptr %2, align 8, !tbaa !13
  br i1 %22, label %.preheader51.preheader, label %._crit_edge78

.preheader51.preheader:                           ; preds = %._crit_edge70, %._crit_edge70.thread
  br label %.preheader51

.preheader51:                                     ; preds = %.preheader51.preheader, %._crit_edge76
  %46 = phi i64 [ %53, %._crit_edge76 ], [ 100000009907, %.preheader51.preheader ]
  %47 = phi i32 [ %54, %._crit_edge76 ], [ %21, %.preheader51.preheader ]
  %indvars.iv114 = phi i64 [ %indvars.iv.next115, %._crit_edge76 ], [ 0, %.preheader51.preheader ]
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph75, label %._crit_edge76

.lr.ph75:                                         ; preds = %.preheader51
  %49 = getelementptr inbounds [40 x i64], ptr @total, i64 0, i64 %indvars.iv114
  br label %57

._crit_edge78:                                    ; preds = %._crit_edge76, %._crit_edge70.thread120, %._crit_edge70
  %50 = phi i64 [ 100000009907, %._crit_edge70 ], [ 100000009907, %._crit_edge70.thread120 ], [ %53, %._crit_edge76 ]
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %50)
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %51, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret i32 0

._crit_edge76:                                    ; preds = %.loopexit, %.preheader51
  %53 = phi i64 [ %46, %.preheader51 ], [ %87, %.loopexit ]
  %54 = phi i32 [ %47, %.preheader51 ], [ %88, %.loopexit ]
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %55 = sext i32 %54 to i64
  %56 = icmp slt i64 %indvars.iv.next115, %55
  br i1 %56, label %.preheader51, label %._crit_edge78, !llvm.loop !20

57:                                               ; preds = %.lr.ph75, %.loopexit
  %58 = phi i64 [ %46, %.lr.ph75 ], [ %87, %.loopexit ]
  %59 = phi i32 [ %47, %.lr.ph75 ], [ %88, %.loopexit ]
  %60 = phi i32 [ %47, %.lr.ph75 ], [ %89, %.loopexit ]
  %indvars.iv111 = phi i64 [ 0, %.lr.ph75 ], [ %indvars.iv.next112, %.loopexit ]
  %61 = icmp ne i64 %indvars.iv114, %indvars.iv111
  %62 = icmp sgt i32 %60, 0
  %or.cond80 = and i1 %61, %62
  br i1 %or.cond80, label %.lr.ph72, label %.loopexit

.lr.ph72:                                         ; preds = %57
  %63 = getelementptr inbounds [40 x i64], ptr getelementptr inbounds (i8, ptr @total, i64 320), i64 0, i64 %indvars.iv111
  br label %64

64:                                               ; preds = %.lr.ph72, %80
  %65 = phi i64 [ %58, %.lr.ph72 ], [ %81, %80 ]
  %66 = phi i32 [ %59, %.lr.ph72 ], [ %82, %80 ]
  %67 = phi i32 [ %60, %.lr.ph72 ], [ %83, %80 ]
  %68 = phi i32 [ %60, %.lr.ph72 ], [ %84, %80 ]
  %indvars.iv108 = phi i64 [ 0, %.lr.ph72 ], [ %indvars.iv.next109, %80 ]
  %69 = icmp eq i64 %indvars.iv114, %indvars.iv108
  %70 = icmp eq i64 %indvars.iv111, %indvars.iv108
  %or.cond = or i1 %69, %70
  br i1 %or.cond, label %80, label %71

71:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %72 = load i64, ptr %49, align 8, !tbaa !13
  %73 = load i64, ptr %63, align 8, !tbaa !13
  %74 = add nsw i64 %73, %72
  %75 = getelementptr inbounds [40 x i64], ptr getelementptr inbounds (i8, ptr @total, i64 640), i64 0, i64 %indvars.iv108
  %76 = load i64, ptr %75, align 8, !tbaa !13
  %77 = add nsw i64 %74, %76
  store i64 %77, ptr %3, align 8, !tbaa !13
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %79 = load i64, ptr %78, align 8, !tbaa !13
  store i64 %79, ptr %2, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %.pre = load i32, ptr @C, align 4
  br label %80

80:                                               ; preds = %64, %71
  %81 = phi i64 [ %65, %64 ], [ %79, %71 ]
  %82 = phi i32 [ %66, %64 ], [ %.pre, %71 ]
  %83 = phi i32 [ %67, %64 ], [ %.pre, %71 ]
  %84 = phi i32 [ %68, %64 ], [ %.pre, %71 ]
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %85 = sext i32 %84 to i64
  %86 = icmp slt i64 %indvars.iv.next109, %85
  br i1 %86, label %64, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %80, %57
  %87 = phi i64 [ %58, %57 ], [ %81, %80 ]
  %88 = phi i32 [ %59, %57 ], [ %82, %80 ]
  %89 = phi i32 [ %60, %57 ], [ %83, %80 ]
  %indvars.iv.next112 = add nuw nsw i64 %indvars.iv111, 1
  %90 = sext i32 %89 to i64
  %91 = icmp slt i64 %indvars.iv.next112, %90
  br i1 %91, label %57, label %._crit_edge76, !llvm.loop !22
}

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

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

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

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

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

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

; 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 #3 align 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 #3 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)) #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10, !11}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


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