; LLVM IR from tangjz/acm-icpc :: 51nod (1263)

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

@tot = external dso_local global i32, align 4
@pr = external dso_local global [32000 x i32], align 16
@dr = external dso_local global [32000 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 [6 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 nounwind uwtable
declare dso_local void @_Z13decompositioniRiPi(i32 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef) #1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca [35 x i32], align 16
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %70, %0
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 32000
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %73

21:                                               ; preds = %17
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %36, label %27

27:                                               ; preds = %21
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %30
  store i32 %28, ptr %31, align 4, !tbaa !5
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr @tot, align 4, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %34
  store i32 %28, ptr %35, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %27, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  br label %37

37:                                               ; preds = %65, %36
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = mul nsw i32 %38, %42
  store i32 %43, ptr %5, align 4, !tbaa !5
  %44 = icmp slt i32 %43, 32000
  br i1 %44, label %46, label %45

45:                                               ; preds = %37
  store i32 5, ptr %3, align 4
  br label %68

46:                                               ; preds = %37
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %52
  store i32 %50, ptr %53, align 4, !tbaa !5
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp eq i32 %57, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %46
  store i32 5, ptr %3, align 4
  br label %68

64:                                               ; preds = %46
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %4, align 4, !tbaa !5
  br label %37, !llvm.loop !9

68:                                               ; preds = %63, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !11

73:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  br label %75

75:                                               ; preds = %157, %73
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr %6, align 4, !tbaa !5
  %78 = icmp ne i32 %76, 0
  br i1 %78, label %79, label %160

79:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 1, ptr %10, align 8, !tbaa !12
  %80 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %7, ptr noundef %8, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 140, ptr %12) #6
  %81 = load i32, ptr %9, align 4, !tbaa !5
  %82 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 0
  call void @_Z13decompositioniRiPi(i32 noundef %81, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef %82)
  %83 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 0
  %84 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 0
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i32, ptr %84, i64 %86
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef %83, ptr noundef %87)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  br label %88

88:                                               ; preds = %154, %79
  %89 = load i32, ptr %13, align 4, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %88
  store i32 10, ptr %3, align 4
  br label %156

93:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %94 = load i32, ptr %13, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  store i32 %97, ptr %15, align 4, !tbaa !5
  %98 = load i32, ptr %13, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %14, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %117, %93
  %101 = load i32, ptr %14, align 4, !tbaa !5
  %102 = load i32, ptr %11, align 4, !tbaa !5
  %103 = icmp slt i32 %101, %102
  br i1 %103, label %104, label %114

104:                                              ; preds = %100
  %105 = load i32, ptr %13, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = load i32, ptr %14, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = icmp eq i32 %108, %112
  br label %114

114:                                              ; preds = %104, %100
  %115 = phi i1 [ false, %100 ], [ %113, %104 ]
  br i1 %115, label %116, label %126

116:                                              ; preds = %114
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %14, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %14, align 4, !tbaa !5
  %120 = load i32, ptr %13, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = load i32, ptr %15, align 4, !tbaa !5
  %125 = mul nsw i32 %124, %123
  store i32 %125, ptr %15, align 4, !tbaa !5
  br label %100, !llvm.loop !14

126:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr %15, align 4, !tbaa !5
  %129 = srem i32 %127, %128
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = load i32, ptr %15, align 4, !tbaa !5
  %132 = srem i32 %130, %131
  %133 = load i32, ptr %13, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [35 x i32], ptr %12, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = load i32, ptr %15, align 4, !tbaa !5
  %138 = call noundef i64 @_Z5solveiiii(i32 noundef %129, i32 noundef %132, i32 noundef %136, i32 noundef %137)
  store i64 %138, ptr %16, align 8, !tbaa !12
  %139 = load i64, ptr %16, align 8, !tbaa !12
  %140 = icmp ne i64 %139, -1
  br i1 %140, label %141, label %149

141:                                              ; preds = %126
  %142 = load i64, ptr %10, align 8, !tbaa !12
  %143 = load i64, ptr %10, align 8, !tbaa !12
  %144 = load i64, ptr %16, align 8, !tbaa !12
  %145 = call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %143, i64 noundef %144)
  %146 = sdiv i64 %142, %145
  %147 = load i64, ptr %16, align 8, !tbaa !12
  %148 = mul nsw i64 %146, %147
  store i64 %148, ptr %10, align 8, !tbaa !12
  br label %150

149:                                              ; preds = %126
  store i64 -1, ptr %10, align 8, !tbaa !12
  store i32 10, ptr %3, align 4
  br label %151

150:                                              ; preds = %141
  store i32 0, ptr %3, align 4
  br label %151

151:                                              ; preds = %150, %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  %152 = load i32, ptr %3, align 4
  switch i32 %152, label %156 [
    i32 0, label %153
  ]

153:                                              ; preds = %151
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %155, ptr %13, align 4, !tbaa !5
  br label %88, !llvm.loop !15

156:                                              ; preds = %151, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %157

157:                                              ; preds = %156
  %158 = load i64, ptr %10, align 8, !tbaa !12
  %159 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %158)
  call void @llvm.lifetime.end.p0(i64 140, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %75, !llvm.loop !16

160:                                              ; preds = %75
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  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 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %161 = load i32, ptr %1, align 4
  ret i32 %161
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef, i64 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 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 #5 = { "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 = !{!"long long", !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"

@tot = external dso_local local_unnamed_addr global i32, align 4
@pr = external dso_local local_unnamed_addr global [32000 x i32], align 16
@dr = external dso_local local_unnamed_addr global [32000 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 [6 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 nounwind uwtable
declare dso_local void @_Z13decompositioniRiPi(i32 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5solveiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) 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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %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 [35 x i32], align 16
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %11

7:                                                ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr %1, align 4, !tbaa !5
  %.not64 = icmp eq i32 %9, 0
  br i1 %.not64, label %._crit_edge67, label %.lr.ph66

11:                                               ; preds = %0, %._crit_edge
  %indvars.iv69 = phi i64 [ 2, %0 ], [ %indvars.iv.next70, %._crit_edge ]
  %12 = phi i32 [ %tot.promoted, %0 ], [ %20, %._crit_edge ]
  %13 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %indvars.iv69
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %.not44 = icmp eq i32 %14, 0
  %15 = trunc nuw nsw i64 %indvars.iv69 to i32
  br i1 %.not44, label %16, label %._crit_edge76

16:                                               ; preds = %11
  store i32 %15, ptr %13, align 4, !tbaa !5
  %17 = add nsw i32 %12, 1
  store i32 %17, ptr @tot, align 4, !tbaa !5
  %18 = sext i32 %12 to i64
  %19 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %18
  store i32 %15, ptr %19, align 4, !tbaa !5
  br label %._crit_edge76

._crit_edge76:                                    ; preds = %11, %16
  %20 = phi i32 [ %17, %16 ], [ %12, %11 ]
  %21 = load i32, ptr @pr, align 16, !tbaa !5
  %22 = mul nsw i32 %21, %15
  %23 = icmp slt i32 %22, 32000
  br i1 %23, label %.lr.ph, label %._crit_edge

24:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = getelementptr inbounds [32000 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = mul nsw i32 %26, %15
  %28 = icmp slt i32 %27, 32000
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph:                                           ; preds = %._crit_edge76, %24
  %indvars.iv = phi i64 [ %indvars.iv.next, %24 ], [ 0, %._crit_edge76 ]
  %29 = phi i32 [ %27, %24 ], [ %22, %._crit_edge76 ]
  %30 = phi i32 [ %26, %24 ], [ %21, %._crit_edge76 ]
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [32000 x i32], ptr @dr, i64 0, i64 %31
  store i32 %30, ptr %32, align 4, !tbaa !5
  %33 = load i32, ptr %13, align 4, !tbaa !5
  %34 = icmp eq i32 %33, %30
  br i1 %34, label %._crit_edge, label %24

._crit_edge:                                      ; preds = %24, %.lr.ph, %._crit_edge76
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next70, 32000
  br i1 %exitcond.not, label %7, label %11, !llvm.loop !11

.lr.ph66:                                         ; preds = %7, %.thread
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 140, ptr nonnull %6) #6
  %36 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z13decompositioniRiPi(i32 noundef %36, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull %6)
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %6, i64 %38
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull %6, ptr noundef nonnull %39)
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %.lr.ph61, label %.thread

.lr.ph61:                                         ; preds = %.lr.ph66, %60
  %42 = phi i32 [ %64, %60 ], [ %40, %.lr.ph66 ]
  %.03559 = phi i32 [ %.034.lcssa, %60 ], [ 0, %.lr.ph66 ]
  %.03658 = phi i64 [ %63, %60 ], [ 1, %.lr.ph66 ]
  %43 = sext i32 %.03559 to i64
  %44 = getelementptr inbounds [35 x i32], ptr %6, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %.03449 = add nsw i32 %.03559, 1
  %46 = icmp slt i32 %.03449, %42
  br i1 %46, label %.lr.ph53.preheader, label %.critedge

.lr.ph53.preheader:                               ; preds = %.lr.ph61
  %47 = add nsw i64 %43, 1
  %48 = sext i32 %42 to i64
  br label %.lr.ph53

.lr.ph53:                                         ; preds = %.lr.ph53.preheader, %52
  %indvars.iv72 = phi i64 [ %47, %.lr.ph53.preheader ], [ %indvars.iv.next73, %52 ]
  %.050 = phi i32 [ %45, %.lr.ph53.preheader ], [ %53, %52 ]
  %49 = getelementptr inbounds [35 x i32], ptr %6, i64 0, i64 %indvars.iv72
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = icmp eq i32 %45, %50
  br i1 %51, label %52, label %.critedge.loopexit.split.loop.exit77

52:                                               ; preds = %.lr.ph53
  %53 = mul nsw i32 %.050, %45
  %indvars.iv.next73 = add nsw i64 %indvars.iv72, 1
  %exitcond75.not = icmp eq i64 %indvars.iv.next73, %48
  br i1 %exitcond75.not, label %.critedge, label %.lr.ph53, !llvm.loop !12

.critedge.loopexit.split.loop.exit77:             ; preds = %.lr.ph53
  %54 = trunc nsw i64 %indvars.iv72 to i32
  br label %.critedge

.critedge:                                        ; preds = %52, %.critedge.loopexit.split.loop.exit77, %.lr.ph61
  %.0.lcssa = phi i32 [ %45, %.lr.ph61 ], [ %.050, %.critedge.loopexit.split.loop.exit77 ], [ %53, %52 ]
  %.034.lcssa = phi i32 [ %.03449, %.lr.ph61 ], [ %54, %.critedge.loopexit.split.loop.exit77 ], [ %42, %52 ]
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = srem i32 %55, %.0.lcssa
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = srem i32 %57, %.0.lcssa
  %59 = call noundef i64 @_Z5solveiiii(i32 noundef %56, i32 noundef %58, i32 noundef %45, i32 noundef %.0.lcssa)
  %.not43.not = icmp eq i64 %59, -1
  br i1 %.not43.not, label %.thread, label %60

60:                                               ; preds = %.critedge
  %61 = call noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef %.03658, i64 noundef %59)
  %62 = sdiv i64 %.03658, %61
  %63 = mul nsw i64 %62, %59
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = icmp slt i32 %.034.lcssa, %64
  br i1 %65, label %.lr.ph61, label %.thread, !llvm.loop !13

.thread:                                          ; preds = %60, %.critedge, %.lr.ph66
  %.2 = phi i64 [ 1, %.lr.ph66 ], [ -1, %.critedge ], [ %63, %60 ]
  %66 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.2)
  call void @llvm.lifetime.end.p0(i64 140, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %67, 0
  br i1 %.not, label %._crit_edge67, label %.lr.ph66, !llvm.loop !14

._crit_edge67:                                    ; preds = %.thread, %7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt5__gcdIxET_S0_S0_(i64 noundef, i64 noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 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 #5 = { 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 #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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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