; LLVM IR from tangjz/acm-icpc :: poj (2888)

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

%struct.Matrix = type { i32, i32, [10 x [10 x i32]] }

@A = external dso_local global %struct.Matrix, align 4
@inv = external dso_local global [9973 x i32], align 16
@tot = external dso_local global i32, align 4
@prime = external dso_local global [31623 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@p = external dso_local global [11 x i32], align 16
@c = external dso_local global [11 x i32], align 16
@ans = external dso_local global i32, align 4
@vis = external dso_local global [31623 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsiii(i32 noundef, i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([9973 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %31, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 9973
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %34

17:                                               ; preds = %13
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sdiv i32 9973, %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = srem i32 9973, %20
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = mul nsw i32 %19, %24
  %26 = srem i32 %25, 9973
  %27 = sub nsw i32 9973, %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %29
  store i32 %27, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %17
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !9

34:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %85, %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 31623
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %88

39:                                               ; preds = %35
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [31623 x i8], ptr @vis, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !11, !range !13, !noundef !14
  %44 = trunc i8 %43 to i1
  br i1 %44, label %51, label %45

45:                                               ; preds = %39
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr @tot, align 4, !tbaa !5
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %49
  store i32 %46, ptr %50, align 4, !tbaa !5
  br label %51

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

52:                                               ; preds = %80, %51
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load i32, ptr @tot, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %64

56:                                               ; preds = %52
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = mul nsw i32 %57, %61
  store i32 %62, ptr %6, align 4, !tbaa !5
  %63 = icmp slt i32 %62, 31623
  br label %64

64:                                               ; preds = %56, %52
  %65 = phi i1 [ false, %52 ], [ %63, %56 ]
  br i1 %65, label %67, label %66

66:                                               ; preds = %64
  store i32 8, ptr %4, align 4
  br label %83

67:                                               ; preds = %64
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [31623 x i8], ptr @vis, i64 0, i64 %69
  store i8 1, ptr %70, align 1, !tbaa !11
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = srem i32 %71, %75
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %79

78:                                               ; preds = %67
  store i32 8, ptr %4, align 4
  br label %83

79:                                               ; preds = %67
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !5
  br label %52, !llvm.loop !15

83:                                               ; preds = %78, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !16

88:                                               ; preds = %38
  %89 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %90

90:                                               ; preds = %230, %88
  %91 = load i32, ptr @t, align 4, !tbaa !5
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr @t, align 4, !tbaa !5
  %93 = icmp ne i32 %91, 0
  br i1 %93, label %94, label %241

94:                                               ; preds = %90
  %95 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m, ptr noundef @q)
  %96 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %96, ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 1), align 4, !tbaa !17
  store i32 %96, ptr @A, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %119, %94
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = load i32, ptr @m, align 4, !tbaa !5
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %122

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

103:                                              ; preds = %115, %102
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = load i32, ptr @m, align 4, !tbaa !5
  %106 = icmp slt i32 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %118

108:                                              ; preds = %103
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 %110
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [10 x i32], ptr %111, i64 0, i64 %113
  store i32 1, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %108
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %8, align 4, !tbaa !5
  br label %103, !llvm.loop !20

118:                                              ; preds = %107
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %7, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %7, align 4, !tbaa !5
  br label %97, !llvm.loop !21

122:                                              ; preds = %101
  br label %123

123:                                              ; preds = %127, %122
  %124 = load i32, ptr @q, align 4, !tbaa !5
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr @q, align 4, !tbaa !5
  %126 = icmp ne i32 %124, 0
  br i1 %126, label %127, label %145

127:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %128 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %9, ptr noundef %10)
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = add nsw i32 %129, -1
  store i32 %130, ptr %9, align 4, !tbaa !5
  %131 = load i32, ptr %10, align 4, !tbaa !5
  %132 = add nsw i32 %131, -1
  store i32 %132, ptr %10, align 4, !tbaa !5
  %133 = load i32, ptr %10, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 %134
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [10 x i32], ptr %135, i64 0, i64 %137
  store i32 0, ptr %138, align 4, !tbaa !5
  %139 = load i32, ptr %9, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (%struct.Matrix, ptr @A, i32 0, i32 2), i64 0, i64 %140
  %142 = load i32, ptr %10, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [10 x i32], ptr %141, i64 0, i64 %143
  store i32 0, ptr %144, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %123, !llvm.loop !22

145:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %146 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %146, ptr %11, align 4, !tbaa !5
  store i32 0, ptr @cnt, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %215, %145
  %148 = load i32, ptr %12, align 4, !tbaa !5
  %149 = load i32, ptr @tot, align 4, !tbaa !5
  %150 = icmp slt i32 %148, %149
  br i1 %150, label %151, label %163

151:                                              ; preds = %147
  %152 = load i32, ptr %12, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = load i32, ptr %12, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  %160 = mul nsw i32 %155, %159
  %161 = load i32, ptr %11, align 4, !tbaa !5
  %162 = icmp sle i32 %160, %161
  br label %163

163:                                              ; preds = %151, %147
  %164 = phi i1 [ false, %147 ], [ %162, %151 ]
  br i1 %164, label %166, label %165

165:                                              ; preds = %163
  store i32 21, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %218

166:                                              ; preds = %163
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = load i32, ptr %12, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = srem i32 %167, %171
  %173 = icmp eq i32 %172, 0
  br i1 %173, label %174, label %214

174:                                              ; preds = %166
  %175 = load i32, ptr @cnt, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %176
  store i32 1, ptr %177, align 4, !tbaa !5
  %178 = load i32, ptr %12, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr %11, align 4, !tbaa !5
  %183 = sdiv i32 %182, %181
  store i32 %183, ptr %11, align 4, !tbaa !5
  br label %184

184:                                              ; preds = %193, %174
  %185 = load i32, ptr %11, align 4, !tbaa !5
  %186 = load i32, ptr %12, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  %190 = srem i32 %185, %189
  %191 = icmp eq i32 %190, 0
  br i1 %191, label %192, label %205

192:                                              ; preds = %184
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr @cnt, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %196, align 4, !tbaa !5
  %199 = load i32, ptr %12, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %200
  %202 = load i32, ptr %201, align 4, !tbaa !5
  %203 = load i32, ptr %11, align 4, !tbaa !5
  %204 = sdiv i32 %203, %202
  store i32 %204, ptr %11, align 4, !tbaa !5
  br label %184, !llvm.loop !23

205:                                              ; preds = %184
  %206 = load i32, ptr %12, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %207
  %209 = load i32, ptr %208, align 4, !tbaa !5
  %210 = load i32, ptr @cnt, align 4, !tbaa !5
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr @cnt, align 4, !tbaa !5
  %212 = sext i32 %210 to i64
  %213 = getelementptr inbounds [11 x i32], ptr @p, i64 0, i64 %212
  store i32 %209, ptr %213, align 4, !tbaa !5
  br label %214

214:                                              ; preds = %205, %166
  br label %215

215:                                              ; preds = %214
  %216 = load i32, ptr %12, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %12, align 4, !tbaa !5
  br label %147, !llvm.loop !24

218:                                              ; preds = %165
  %219 = load i32, ptr %11, align 4, !tbaa !5
  %220 = icmp sgt i32 %219, 1
  br i1 %220, label %221, label %230

221:                                              ; preds = %218
  %222 = load i32, ptr @cnt, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %223
  store i32 1, ptr %224, align 4, !tbaa !5
  %225 = load i32, ptr %11, align 4, !tbaa !5
  %226 = load i32, ptr @cnt, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  store i32 %227, ptr @cnt, align 4, !tbaa !5
  %228 = sext i32 %226 to i64
  %229 = getelementptr inbounds [11 x i32], ptr @p, i64 0, i64 %228
  store i32 %225, ptr %229, align 4, !tbaa !5
  br label %230

230:                                              ; preds = %221, %218
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef 0, i32 noundef 1, i32 noundef 1)
  %231 = load i32, ptr @ans, align 4, !tbaa !5
  %232 = load i32, ptr @n, align 4, !tbaa !5
  %233 = srem i32 %232, 9973
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %234
  %236 = load i32, ptr %235, align 4, !tbaa !5
  %237 = mul nsw i32 %231, %236
  %238 = srem i32 %237, 9973
  store i32 %238, ptr @ans, align 4, !tbaa !5
  %239 = load i32, ptr @ans, align 4, !tbaa !5
  %240 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %239)
  br label %90, !llvm.loop !25

241:                                              ; preds = %90
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @printf(ptr noundef, ...) #3

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 4}
!18 = !{!"_ZTS6Matrix", !6, i64 0, !6, i64 4, !7, i64 8}
!19 = !{!18, !6, i64 0}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !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"

%struct.Matrix = type { i32, i32, [10 x [10 x i32]] }

@A = external dso_local local_unnamed_addr global %struct.Matrix, align 4
@inv = external dso_local local_unnamed_addr global [9973 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [31623 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local local_unnamed_addr global [11 x i32], align 16
@c = external dso_local local_unnamed_addr global [11 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [31623 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  br label %3

.preheader52:                                     ; preds = %3
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %17

3:                                                ; preds = %0, %3
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %3 ]
  %.rhs.trunc = trunc i64 %indvars.iv to i16
  %4 = udiv i16 9973, %.rhs.trunc
  %.zext = zext nneg i16 %4 to i32
  %5 = urem i16 9973, %.rhs.trunc
  %6 = zext nneg i16 %5 to i64
  %7 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = mul nsw i32 %8, %.zext
  %10 = srem i32 %9, 9973
  %11 = sub nsw i32 9973, %10
  %12 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %indvars.iv
  store i32 %11, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 9973
  br i1 %exitcond.not, label %.preheader52, label %3, !llvm.loop !9

13:                                               ; preds = %.critedge
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %15 = load i32, ptr @t, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr @t, align 4, !tbaa !5
  %.not69 = icmp eq i32 %15, 0
  br i1 %.not69, label %._crit_edge72, label %.lr.ph71

17:                                               ; preds = %.preheader52, %.critedge
  %indvars.iv77 = phi i64 [ 2, %.preheader52 ], [ %indvars.iv.next78, %.critedge ]
  %18 = phi i32 [ %tot.promoted, %.preheader52 ], [ %28, %.critedge ]
  %19 = getelementptr inbounds [31623 x i8], ptr @vis, i64 0, i64 %indvars.iv77
  %20 = load i8, ptr %19, align 1, !tbaa !11, !range !13, !noundef !14
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %27, label %22

22:                                               ; preds = %17
  %23 = add nsw i32 %18, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %18 to i64
  %25 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %24
  %26 = trunc nuw nsw i64 %indvars.iv77 to i32
  store i32 %26, ptr %25, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %22, %17
  %28 = phi i32 [ %23, %22 ], [ %18, %17 ]
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %27
  %30 = zext nneg i32 %28 to i64
  %31 = trunc nuw nsw i64 %indvars.iv77 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %36
  %indvars.iv74 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next75, %36 ]
  %32 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %indvars.iv74
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = mul nsw i32 %33, %31
  %35 = icmp slt i32 %34, 31623
  br i1 %35, label %36, label %.critedge

36:                                               ; preds = %.lr.ph
  %37 = sext i32 %34 to i64
  %38 = getelementptr inbounds [31623 x i8], ptr @vis, i64 0, i64 %37
  store i8 1, ptr %38, align 1, !tbaa !11
  %39 = srem i32 %31, %33
  %40 = icmp ne i32 %39, 0
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %41 = icmp ult i64 %indvars.iv.next75, %30
  %or.cond = select i1 %40, i1 %41, i1 false
  br i1 %or.cond, label %.lr.ph, label %.critedge, !llvm.loop !15

.critedge:                                        ; preds = %.lr.ph, %36, %27
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next78, 31623
  br i1 %exitcond80.not, label %13, label %17, !llvm.loop !16

.lr.ph71:                                         ; preds = %13, %91
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %43 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %43, ptr getelementptr inbounds (i8, ptr @A, i64 4), align 4, !tbaa !17
  store i32 %43, ptr @A, align 4, !tbaa !19
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.preheader.us.preheader, label %.preheader51

.preheader.us.preheader:                          ; preds = %.lr.ph71
  %wide.trip.count88 = zext nneg i32 %43 to i64
  %min.iters.check = icmp ult i32 %43, 8
  %n.vec = and i64 %wide.trip.count88, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count88
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv85 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next86, %._crit_edge.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader.us ]
  %45 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %indvars.iv85, i64 %index
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %45, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %46, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %47 = icmp eq i64 %index.next, %n.vec
  br i1 %47, label %middle.block, label %vector.body, !llvm.loop !20

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader.us
  %indvars.iv81.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %scalar.ph ], [ %indvars.iv81.ph, %scalar.ph.preheader ]
  %48 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %indvars.iv85, i64 %indvars.iv81
  store i32 1, ptr %48, align 4, !tbaa !5
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond84.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count88
  br i1 %exitcond84.not, label %._crit_edge.us, label %scalar.ph, !llvm.loop !23

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next86, %wide.trip.count88
  br i1 %exitcond89.not, label %.preheader51, label %.preheader.us, !llvm.loop !24

.preheader51:                                     ; preds = %._crit_edge.us, %.lr.ph71
  %49 = load i32, ptr @q, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr @q, align 4, !tbaa !5
  %.not4761 = icmp eq i32 %49, 0
  br i1 %.not4761, label %._crit_edge, label %.lr.ph62

.lr.ph62:                                         ; preds = %.preheader51, %.lr.ph62
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = add nsw i32 %54, -1
  %56 = sext i32 %55 to i64
  %57 = sext i32 %53 to i64
  %58 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %56, i64 %57
  store i32 0, ptr %58, align 4, !tbaa !5
  %59 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds (i8, ptr @A, i64 8), i64 0, i64 %57, i64 %56
  store i32 0, ptr %59, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %60 = load i32, ptr @q, align 4, !tbaa !5
  %61 = add nsw i32 %60, -1
  store i32 %61, ptr @q, align 4, !tbaa !5
  %.not47 = icmp eq i32 %60, 0
  br i1 %.not47, label %._crit_edge, label %.lr.ph62, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph62, %.preheader51
  %62 = load i32, ptr @n, align 4, !tbaa !5
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %63 = load i32, ptr @tot, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %.lr.ph66.preheader, label %.critedge2

.lr.ph66.preheader:                               ; preds = %._crit_edge
  %wide.trip.count93 = zext nneg i32 %63 to i64
  br label %.lr.ph66

.lr.ph66:                                         ; preds = %.lr.ph66.preheader, %84
  %indvars.iv90 = phi i64 [ 0, %.lr.ph66.preheader ], [ %indvars.iv.next91, %84 ]
  %.04063 = phi i32 [ %62, %.lr.ph66.preheader ], [ %.2, %84 ]
  %65 = phi i32 [ 0, %.lr.ph66.preheader ], [ %85, %84 ]
  %66 = getelementptr inbounds [31623 x i32], ptr @prime, i64 0, i64 %indvars.iv90
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = mul nsw i32 %67, %67
  %.not48 = icmp sgt i32 %68, %.04063
  br i1 %.not48, label %.critedge2, label %71

.critedge2:                                       ; preds = %.lr.ph66, %84, %._crit_edge
  %69 = phi i32 [ 0, %._crit_edge ], [ %85, %84 ], [ %65, %.lr.ph66 ]
  %.040.lcssa = phi i32 [ %62, %._crit_edge ], [ %.2, %84 ], [ %.04063, %.lr.ph66 ]
  %70 = icmp sgt i32 %.040.lcssa, 1
  br i1 %70, label %86, label %91

71:                                               ; preds = %.lr.ph66
  %72 = srem i32 %.04063, %67
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %84

74:                                               ; preds = %71
  %75 = sext i32 %65 to i64
  br label %76

76:                                               ; preds = %76, %74
  %storemerge = phi i32 [ 1, %74 ], [ %79, %76 ]
  %.040.pn = phi i32 [ %.04063, %74 ], [ %.1, %76 ]
  %.1 = sdiv i32 %.040.pn, %67
  %77 = srem i32 %.1, %67
  %78 = icmp eq i32 %77, 0
  %79 = add nuw nsw i32 %storemerge, 1
  br i1 %78, label %76, label %80, !llvm.loop !26

80:                                               ; preds = %76
  %81 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %75
  store i32 %storemerge, ptr %81, align 4, !tbaa !5
  %82 = add nsw i32 %65, 1
  store i32 %82, ptr @cnt, align 4, !tbaa !5
  %83 = getelementptr inbounds [11 x i32], ptr @p, i64 0, i64 %75
  store i32 %67, ptr %83, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %71, %80
  %85 = phi i32 [ %82, %80 ], [ %65, %71 ]
  %.2 = phi i32 [ %.1, %80 ], [ %.04063, %71 ]
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %exitcond94.not = icmp eq i64 %indvars.iv.next91, %wide.trip.count93
  br i1 %exitcond94.not, label %.critedge2, label %.lr.ph66, !llvm.loop !27

86:                                               ; preds = %.critedge2
  %87 = sext i32 %69 to i64
  %88 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %87
  store i32 1, ptr %88, align 4, !tbaa !5
  %89 = add nsw i32 %69, 1
  store i32 %89, ptr @cnt, align 4, !tbaa !5
  %90 = getelementptr inbounds [11 x i32], ptr @p, i64 0, i64 %87
  store i32 %.040.lcssa, ptr %90, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %86, %.critedge2
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef 0, i32 noundef 1, i32 noundef 1)
  %92 = load i32, ptr @ans, align 4, !tbaa !5
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = srem i32 %93, 9973
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [9973 x i32], ptr @inv, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = mul nsw i32 %97, %92
  %99 = srem i32 %98, 9973
  store i32 %99, ptr @ans, align 4, !tbaa !5
  %100 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %99)
  %101 = load i32, ptr @t, align 4, !tbaa !5
  %102 = add nsw i32 %101, -1
  store i32 %102, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %101, 0
  br i1 %.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !28

._crit_edge72:                                    ; preds = %91, %13
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 4}
!18 = !{!"_ZTS6Matrix", !6, i64 0, !6, i64 4, !7, i64 8}
!19 = !{!18, !6, i64 0}
!20 = distinct !{!20, !10, !21, !22}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !10, !22, !21}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10}
!28 = distinct !{!28, !10}


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