; LLVM IR from tangjz/acm-icpc :: projecteuler (612)

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

@len = external dso_local global i32, align 4
@msk = external dso_local global [21 x i32], align 16
@f = external dso_local global [1025 x i32], align 16
@g = external dso_local global [1025 x i32], align 16
@ans = external dso_local global i32, align 4
@num = external dso_local global [21 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7mod_decRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %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
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  br label %16

16:                                               ; preds = %226, %0
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %235

19:                                               ; preds = %16
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @num, ptr noundef @.str, i64 noundef %20) #6
  store i32 %21, ptr @len, align 4, !tbaa !9
  %22 = load i32, ptr @len, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %24
  store i32 0, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %26 = load i32, ptr @len, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %52, %19
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = load i32, ptr @len, align 4, !tbaa !9
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = sub nsw i32 %37, %38
  %40 = sub nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [21 x i8], ptr @num, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = sext i8 %43 to i32
  %45 = sub nsw i32 %44, 48
  %46 = shl i32 1, %45
  %47 = or i32 %36, %46
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = sub nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %50
  store i32 %47, ptr %51, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %32
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = add nsw i32 %53, -1
  store i32 %54, ptr %3, align 4, !tbaa !9
  br label %28, !llvm.loop !12

55:                                               ; preds = %31
  call void @llvm.memset.p0.i64(ptr align 16 @f, i8 0, i64 4100, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @g, i8 0, i64 4100, i1 false)
  store i32 1, ptr @f, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %175, %55
  %57 = load i32, ptr %4, align 4, !tbaa !9
  %58 = load i32, ptr @len, align 4, !tbaa !9
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %178

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

62:                                               ; preds = %82, %61
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = icmp slt i32 %63, 1024
  br i1 %64, label %66, label %65

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

66:                                               ; preds = %62
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %68
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %69, i32 noundef %73)
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = or i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %76
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !9
  call void @_Z7mod_decRii(ptr noundef nonnull align 4 dereferenceable(4) %77, i32 noundef %81)
  br label %82

82:                                               ; preds = %66
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = add nsw i32 %83, 2
  store i32 %84, ptr %6, align 4, !tbaa !9
  br label %62, !llvm.loop !14

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

86:                                               ; preds = %125, %85
  %87 = load i32, ptr %7, align 4, !tbaa !9
  %88 = add nsw i32 %87, 48
  %89 = load i32, ptr @len, align 4, !tbaa !9
  %90 = load i32, ptr %4, align 4, !tbaa !9
  %91 = sub nsw i32 %89, %90
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [21 x i8], ptr @num, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !11
  %96 = sext i8 %95 to i32
  %97 = icmp slt i32 %88, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %86
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %128

99:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %100 = load i32, ptr %4, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !9
  %104 = load i32, ptr %7, align 4, !tbaa !9
  %105 = shl i32 1, %104
  %106 = or i32 %103, %105
  store i32 %106, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %107

107:                                              ; preds = %121, %99
  %108 = load i32, ptr %9, align 4, !tbaa !9
  %109 = icmp slt i32 %108, 1024
  br i1 %109, label %111, label %110

110:                                              ; preds = %107
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %124

111:                                              ; preds = %107
  %112 = load i32, ptr %8, align 4, !tbaa !9
  %113 = load i32, ptr %9, align 4, !tbaa !9
  %114 = or i32 %112, %113
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %115
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %116, i32 noundef %120)
  br label %121

121:                                              ; preds = %111
  %122 = load i32, ptr %9, align 4, !tbaa !9
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %9, align 4, !tbaa !9
  br label %107, !llvm.loop !15

124:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %125

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

128:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1023, ptr %10, align 4, !tbaa !9
  br label %129

129:                                              ; preds = %171, %128
  %130 = load i32, ptr %10, align 4, !tbaa !9
  %131 = icmp sge i32 %130, 0
  br i1 %131, label %133, label %132

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

133:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %134 = load i32, ptr %10, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !9
  store i32 %137, ptr %11, align 4, !tbaa !9
  %138 = load i32, ptr %10, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %139
  store i32 0, ptr %140, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %141

141:                                              ; preds = %167, %133
  %142 = load i32, ptr %12, align 4, !tbaa !9
  %143 = icmp slt i32 %142, 10
  br i1 %143, label %145, label %144

144:                                              ; preds = %141
  store i32 22, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %170

145:                                              ; preds = %141
  %146 = load i32, ptr %10, align 4, !tbaa !9
  %147 = load i32, ptr %12, align 4, !tbaa !9
  %148 = shl i32 1, %147
  %149 = and i32 %146, %148
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %151, label %166

151:                                              ; preds = %145
  %152 = load i32, ptr %10, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %153
  %155 = load i32, ptr %10, align 4, !tbaa !9
  %156 = load i32, ptr %12, align 4, !tbaa !9
  %157 = shl i32 1, %156
  %158 = xor i32 %155, %157
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %154, i32 noundef %161)
  %162 = load i32, ptr %10, align 4, !tbaa !9
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %163
  %165 = load i32, ptr %11, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %164, i32 noundef %165)
  br label %166

166:                                              ; preds = %151, %145
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %12, align 4, !tbaa !9
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %12, align 4, !tbaa !9
  br label %141, !llvm.loop !17

170:                                              ; preds = %144
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %171

171:                                              ; preds = %170
  %172 = load i32, ptr %10, align 4, !tbaa !9
  %173 = add nsw i32 %172, -1
  store i32 %173, ptr %10, align 4, !tbaa !9
  br label %129, !llvm.loop !18

174:                                              ; preds = %132
  br label %175

175:                                              ; preds = %174
  %176 = load i32, ptr %4, align 4, !tbaa !9
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %4, align 4, !tbaa !9
  br label %56, !llvm.loop !19

178:                                              ; preds = %60
  %179 = load i64, ptr %2, align 8, !tbaa !5
  %180 = sub nsw i64 %179, 1
  %181 = srem i64 %180, 1000267129
  %182 = load i64, ptr %2, align 8, !tbaa !5
  %183 = sub nsw i64 %182, 2
  %184 = srem i64 %183, 1000267129
  %185 = mul nsw i64 %181, %184
  %186 = srem i64 %185, 1000267129
  %187 = trunc i64 %186 to i32
  store i32 %187, ptr @ans, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %188

188:                                              ; preds = %223, %178
  %189 = load i32, ptr %13, align 4, !tbaa !9
  %190 = icmp slt i32 %189, 1024
  br i1 %190, label %192, label %191

191:                                              ; preds = %188
  store i32 25, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %226

192:                                              ; preds = %188
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %193 = load i32, ptr %13, align 4, !tbaa !9
  %194 = sub nsw i32 1023, %193
  store i32 %194, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %195 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %195, ptr %15, align 4, !tbaa !9
  br label %196

196:                                              ; preds = %217, %192
  %197 = load i32, ptr %15, align 4, !tbaa !9
  %198 = icmp ne i32 %197, 0
  br i1 %198, label %200, label %199

199:                                              ; preds = %196
  store i32 28, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %222

200:                                              ; preds = %196
  %201 = load i32, ptr @ans, align 4, !tbaa !9
  %202 = sext i32 %201 to i64
  %203 = load i32, ptr %13, align 4, !tbaa !9
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %204
  %206 = load i32, ptr %205, align 4, !tbaa !9
  %207 = sext i32 %206 to i64
  %208 = load i32, ptr %15, align 4, !tbaa !9
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !9
  %212 = sext i32 %211 to i64
  %213 = mul nsw i64 %207, %212
  %214 = sub nsw i64 %202, %213
  %215 = srem i64 %214, 1000267129
  %216 = trunc i64 %215 to i32
  store i32 %216, ptr @ans, align 4, !tbaa !9
  br label %217

217:                                              ; preds = %200
  %218 = load i32, ptr %15, align 4, !tbaa !9
  %219 = sub nsw i32 %218, 1
  %220 = load i32, ptr %14, align 4, !tbaa !9
  %221 = and i32 %219, %220
  store i32 %221, ptr %15, align 4, !tbaa !9
  br label %196, !llvm.loop !20

222:                                              ; preds = %199
  br label %223

223:                                              ; preds = %222
  %224 = load i32, ptr %13, align 4, !tbaa !9
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %13, align 4, !tbaa !9
  br label %188, !llvm.loop !21

226:                                              ; preds = %191
  %227 = load i32, ptr @ans, align 4, !tbaa !9
  %228 = add nsw i32 %227, 1000267129
  %229 = sext i32 %228 to i64
  %230 = mul nsw i64 %229, 500133565
  %231 = srem i64 %230, 1000267129
  %232 = trunc i64 %231 to i32
  store i32 %232, ptr @ans, align 4, !tbaa !9
  %233 = load i32, ptr @ans, align 4, !tbaa !9
  %234 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %233)
  br label %16, !llvm.loop !22

235:                                              ; preds = %16
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %236 = load i32, ptr %1, align 4
  ret i32 %236
}

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = distinct !{!22, !13}


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

@len = external dso_local local_unnamed_addr global i32, align 4
@msk = external dso_local local_unnamed_addr global [21 x i32], align 16
@f = external dso_local global [1025 x i32], align 16
@g = external dso_local global [1025 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@num = external dso_local global [21 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7mod_decRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %.lr.ph77, label %._crit_edge78

.lr.ph77:                                         ; preds = %0, %.thread
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @num, ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %4) #5
  store i32 %5, ptr @len, align 4, !tbaa !9
  %6 = add nsw i32 %5, -1
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %7
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = icmp sgt i32 %5, 1
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph77
  %10 = zext nneg i32 %5 to i64
  %11 = shl nuw nsw i64 %10, 2
  %scevgep = getelementptr i8, ptr getelementptr (i8, ptr @msk, i64 -4), i64 %11
  %load_initial = load i32, ptr %scevgep, align 4
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph77
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4100) @f, i8 0, i64 4100, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4100) @g, i8 0, i64 4100, i1 false)
  store i32 1, ptr @f, align 16, !tbaa !9
  %12 = icmp sgt i32 %5, 0
  br i1 %12, label %.preheader56, label %._crit_edge65

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %store_forwarded = phi i32 [ %load_initial, %.lr.ph.preheader ], [ %19, %.lr.ph ]
  %indvars.iv = phi i64 [ %10, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %13 = sub nuw nsw i64 %10, %indvars.iv
  %14 = getelementptr inbounds [21 x i8], ptr @num, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = add nsw i32 %16, -48
  %18 = shl nuw i32 1, %17
  %19 = or i32 %18, %store_forwarded
  %20 = add nsw i64 %indvars.iv, -2
  %21 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %20
  store i32 %19, ptr %21, align 4, !tbaa !9
  %22 = icmp ugt i64 %indvars.iv, 2
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.preheader56:                                     ; preds = %._crit_edge, %69
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %69 ], [ 0, %._crit_edge ]
  br label %40

._crit_edge65:                                    ; preds = %69, %._crit_edge
  %23 = load i64, ptr %1, align 8, !tbaa !5
  %24 = add nsw i64 %23, -1
  %25 = srem i64 %24, 1000267129
  %26 = add nsw i64 %23, -2
  %27 = srem i64 %26, 1000267129
  %28 = mul nsw i64 %25, %27
  %29 = srem i64 %28, 1000267129
  %30 = trunc nsw i64 %29 to i32
  br label %145

.preheader55:                                     ; preds = %40
  %31 = trunc nuw nsw i64 %indvars.iv90 to i32
  %32 = xor i32 %31, -1
  %33 = load i32, ptr @len, align 4, !tbaa !9
  %34 = add i32 %33, %32
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [21 x i8], ptr @num, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = icmp sgt i8 %37, 48
  br i1 %38, label %.lr.ph61, label %.preheader.preheader

.preheader.preheader:                             ; preds = %52, %.preheader55
  br label %.preheader

.lr.ph61:                                         ; preds = %.preheader55
  %39 = getelementptr inbounds [21 x i32], ptr @msk, i64 0, i64 %indvars.iv90
  br label %48

40:                                               ; preds = %.preheader56, %40
  %indvars.iv80 = phi i64 [ 0, %.preheader56 ], [ %indvars.iv.next81, %40 ]
  %41 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %indvars.iv80
  %42 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %indvars.iv80
  %43 = load i32, ptr %42, align 8, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %41, i32 noundef %43)
  %44 = or disjoint i64 %indvars.iv80, 1
  %45 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %44
  %46 = load i32, ptr %42, align 8, !tbaa !9
  call void @_Z7mod_decRii(ptr noundef nonnull align 4 dereferenceable(4) %45, i32 noundef %46)
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 2
  %47 = icmp ult i64 %indvars.iv80, 1022
  br i1 %47, label %40, label %.preheader55, !llvm.loop !14

48:                                               ; preds = %.lr.ph61, %52
  %.05260 = phi i32 [ 0, %.lr.ph61 ], [ %53, %52 ]
  %49 = load i32, ptr %39, align 4, !tbaa !9
  %50 = shl nuw i32 1, %.05260
  %51 = or i32 %49, %50
  br label %62

52:                                               ; preds = %62
  %53 = add nuw nsw i32 %.05260, 1
  %54 = add nuw nsw i32 %.05260, 49
  %55 = load i32, ptr @len, align 4, !tbaa !9
  %56 = add i32 %55, %32
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [21 x i8], ptr @num, i64 0, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = sext i8 %59 to i32
  %61 = icmp slt i32 %54, %60
  br i1 %61, label %48, label %.preheader.preheader, !llvm.loop !15

62:                                               ; preds = %48, %62
  %indvars.iv83 = phi i64 [ 0, %48 ], [ %indvars.iv.next84, %62 ]
  %63 = trunc nuw nsw i64 %indvars.iv83 to i32
  %64 = or i32 %51, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %65
  %67 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %indvars.iv83
  %68 = load i32, ptr %67, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %66, i32 noundef %68)
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next84, 1024
  br i1 %exitcond.not, label %52, label %62, !llvm.loop !16

69:                                               ; preds = %135
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %70 = load i32, ptr @len, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = icmp slt i64 %indvars.iv.next91, %71
  br i1 %72, label %.preheader56, label %._crit_edge65, !llvm.loop !17

.preheader:                                       ; preds = %.preheader.preheader, %135
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %135 ], [ 1023, %.preheader.preheader ]
  %73 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %indvars.iv87
  %74 = load i32, ptr %73, align 4, !tbaa !9
  store i32 0, ptr %73, align 4, !tbaa !9
  %75 = trunc nuw nsw i64 %indvars.iv87 to i32
  %76 = and i32 %75, 1
  %.not54 = icmp eq i32 %76, 0
  br i1 %.not54, label %81, label %77

77:                                               ; preds = %.preheader
  %78 = and i64 %indvars.iv87, 4294967294
  %79 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %78
  %80 = load i32, ptr %79, align 8, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %80)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %81

81:                                               ; preds = %.preheader, %77
  %82 = and i32 %75, 2
  %.not54.1 = icmp eq i32 %82, 0
  br i1 %.not54.1, label %87, label %83

83:                                               ; preds = %81
  %84 = and i64 %indvars.iv87, 4294967293
  %85 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %86)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %87

87:                                               ; preds = %83, %81
  %88 = and i32 %75, 4
  %.not54.2 = icmp eq i32 %88, 0
  br i1 %.not54.2, label %93, label %89

89:                                               ; preds = %87
  %90 = and i64 %indvars.iv87, 4294967291
  %91 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %92)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %93

93:                                               ; preds = %89, %87
  %94 = and i32 %75, 8
  %.not54.3 = icmp eq i32 %94, 0
  br i1 %.not54.3, label %99, label %95

95:                                               ; preds = %93
  %96 = and i64 %indvars.iv87, 4294967287
  %97 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %98)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %99

99:                                               ; preds = %95, %93
  %100 = and i32 %75, 16
  %.not54.4 = icmp eq i32 %100, 0
  br i1 %.not54.4, label %105, label %101

101:                                              ; preds = %99
  %102 = and i64 %indvars.iv87, 4294967279
  %103 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %104)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %105

105:                                              ; preds = %101, %99
  %106 = and i32 %75, 32
  %.not54.5 = icmp eq i32 %106, 0
  br i1 %.not54.5, label %111, label %107

107:                                              ; preds = %105
  %108 = and i64 %indvars.iv87, 4294967263
  %109 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %110)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %111

111:                                              ; preds = %107, %105
  %112 = and i32 %75, 64
  %.not54.6 = icmp eq i32 %112, 0
  br i1 %.not54.6, label %117, label %113

113:                                              ; preds = %111
  %114 = and i64 %indvars.iv87, 4294967231
  %115 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %116)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %117

117:                                              ; preds = %113, %111
  %118 = and i32 %75, 128
  %.not54.7 = icmp eq i32 %118, 0
  br i1 %.not54.7, label %123, label %119

119:                                              ; preds = %117
  %120 = and i64 %indvars.iv87, 4294967167
  %121 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %122)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %123

123:                                              ; preds = %119, %117
  %124 = and i32 %75, 256
  %.not54.8 = icmp eq i32 %124, 0
  br i1 %.not54.8, label %129, label %125

125:                                              ; preds = %123
  %126 = and i64 %indvars.iv87, 4294967039
  %127 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %128)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %129

129:                                              ; preds = %125, %123
  %130 = and i32 %75, 512
  %.not54.9 = icmp eq i32 %130, 0
  br i1 %.not54.9, label %135, label %131

131:                                              ; preds = %129
  %132 = and i64 %indvars.iv87, 4294966783
  %133 = getelementptr inbounds [1025 x i32], ptr @f, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !9
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %134)
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %73, i32 noundef %74)
  br label %135

135:                                              ; preds = %131, %129
  %indvars.iv.next88 = add nsw i64 %indvars.iv87, -1
  %.not97 = icmp eq i64 %indvars.iv87, 0
  br i1 %.not97, label %69, label %.preheader, !llvm.loop !18

.thread:                                          ; preds = %145, %151
  %136 = phi i32 [ %162, %151 ], [ %.lcssa7374, %145 ]
  %137 = add nsw i32 %136, 1000267129
  %138 = zext nneg i32 %137 to i64
  %139 = mul nuw nsw i64 %138, 500133565
  %140 = urem i64 %139, 1000267129
  %141 = trunc nuw nsw i64 %140 to i32
  store i32 %141, ptr @ans, align 4, !tbaa !9
  %142 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %141)
  %143 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %144 = icmp eq i32 %143, 1
  br i1 %144, label %.lr.ph77, label %._crit_edge78, !llvm.loop !19

145:                                              ; preds = %._crit_edge65, %151
  %indvars.iv93 = phi i64 [ 1, %._crit_edge65 ], [ %indvars.iv.next94, %151 ]
  %.lcssa7374 = phi i32 [ %30, %._crit_edge65 ], [ %162, %151 ]
  %.not66 = icmp eq i64 %indvars.iv93, 1023
  br i1 %.not66, label %.thread, label %.lr.ph69

.lr.ph69:                                         ; preds = %145
  %146 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %indvars.iv93
  %147 = load i32, ptr %146, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = trunc i64 %indvars.iv93 to i32
  %150 = sub i32 1023, %149
  br label %152

151:                                              ; preds = %152
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond96.not = icmp eq i64 %indvars.iv.next94, 1024
  br i1 %exitcond96.not, label %.thread, label %145, !llvm.loop !20

152:                                              ; preds = %.lr.ph69, %152
  %.067 = phi i32 [ %150, %.lr.ph69 ], [ %164, %152 ]
  %153 = phi i32 [ %.lcssa7374, %.lr.ph69 ], [ %162, %152 ]
  %154 = sext i32 %153 to i64
  %155 = sext i32 %.067 to i64
  %156 = getelementptr inbounds [1025 x i32], ptr @g, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  %159 = mul nsw i64 %158, %148
  %160 = sub nsw i64 %154, %159
  %161 = srem i64 %160, 1000267129
  %162 = trunc nsw i64 %161 to i32
  %163 = add nuw nsw i32 %.067, 1023
  %164 = and i32 %163, %150
  %.not = icmp eq i32 %164, 0
  br i1 %.not, label %151, label %152, !llvm.loop !21

._crit_edge78:                                    ; preds = %.thread, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0
}

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass