; LLVM IR from tangjz/acm-icpc :: lydsy (4017)

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

@n = external dso_local global i32, align 4
@a = external dso_local global [100010 x i32], align 16
@x = external dso_local global [100010 x i32], align 16
@bit = external dso_local global [100010 x i32], align 16
@ans1 = external dso_local global i32, align 4
@s = external dso_local global [100010 x i64], align 16
@p = external dso_local global [100010 x i64], align 16
@ans2 = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) #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 nounwind uwtable
declare dso_local void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addi(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxx(i64 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 [2 x 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 i64, align 8
  store i32 0, ptr %1, align 4
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %50, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %53

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %21
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %22)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = xor i32 %27, %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %34
  store i32 %32, ptr %35, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %40, %45
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %48
  store i64 %46, ptr %49, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %19
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !11

53:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %98, %53
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = icmp slt i32 %55, 30
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %102

58:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.memset.p0.i64(ptr align 4 %6, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %87, %58
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %90

64:                                               ; preds = %59
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = ashr i32 %68, %69
  %71 = and i32 %70, 1
  %72 = xor i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef %75)
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = ashr i32 %79, %80
  %82 = and i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %84, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %64
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %8, align 4, !tbaa !5
  br label %59, !llvm.loop !13

90:                                               ; preds = %63
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = mul nsw i64 %92, %94
  %96 = srem i64 %95, 998244353
  %97 = trunc i64 %96 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) @ans1, i32 noundef %97)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %98

98:                                               ; preds = %90
  %99 = load i32, ptr %3, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %3, align 4, !tbaa !5
  %101 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %101)
  br label %54, !llvm.loop !14

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

103:                                              ; preds = %193, %102
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = zext i32 %104 to i64
  %106 = shl i64 1, %105
  %107 = load i32, ptr @n, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %108
  %110 = load i64, ptr %109, align 8, !tbaa !9
  %111 = icmp slt i64 %106, %110
  br i1 %111, label %113, label %112

112:                                              ; preds = %103
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %196

113:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %133, %113
  %115 = load i32, ptr %11, align 4, !tbaa !5
  %116 = load i32, ptr @n, align 4, !tbaa !5
  %117 = icmp sle i32 %115, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %114
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %136

119:                                              ; preds = %114
  %120 = load i32, ptr %11, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %121
  %123 = load i64, ptr %122, align 8, !tbaa !9
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  %126 = zext i32 %125 to i64
  %127 = shl i64 1, %126
  %128 = sub nsw i64 %127, 1
  %129 = and i64 %123, %128
  %130 = load i32, ptr %11, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100010 x i64], ptr @p, i64 0, i64 %131
  store i64 %129, ptr %132, align 8, !tbaa !9
  br label %133

133:                                              ; preds = %119
  %134 = load i32, ptr %11, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %11, align 4, !tbaa !5
  br label %114, !llvm.loop !15

136:                                              ; preds = %118
  %137 = load i32, ptr @n, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds i64, ptr @p, i64 %138
  %140 = getelementptr inbounds i64, ptr %139, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @p, ptr noundef %140)
  call void @llvm.memset.p0.i64(ptr align 16 @bit, i8 0, i64 400040, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %180, %136
  %142 = load i32, ptr %12, align 4, !tbaa !5
  %143 = load i32, ptr @n, align 4, !tbaa !5
  %144 = icmp sle i32 %142, %143
  br i1 %144, label %146, label %145

145:                                              ; preds = %141
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %183

146:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %147 = load i32, ptr %12, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %148
  %150 = load i64, ptr %149, align 8, !tbaa !9
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = add nsw i32 %151, 1
  %153 = zext i32 %152 to i64
  %154 = shl i64 1, %153
  %155 = sub nsw i64 %154, 1
  %156 = and i64 %150, %155
  store i64 %156, ptr %13, align 8, !tbaa !9
  %157 = load i64, ptr %13, align 8, !tbaa !9
  %158 = call noundef i32 @_Z3idxx(i64 noundef %157)
  call void @_Z3addi(i32 noundef %158)
  %159 = load i64, ptr %13, align 8, !tbaa !9
  %160 = load i32, ptr %9, align 4, !tbaa !5
  %161 = zext i32 %160 to i64
  %162 = shl i64 1, %161
  %163 = sub nsw i64 %159, %162
  %164 = call noundef i32 @_Z3idxx(i64 noundef %163)
  %165 = call noundef i32 @_Z3sumi(i32 noundef %164)
  %166 = load i64, ptr %13, align 8, !tbaa !9
  %167 = load i32, ptr %9, align 4, !tbaa !5
  %168 = zext i32 %167 to i64
  %169 = shl i64 1, %168
  %170 = add nsw i64 %166, %169
  %171 = call noundef i32 @_Z3idxx(i64 noundef %170)
  %172 = call noundef i32 @_Z3sumi(i32 noundef %171)
  %173 = xor i32 %165, %172
  %174 = load i64, ptr %13, align 8, !tbaa !9
  %175 = call noundef i32 @_Z3idxx(i64 noundef %174)
  %176 = call noundef i32 @_Z3sumi(i32 noundef %175)
  %177 = xor i32 %173, %176
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = xor i32 %178, %177
  store i32 %179, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %180

180:                                              ; preds = %146
  %181 = load i32, ptr %12, align 4, !tbaa !5
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr %12, align 4, !tbaa !5
  br label %141, !llvm.loop !16

183:                                              ; preds = %145
  %184 = load i32, ptr %10, align 4, !tbaa !5
  %185 = icmp ne i32 %184, 0
  br i1 %185, label %186, label %192

186:                                              ; preds = %183
  %187 = load i32, ptr %9, align 4, !tbaa !5
  %188 = zext i32 %187 to i64
  %189 = shl i64 1, %188
  %190 = load i64, ptr @ans2, align 8, !tbaa !9
  %191 = or i64 %190, %189
  store i64 %191, ptr @ans2, align 8, !tbaa !9
  br label %192

192:                                              ; preds = %186, %183
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %9, align 4, !tbaa !5
  br label %103, !llvm.loop !17

196:                                              ; preds = %112
  %197 = load i32, ptr @ans1, align 4, !tbaa !5
  %198 = load i64, ptr @ans2, align 8, !tbaa !9
  %199 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %197, i64 noundef %198)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #5

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

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 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { "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 #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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

@n = external dso_local global i32, align 4
@a = external dso_local global [100010 x i32], align 16
@x = external dso_local local_unnamed_addr global [100010 x i32], align 16
@bit = external dso_local local_unnamed_addr global [100010 x i32], align 16
@ans1 = external dso_local global i32, align 4
@s = external dso_local local_unnamed_addr global [100010 x i64], align 16
@p = external dso_local global [100010 x i64], align 16
@ans2 = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) 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 nounwind uwtable
declare dso_local void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxx(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca [2 x i32], align 8
  %3 = alloca i32, align 4
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not50 = icmp slt i32 %4, 1
  br i1 %.not50, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %25

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %5 = getelementptr inbounds [100010 x i32], ptr @a, i64 0, i64 %indvars.iv
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %5)
  %6 = add nsw i64 %indvars.iv, -1
  %7 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = xor i32 %9, %8
  %11 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %indvars.iv
  store i32 %10, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %6
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = sext i32 %9 to i64
  %15 = add nsw i64 %13, %14
  %16 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %indvars.iv
  store i64 %15, ptr %16, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %.not.not = icmp slt i64 %indvars.iv, %18
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

19:                                               ; preds = %._crit_edge56
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp sgt i64 %23, 1
  br i1 %24, label %.preheader, label %._crit_edge69

25:                                               ; preds = %._crit_edge, %._crit_edge56
  %.04257 = phi i32 [ 0, %._crit_edge ], [ %34, %._crit_edge56 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 0, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %.not4952 = icmp slt i32 %26, 0
  br i1 %.not4952, label %._crit_edge56, label %.lr.ph55

._crit_edge56.loopexit:                           ; preds = %.lr.ph55
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge56

._crit_edge56:                                    ; preds = %._crit_edge56.loopexit, %25
  %27 = phi i32 [ %.pre, %._crit_edge56.loopexit ], [ 0, %25 ]
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = sext i32 %27 to i64
  %31 = mul nsw i64 %30, %29
  %32 = srem i64 %31, 998244353
  %33 = trunc nsw i64 %32 to i32
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) @ans1, i32 noundef %33)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %34 = add nuw nsw i32 %.04257, 1
  %35 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %1, i32 noundef %35)
  %exitcond.not = icmp eq i32 %34, 30
  br i1 %exitcond.not, label %19, label %25, !llvm.loop !13

.lr.ph55:                                         ; preds = %25, %.lr.ph55
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %.lr.ph55 ], [ 0, %25 ]
  %36 = getelementptr inbounds [100010 x i32], ptr @x, i64 0, i64 %indvars.iv71
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = lshr i32 %37, %.04257
  %39 = and i32 %38, 1
  %40 = xor i32 %39, 1
  %41 = zext nneg i32 %40 to i64
  %42 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  call void @_Z3incRii(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef %43)
  %44 = load i32, ptr %36, align 4, !tbaa !5
  %45 = lshr i32 %44, %.04257
  %46 = and i32 %45, 1
  %47 = zext nneg i32 %46 to i64
  %48 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %48, align 4, !tbaa !5
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %.not49.not = icmp slt i64 %indvars.iv71, %52
  br i1 %.not49.not, label %.lr.ph55, label %._crit_edge56.loopexit, !llvm.loop !14

.preheader:                                       ; preds = %19, %._crit_edge67.thread
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge67.thread ], [ 0, %19 ]
  %53 = phi i64 [ %97, %._crit_edge67.thread ], [ %21, %19 ]
  %54 = phi i32 [ %95, %._crit_edge67.thread ], [ %20, %19 ]
  %55 = phi i64 [ %96, %._crit_edge67.thread ], [ 1, %19 ]
  %.not4558 = icmp slt i32 %54, 0
  br i1 %.not4558, label %._crit_edge61, label %.lr.ph60

.lr.ph60:                                         ; preds = %.preheader
  %notmask48 = shl nsw i64 -2, %indvars.iv81
  %56 = xor i64 %notmask48, -1
  %57 = add nuw i32 %54, 1
  %wide.trip.count = zext i32 %57 to i64
  %min.iters.check = icmp ult i32 %54, 3
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

vector.ph:                                        ; preds = %.lr.ph60
  %n.vec = and i64 %wide.trip.count, 4294967292
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %56, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %58 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %index
  %59 = getelementptr inbounds i8, ptr %58, i64 16
  %wide.load = load <2 x i64>, ptr %58, align 16, !tbaa !9
  %wide.load89 = load <2 x i64>, ptr %59, align 16, !tbaa !9
  %60 = and <2 x i64> %wide.load, %broadcast.splat
  %61 = and <2 x i64> %wide.load89, %broadcast.splat
  %62 = getelementptr inbounds [100010 x i64], ptr @p, i64 0, i64 %index
  %63 = getelementptr inbounds i8, ptr %62, i64 16
  store <2 x i64> %60, ptr %62, align 16, !tbaa !9
  store <2 x i64> %61, ptr %63, align 16, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %64 = icmp eq i64 %index.next, %n.vec
  br i1 %64, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge61, label %scalar.ph.preheader

._crit_edge69:                                    ; preds = %._crit_edge67.thread, %19
  %65 = load i32, ptr @ans1, align 4, !tbaa !5
  %66 = load i64, ptr @ans2, align 8, !tbaa !9
  %67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %65, i64 noundef %66)
  ret i32 0

._crit_edge61:                                    ; preds = %scalar.ph, %middle.block, %.preheader
  %gep = getelementptr i64, ptr getelementptr inbounds (i8, ptr @p, i64 8), i64 %53
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @p, ptr noundef nonnull %gep)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400040) @bit, i8 0, i64 400040, i1 false)
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %.not4662 = icmp slt i32 %68, 0
  br i1 %.not4662, label %._crit_edge67.thread, label %.lr.ph66

.lr.ph66:                                         ; preds = %._crit_edge61
  %notmask = shl nsw i64 -2, %indvars.iv81
  %69 = xor i64 %notmask, -1
  br label %74

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %scalar.ph ], [ %indvars.iv74.ph, %scalar.ph.preheader ]
  %70 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %indvars.iv74
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = and i64 %71, %56
  %73 = getelementptr inbounds [100010 x i64], ptr @p, i64 0, i64 %indvars.iv74
  store i64 %72, ptr %73, align 8, !tbaa !9
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond77.not = icmp eq i64 %indvars.iv.next75, %wide.trip.count
  br i1 %exitcond77.not, label %._crit_edge61, label %scalar.ph, !llvm.loop !18

._crit_edge67:                                    ; preds = %74
  %.not47 = icmp eq i32 %88, %86
  br i1 %.not47, label %._crit_edge67.thread, label %92

74:                                               ; preds = %.lr.ph66, %74
  %indvars.iv78 = phi i64 [ 0, %.lr.ph66 ], [ %indvars.iv.next79, %74 ]
  %.03963 = phi i32 [ 0, %.lr.ph66 ], [ %89, %74 ]
  %75 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %indvars.iv78
  %76 = load i64, ptr %75, align 8, !tbaa !9
  %77 = and i64 %76, %69
  %78 = call noundef i32 @_Z3idxx(i64 noundef %77)
  call void @_Z3addi(i32 noundef %78)
  %79 = sub nsw i64 %77, %55
  %80 = call noundef i32 @_Z3idxx(i64 noundef %79)
  %81 = call noundef i32 @_Z3sumi(i32 noundef %80)
  %82 = add nuw nsw i64 %77, %55
  %83 = call noundef i32 @_Z3idxx(i64 noundef %82)
  %84 = call noundef i32 @_Z3sumi(i32 noundef %83)
  %85 = call noundef i32 @_Z3idxx(i64 noundef %77)
  %86 = call noundef i32 @_Z3sumi(i32 noundef %85)
  %87 = xor i32 %81, %.03963
  %88 = xor i32 %87, %84
  %89 = xor i32 %88, %86
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %.not46.not = icmp slt i64 %indvars.iv78, %91
  br i1 %.not46.not, label %74, label %._crit_edge67, !llvm.loop !19

92:                                               ; preds = %._crit_edge67
  %93 = load i64, ptr @ans2, align 8, !tbaa !9
  %94 = or i64 %93, %55
  store i64 %94, ptr @ans2, align 8, !tbaa !9
  br label %._crit_edge67.thread

._crit_edge67.thread:                             ; preds = %._crit_edge61, %92, %._crit_edge67
  %95 = phi i32 [ %90, %92 ], [ %90, %._crit_edge67 ], [ %68, %._crit_edge61 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %96 = shl nuw i64 2, %indvars.iv81
  %97 = sext i32 %95 to i64
  %98 = getelementptr inbounds [100010 x i64], ptr @s, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !9
  %100 = icmp slt i64 %96, %99
  br i1 %100, label %.preheader, label %._crit_edge69, !llvm.loop !20
}

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #5

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

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


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