; LLVM IR from tangjz/acm-icpc :: TDL_training/2016-04-10 (K - Average Modulo - lzy)

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

@T = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@P = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@s = external dso_local global [100009 x i32], align 16
@t = external dso_local global [100009 x i32], align 16
@x = external dso_local global [100009 x i32], 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 [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5checkd(double noundef) #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 double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %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
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @T)
  br label %17

17:                                               ; preds = %213, %211, %0
  %18 = load i32, ptr @T, align 4, !tbaa !5
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr @T, align 4, !tbaa !5
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %214

21:                                               ; preds = %17
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @P, ptr noundef @k)
  store i32 0, ptr @s, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %49, %21
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %52

28:                                               ; preds = %23
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a)
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sub nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr @a, align 4, !tbaa !5
  %36 = add nsw i32 %34, %35
  %37 = load i32, ptr @P, align 4, !tbaa !5
  %38 = srem i32 %36, %37
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %40
  store i32 %38, ptr %41, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100009 x i32], ptr @x, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %28
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %2, align 4, !tbaa !5
  br label %23, !llvm.loop !9

52:                                               ; preds = %27
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr @x, i64 %54
  %56 = getelementptr inbounds i32, ptr %55, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @x, ptr noundef %56)
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr @x, i64 %58
  %60 = getelementptr inbounds i32, ptr %59, i64 1
  %61 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @x, ptr noundef %60)
  %62 = ptrtoint ptr %61 to i64
  %63 = sub i64 %62, ptrtoint (ptr @x to i64)
  %64 = sdiv exact i64 %63, 4
  %65 = trunc i64 %64 to i32
  store i32 %65, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %86, %52
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp sle i32 %67, %68
  br i1 %69, label %71, label %70

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

71:                                               ; preds = %66
  %72 = load i32, ptr @m, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr @x, i64 %73
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %76
  %78 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @x, ptr noundef %74, ptr noundef nonnull align 4 dereferenceable(4) %77)
  %79 = ptrtoint ptr %78 to i64
  %80 = sub i64 %79, ptrtoint (ptr @x to i64)
  %81 = sdiv exact i64 %80, 4
  %82 = trunc i64 %81 to i32
  %83 = load i32, ptr %3, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100009 x i32], ptr @t, i64 0, i64 %84
  store i32 %82, ptr %85, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %71
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %3, align 4, !tbaa !5
  br label %66, !llvm.loop !11

89:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store double 0.000000e+00, ptr %4, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store double 1.000000e+10, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %107, %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = icmp slt i32 %91, 60
  br i1 %92, label %94, label %93

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

94:                                               ; preds = %90
  %95 = load double, ptr %4, align 8, !tbaa !12
  %96 = load double, ptr %5, align 8, !tbaa !12
  %97 = fadd double %95, %96
  %98 = fdiv double %97, 2.000000e+00
  store double %98, ptr %6, align 8, !tbaa !12
  %99 = load double, ptr %6, align 8, !tbaa !12
  %100 = call noundef i32 @_Z5checkd(double noundef %99)
  %101 = icmp eq i32 %100, -1
  br i1 %101, label %102, label %104

102:                                              ; preds = %94
  %103 = load double, ptr %6, align 8, !tbaa !12
  store double %103, ptr %5, align 8, !tbaa !12
  br label %106

104:                                              ; preds = %94
  %105 = load double, ptr %6, align 8, !tbaa !12
  store double %105, ptr %4, align 8, !tbaa !12
  br label %106

106:                                              ; preds = %104, %102
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %7, align 4, !tbaa !5
  br label %90, !llvm.loop !14

110:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %111 = load double, ptr %4, align 8, !tbaa !12
  %112 = fsub double %111, 0x3E7AD7F29ABCAF48
  %113 = call noundef i32 @_Z5checkd(double noundef %112)
  store i32 %113, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = load i32, ptr @k, align 4, !tbaa !5
  %116 = icmp slt i32 %114, %115
  br i1 %116, label %117, label %119

117:                                              ; preds = %110
  %118 = call i32 @puts(ptr noundef @.str.2)
  store i32 2, ptr %10, align 4
  br label %211, !llvm.loop !15

119:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store double 0.000000e+00, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %171, %119
  %121 = load i32, ptr %12, align 4, !tbaa !5
  %122 = load i32, ptr @k, align 4, !tbaa !5
  %123 = add nsw i32 %121, %122
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = icmp sle i32 %123, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %120
  store i32 13, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %174

127:                                              ; preds = %120
  %128 = load double, ptr %11, align 8, !tbaa !12
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = load i32, ptr %12, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = sub nsw i32 %132, %136
  %138 = load i32, ptr @P, align 4, !tbaa !5
  %139 = add nsw i32 %137, %138
  %140 = load i32, ptr @P, align 4, !tbaa !5
  %141 = srem i32 %139, %140
  %142 = sitofp i32 %141 to double
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = load i32, ptr %12, align 4, !tbaa !5
  %145 = sub nsw i32 %143, %144
  %146 = sitofp i32 %145 to double
  %147 = fdiv double %142, %146
  %148 = fcmp olt double %128, %147
  br i1 %148, label %149, label %170

149:                                              ; preds = %127
  %150 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %150, ptr %9, align 4, !tbaa !5
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr %12, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = sub nsw i32 %154, %158
  %160 = load i32, ptr @P, align 4, !tbaa !5
  %161 = add nsw i32 %159, %160
  %162 = load i32, ptr @P, align 4, !tbaa !5
  %163 = srem i32 %161, %162
  %164 = sitofp i32 %163 to double
  %165 = load i32, ptr %8, align 4, !tbaa !5
  %166 = load i32, ptr %12, align 4, !tbaa !5
  %167 = sub nsw i32 %165, %166
  %168 = sitofp i32 %167 to double
  %169 = fdiv double %164, %168
  store double %169, ptr %11, align 8, !tbaa !12
  br label %170

170:                                              ; preds = %149, %127
  br label %171

171:                                              ; preds = %170
  %172 = load i32, ptr %12, align 4, !tbaa !5
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %12, align 4, !tbaa !5
  br label %120, !llvm.loop !16

174:                                              ; preds = %126
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = icmp slt i32 %175, 0
  br i1 %176, label %181, label %177

177:                                              ; preds = %174
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = load i32, ptr %8, align 4, !tbaa !5
  %180 = icmp sge i32 %178, %179
  br i1 %180, label %181, label %183

181:                                              ; preds = %177, %174
  %182 = call i32 @puts(ptr noundef @.str.2)
  store i32 2, ptr %10, align 4
  br label %210, !llvm.loop !15

183:                                              ; preds = %177
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %184 = load i32, ptr %8, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = load i32, ptr %9, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = sub nsw i32 %187, %191
  %193 = load i32, ptr @P, align 4, !tbaa !5
  %194 = add nsw i32 %192, %193
  %195 = load i32, ptr @P, align 4, !tbaa !5
  %196 = srem i32 %194, %195
  store i32 %196, ptr %13, align 4, !tbaa !5
  %197 = load i32, ptr %8, align 4, !tbaa !5
  %198 = load i32, ptr %9, align 4, !tbaa !5
  %199 = sub nsw i32 %197, %198
  store i32 %199, ptr %14, align 4, !tbaa !5
  %200 = load i32, ptr %13, align 4, !tbaa !5
  %201 = load i32, ptr %14, align 4, !tbaa !5
  %202 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %200, i32 noundef %201)
  store i32 %202, ptr %15, align 4, !tbaa !5
  %203 = load i32, ptr %13, align 4, !tbaa !5
  %204 = load i32, ptr %15, align 4, !tbaa !5
  %205 = sdiv i32 %203, %204
  %206 = load i32, ptr %14, align 4, !tbaa !5
  %207 = load i32, ptr %15, align 4, !tbaa !5
  %208 = sdiv i32 %206, %207
  %209 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %205, i32 noundef %208)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  store i32 0, ptr %10, align 4
  br label %210

210:                                              ; preds = %183, %181
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %211

211:                                              ; preds = %210, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %212 = load i32, ptr %10, align 4
  switch i32 %212, label %215 [
    i32 0, label %213
    i32 2, label %17
  ]

213:                                              ; preds = %211
  br label %17, !llvm.loop !15

214:                                              ; preds = %17
  ret i32 0

215:                                              ; preds = %211
  unreachable
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef, ptr noundef) #4

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

declare i32 @puts(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) #5

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

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

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

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


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

@T = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@P = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global i32, align 4
@s = external dso_local global [100009 x i32], align 16
@t = external dso_local local_unnamed_addr global [100009 x i32], align 16
@x = external dso_local global [100009 x i32], 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 [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5checkd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @T)
  %2 = load i32, ptr @T, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @T, align 4, !tbaa !5
  %.not76 = icmp eq i32 %2, 0
  br i1 %.not76, label %._crit_edge80, label %.lr.ph79

.lr.ph79:                                         ; preds = %0, %84
  %.04977 = phi i32 [ %.3, %84 ], [ undef, %0 ]
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @P, ptr noundef nonnull @k)
  store i32 0, ptr @s, align 16, !tbaa !5
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not5763 = icmp slt i32 %5, 1
  br i1 %.not5763, label %.lr.ph79.._crit_edge_crit_edge, label %.lr.ph

.lr.ph79.._crit_edge_crit_edge:                   ; preds = %.lr.ph79
  %.pre = sext i32 %5 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph79.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.lr.ph79.._crit_edge_crit_edge ], [ %25, %.lr.ph ]
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @x, i64 4), i64 %.pre-phi
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @x, ptr noundef nonnull %gep)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %gep75 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @x, i64 4), i64 %7
  %8 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @x, ptr noundef nonnull %gep75)
  %9 = ptrtoint ptr %8 to i64
  %10 = sub i64 %9, ptrtoint (ptr @x to i64)
  %11 = lshr exact i64 %10, 2
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr @m, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %.not5865 = icmp slt i32 %13, 0
  br i1 %.not5865, label %.preheader62.preheader, label %.lr.ph68

.preheader62.preheader:                           ; preds = %.lr.ph68, %._crit_edge
  br label %.preheader62

.lr.ph:                                           ; preds = %.lr.ph79, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph79 ]
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %15 = add nsw i64 %indvars.iv, -1
  %16 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = load i32, ptr @a, align 4, !tbaa !5
  %19 = add nsw i32 %18, %17
  %20 = load i32, ptr @P, align 4, !tbaa !5
  %21 = srem i32 %19, %20
  %22 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %indvars.iv
  store i32 %21, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds [100009 x i32], ptr @x, i64 0, i64 %indvars.iv
  store i32 %21, ptr %23, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %.not57.not = icmp slt i64 %indvars.iv, %25
  br i1 %.not57.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph68:                                         ; preds = %._crit_edge, %.lr.ph68
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %.lr.ph68 ], [ 0, %._crit_edge ]
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @x, i64 %27
  %29 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %indvars.iv83
  %30 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @x, ptr noundef nonnull %28, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %31 = ptrtoint ptr %30 to i64
  %32 = sub i64 %31, ptrtoint (ptr @x to i64)
  %33 = lshr exact i64 %32, 2
  %34 = trunc i64 %33 to i32
  %35 = getelementptr inbounds [100009 x i32], ptr @t, i64 0, i64 %indvars.iv83
  store i32 %34, ptr %35, align 4, !tbaa !5
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %.not58.not = icmp slt i64 %indvars.iv83, %37
  br i1 %.not58.not, label %.lr.ph68, label %.preheader62.preheader, !llvm.loop !11

38:                                               ; preds = %.preheader62
  %39 = fadd double %.045., 0xBE7AD7F29ABCAF48
  %40 = tail call noundef i32 @_Z5checkd(double noundef %39)
  %41 = load i32, ptr @k, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %53, label %.preheader

.preheader:                                       ; preds = %38
  %43 = sext i32 %40 to i64
  %44 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr @P, align 4, !tbaa !5
  %47 = sext i32 %41 to i64
  %invariant.op = sub nsw i64 %43, %47
  br label %57

.preheader62:                                     ; preds = %.preheader62.preheader, %.preheader62
  %.04571 = phi double [ %.045., %.preheader62 ], [ 0.000000e+00, %.preheader62.preheader ]
  %.05170 = phi double [ %..051, %.preheader62 ], [ 1.000000e+10, %.preheader62.preheader ]
  %.05369 = phi i32 [ %52, %.preheader62 ], [ 0, %.preheader62.preheader ]
  %48 = fadd double %.05170, %.04571
  %49 = fmul double %48, 5.000000e-01
  %50 = tail call noundef i32 @_Z5checkd(double noundef %49)
  %51 = icmp eq i32 %50, -1
  %..051 = select i1 %51, double %49, double %.05170
  %.045. = select i1 %51, double %.04571, double %49
  %52 = add nuw nsw i32 %.05369, 1
  %exitcond.not = icmp eq i32 %52, 60
  br i1 %exitcond.not, label %38, label %.preheader62, !llvm.loop !12

53:                                               ; preds = %38
  %54 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %84, !llvm.loop !13

55:                                               ; preds = %57
  %56 = icmp sgt i32 %.2, -1
  %.not60 = icmp slt i32 %.2, %40
  %or.cond = and i1 %56, %.not60
  br i1 %or.cond, label %72, label %70

57:                                               ; preds = %.preheader, %57
  %indvars.iv86 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next87, %57 ]
  %.04773 = phi double [ 0.000000e+00, %.preheader ], [ %.148, %57 ]
  %.15072 = phi i32 [ %.04977, %.preheader ], [ %.2, %57 ]
  %58 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %indvars.iv86
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sub i32 %45, %59
  %61 = add nsw i32 %60, %46
  %62 = srem i32 %61, %46
  %63 = sitofp i32 %62 to double
  %64 = trunc i64 %indvars.iv86 to i32
  %65 = sub i32 %40, %64
  %66 = sitofp i32 %65 to double
  %67 = fdiv double %63, %66
  %68 = fcmp olt double %.04773, %67
  %69 = trunc nuw nsw i64 %indvars.iv86 to i32
  %.2 = select i1 %68, i32 %69, i32 %.15072
  %.148 = select i1 %68, double %67, double %.04773
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %.not59.not = icmp slt i64 %indvars.iv86, %invariant.op
  br i1 %.not59.not, label %57, label %55, !llvm.loop !14

70:                                               ; preds = %55
  %71 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %84, !llvm.loop !13

72:                                               ; preds = %55
  %73 = zext nneg i32 %.2 to i64
  %74 = getelementptr inbounds [100009 x i32], ptr @s, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sub i32 %45, %75
  %77 = add nsw i32 %76, %46
  %78 = srem i32 %77, %46
  %79 = sub nsw i32 %40, %.2
  %80 = tail call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %78, i32 noundef %79)
  %81 = sdiv i32 %78, %80
  %82 = sdiv i32 %79, %80
  %83 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %81, i32 noundef %82)
  br label %84

84:                                               ; preds = %70, %72, %53
  %.3 = phi i32 [ %.04977, %53 ], [ %.2, %72 ], [ %.2, %70 ]
  %85 = load i32, ptr @T, align 4, !tbaa !5
  %86 = add nsw i32 %85, -1
  store i32 %86, ptr @T, align 4, !tbaa !5
  %.not = icmp eq i32 %85, 0
  br i1 %.not, label %._crit_edge80, label %.lr.ph79

._crit_edge80:                                    ; preds = %84, %0
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #4

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

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 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 = { 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 #3 = { 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 #4 = { 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" }

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

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


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