; LLVM IR from lzyrapx/Competitive-Programming :: ACdream (1003（DFS）)

; 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
@m = external dso_local global i32, align 4
@sum = external dso_local global i32, align 4
@Min = external dso_local global i32, align 4
@res = external dso_local global i32, align 4
@pill = external dso_local global [23 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 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 zeroext i1 @_Z5solveii(i32 noundef, i32 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 i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %10

10:                                               ; preds = %175, %93, %55, %47, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr %2, align 4, !tbaa !5
  %13 = icmp ne i32 %11, 0
  br i1 %13, label %14, label %176

14:                                               ; preds = %10
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @m)
  store i32 0, ptr @sum, align 4, !tbaa !5
  store i32 10000, ptr @Min, 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 %16

16:                                               ; preds = %37, %14
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %40

21:                                               ; preds = %16
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %23
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %24)
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr @sum, align 4, !tbaa !5
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr @sum, align 4, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %33
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @Min, ptr noundef nonnull align 4 dereferenceable(4) %34)
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr @Min, align 4, !tbaa !5
  br label %37

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

40:                                               ; preds = %20
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr @pill, i64 %42
  %44 = getelementptr inbounds i32, ptr %43, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @pill, i64 1), ptr noundef %44)
  %45 = load i32, ptr @m, align 4, !tbaa !5
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %40
  %48 = call i32 @puts(ptr noundef @.str.3)
  br label %10, !llvm.loop !11

49:                                               ; preds = %40
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp eq i32 %50, 1
  br i1 %51, label %55, label %52

52:                                               ; preds = %49
  %53 = load i32, ptr @m, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %57

55:                                               ; preds = %52, %49
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %10, !llvm.loop !11

57:                                               ; preds = %52
  %58 = load i32, ptr @m, align 4, !tbaa !5
  %59 = load i32, ptr @m, align 4, !tbaa !5
  %60 = load i32, ptr @m, align 4, !tbaa !5
  %61 = sub nsw i32 %60, 1
  %62 = mul nsw i32 %59, %61
  %63 = sdiv i32 %62, 2
  %64 = icmp sgt i32 %58, %63
  br i1 %64, label %65, label %73

65:                                               ; preds = %57
  %66 = load i32, ptr @m, align 4, !tbaa !5
  %67 = load i32, ptr @m, align 4, !tbaa !5
  %68 = load i32, ptr @m, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = mul nsw i32 %67, %69
  %71 = sdiv i32 %70, 2
  %72 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %66, i32 noundef %71)
  br label %81

73:                                               ; preds = %57
  %74 = load i32, ptr @m, align 4, !tbaa !5
  %75 = load i32, ptr @m, align 4, !tbaa !5
  %76 = sub nsw i32 %75, 1
  %77 = mul nsw i32 %74, %76
  %78 = sdiv i32 %77, 2
  %79 = load i32, ptr @m, align 4, !tbaa !5
  %80 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %78, i32 noundef %79)
  br label %81

81:                                               ; preds = %73, %65
  %82 = phi i32 [ %72, %65 ], [ %80, %73 ]
  store i32 %82, ptr %3, align 4, !tbaa !5
  %83 = load i32, ptr @sum, align 4, !tbaa !5
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = srem i32 %83, %84
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %93, label %87

87:                                               ; preds = %81
  %88 = load i32, ptr @sum, align 4, !tbaa !5
  %89 = mul nsw i32 2, %88
  %90 = load i32, ptr @m, align 4, !tbaa !5
  %91 = srem i32 %89, %90
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %95

93:                                               ; preds = %87, %81
  %94 = call i32 @puts(ptr noundef @.str.3)
  br label %10, !llvm.loop !11

95:                                               ; preds = %87
  store i32 -1, ptr @res, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %161, %95
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = load i32, ptr @sum, align 4, !tbaa !5
  %99 = mul nsw i32 2, %98
  %100 = load i32, ptr @m, align 4, !tbaa !5
  %101 = sdiv i32 %99, %100
  %102 = sub nsw i32 %101, 2
  %103 = icmp sle i32 %97, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %96
  store i32 7, ptr %6, align 4
  br label %166

105:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = load i32, ptr @m, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 1
  %109 = sdiv i32 %106, %108
  store i32 %109, ptr %7, align 4, !tbaa !5
  %110 = load i32, ptr @sum, align 4, !tbaa !5
  %111 = load i32, ptr @m, align 4, !tbaa !5
  %112 = load i32, ptr @m, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 1
  %114 = mul nsw i32 %111, %113
  %115 = sdiv i32 %114, 2
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = mul nsw i32 %115, %116
  %118 = sub nsw i32 %110, %117
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %120 = srem i32 %118, %119
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %123

122:                                              ; preds = %105
  store i32 9, ptr %6, align 4
  br label %158

123:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %124 = load i32, ptr @sum, align 4, !tbaa !5
  %125 = load i32, ptr @m, align 4, !tbaa !5
  %126 = load i32, ptr @m, align 4, !tbaa !5
  %127 = sub nsw i32 %126, 1
  %128 = mul nsw i32 %125, %127
  %129 = sdiv i32 %128, 2
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = mul nsw i32 %129, %130
  %132 = sub nsw i32 %124, %131
  %133 = load i32, ptr @m, align 4, !tbaa !5
  %134 = sdiv i32 %132, %133
  store i32 %134, ptr %8, align 4, !tbaa !5
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = load i32, ptr getelementptr inbounds ([23 x i32], ptr @pill, i64 0, i64 1), align 4, !tbaa !5
  %137 = icmp sge i32 %135, %136
  br i1 %137, label %138, label %156

138:                                              ; preds = %123
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = load i32, ptr @m, align 4, !tbaa !5
  %141 = sub nsw i32 %140, 1
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = mul nsw i32 %141, %142
  %144 = add nsw i32 %139, %143
  %145 = load i32, ptr @n, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = icmp sge i32 %144, %148
  br i1 %149, label %150, label %156

150:                                              ; preds = %138
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = call noundef zeroext i1 @_Z5solveii(i32 noundef %151, i32 noundef %152)
  br i1 %153, label %154, label %156

154:                                              ; preds = %150
  %155 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %155, ptr @res, align 4, !tbaa !5
  store i32 7, ptr %6, align 4
  br label %157

156:                                              ; preds = %150, %138, %123
  store i32 0, ptr %6, align 4
  br label %157

157:                                              ; preds = %156, %154
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %158

158:                                              ; preds = %157, %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  %159 = load i32, ptr %6, align 4
  switch i32 %159, label %166 [
    i32 0, label %160
    i32 9, label %161
  ]

160:                                              ; preds = %158
  br label %161

161:                                              ; preds = %160, %158
  %162 = load i32, ptr @m, align 4, !tbaa !5
  %163 = sub nsw i32 %162, 1
  %164 = load i32, ptr %5, align 4, !tbaa !5
  %165 = add nsw i32 %164, %163
  store i32 %165, ptr %5, align 4, !tbaa !5
  br label %96, !llvm.loop !12

166:                                              ; preds = %158, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr @res, align 4, !tbaa !5
  %169 = icmp eq i32 %168, -1
  br i1 %169, label %170, label %172

170:                                              ; preds = %167
  %171 = call i32 @puts(ptr noundef @.str.3)
  br label %175

172:                                              ; preds = %167
  %173 = load i32, ptr @res, align 4, !tbaa !5
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %173)
  br label %175

175:                                              ; preds = %172, %170
  br label %10, !llvm.loop !11

176:                                              ; preds = %10
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %177 = load i32, ptr %1, align 4
  ret i32 %177
}

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

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

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

declare i32 @puts(ptr noundef) #3

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

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

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 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 #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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@sum = external dso_local local_unnamed_addr global i32, align 4
@Min = external dso_local global i32, align 4
@res = external dso_local local_unnamed_addr global i32, align 4
@pill = external dso_local global [23 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: mustprogress 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 zeroext i1 @_Z5solveii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr %1, align 4, !tbaa !5
  %.not44 = icmp eq i32 %3, 0
  br i1 %.not44, label %._crit_edge47, label %.lr.ph46

.lr.ph46:                                         ; preds = %0, %.backedge
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @m)
  store i32 0, ptr @sum, align 4, !tbaa !5
  store i32 10000, ptr @Min, align 4, !tbaa !5
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not2838 = icmp slt i32 %6, 1
  br i1 %.not2838, label %.lr.ph46.._crit_edge_crit_edge, label %.lr.ph

.lr.ph46.._crit_edge_crit_edge:                   ; preds = %.lr.ph46
  %.pre55 = sext i32 %6 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph46.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre55, %.lr.ph46.._crit_edge_crit_edge ], [ %17, %.lr.ph ]
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @pill, i64 4), i64 %.pre-phi
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @pill, i64 4), ptr noundef nonnull %gep)
  %7 = load i32, ptr @m, align 4
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %18, label %22

.lr.ph:                                           ; preds = %.lr.ph46, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph46 ]
  %9 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %indvars.iv
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = load i32, ptr @sum, align 4, !tbaa !5
  %13 = add nsw i32 %12, %11
  store i32 %13, ptr @sum, align 4, !tbaa !5
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @Min, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %15 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %15, ptr @Min, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %.not28.not = icmp slt i64 %indvars.iv, %17
  br i1 %.not28.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

18:                                               ; preds = %._crit_edge
  %19 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.backedge

.backedge:                                        ; preds = %thread-pre-split.thread, %79, %18, %26, %46
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %._crit_edge47, label %.lr.ph46, !llvm.loop !11

22:                                               ; preds = %._crit_edge
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 1
  %25 = icmp eq i32 %7, 1
  %or.cond = or i1 %25, %24
  br i1 %or.cond, label %26, label %28

26:                                               ; preds = %22
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %.backedge

28:                                               ; preds = %22
  %29 = add nsw i32 %7, -1
  %30 = mul nsw i32 %29, %7
  %31 = sdiv i32 %30, 2
  %32 = icmp sgt i32 %7, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %7, i32 noundef %31)
  br label %37

35:                                               ; preds = %28
  %36 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %31, i32 noundef %7)
  br label %37

37:                                               ; preds = %35, %33
  %38 = phi i32 [ %34, %33 ], [ %36, %35 ]
  %39 = load i32, ptr @sum, align 4, !tbaa !5
  %40 = srem i32 %39, %38
  %.not29 = icmp eq i32 %40, 0
  br i1 %.not29, label %41, label %46

41:                                               ; preds = %37
  %42 = shl nsw i32 %39, 1
  %43 = load i32, ptr @m, align 4, !tbaa !5
  %44 = srem i32 %42, %43
  %45 = sdiv i32 %42, %43
  %.not30 = icmp eq i32 %44, 0
  br i1 %.not30, label %48, label %46

46:                                               ; preds = %41, %37
  %47 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.backedge

48:                                               ; preds = %41
  store i32 -1, ptr @res, align 4, !tbaa !5
  %.not3140 = icmp slt i32 %45, 2
  br i1 %.not3140, label %thread-pre-split.thread, label %.lr.ph43

.lr.ph43:                                         ; preds = %48, %68
  %49 = phi i32 [ %69, %68 ], [ %39, %48 ]
  %50 = phi i32 [ %70, %68 ], [ %43, %48 ]
  %.02141 = phi i32 [ %72, %68 ], [ 0, %48 ]
  %51 = add nsw i32 %50, -1
  %52 = sdiv i32 %.02141, %51
  %53 = mul nsw i32 %51, %50
  %.neg = sdiv i32 %53, -2
  %.neg32 = mul i32 %52, %.neg
  %54 = add i32 %.neg32, %49
  %55 = srem i32 %54, %50
  %56 = sdiv i32 %54, %50
  %.not33 = icmp ne i32 %55, 0
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @pill, i64 4), align 4
  %.not34 = icmp slt i32 %56, %57
  %or.cond64 = select i1 %.not33, i1 true, i1 %.not34
  br i1 %or.cond64, label %68, label %58

58:                                               ; preds = %.lr.ph43
  %59 = mul nsw i32 %52, %51
  %60 = add nsw i32 %56, %59
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [23 x i32], ptr @pill, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %.not35 = icmp slt i32 %60, %64
  br i1 %.not35, label %68, label %65

65:                                               ; preds = %58
  %66 = call noundef zeroext i1 @_Z5solveii(i32 noundef %56, i32 noundef %52)
  br i1 %66, label %67, label %._crit_edge52

._crit_edge52:                                    ; preds = %65
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  %.pre53 = load i32, ptr @sum, align 4, !tbaa !5
  br label %68

67:                                               ; preds = %65
  store i32 %52, ptr @res, align 4, !tbaa !5
  br label %thread-pre-split

68:                                               ; preds = %._crit_edge52, %.lr.ph43, %58
  %69 = phi i32 [ %.pre53, %._crit_edge52 ], [ %49, %.lr.ph43 ], [ %49, %58 ]
  %70 = phi i32 [ %.pre, %._crit_edge52 ], [ %50, %.lr.ph43 ], [ %50, %58 ]
  %71 = add i32 %.02141, -1
  %72 = add i32 %71, %70
  %73 = shl nsw i32 %69, 1
  %74 = sdiv i32 %73, %70
  %75 = add nsw i32 %74, -2
  %.not31 = icmp sgt i32 %72, %75
  br i1 %.not31, label %thread-pre-split.loopexit, label %.lr.ph43, !llvm.loop !12

thread-pre-split.loopexit:                        ; preds = %68
  %.pr.pre = load i32, ptr @res, align 4, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %thread-pre-split.loopexit, %67
  %76 = phi i32 [ %52, %67 ], [ %.pr.pre, %thread-pre-split.loopexit ]
  %77 = icmp eq i32 %76, -1
  br i1 %77, label %thread-pre-split.thread, label %79

thread-pre-split.thread:                          ; preds = %48, %thread-pre-split
  %78 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.backedge

79:                                               ; preds = %thread-pre-split
  %80 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %76)
  br label %.backedge

._crit_edge47:                                    ; preds = %.backedge, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0
}

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

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

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

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

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

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

attributes #0 = { mustprogress 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 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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