; LLVM IR from tangjz/acm-icpc :: TDL_training/2015-11-02 (B - Discrete Square Roots - tjz)

; 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
@prime = external dso_local global [32000 x i32], align 16
@n = external dso_local global i32, align 4
@xx = external dso_local global i32, align 4
@r0 = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@p = external dso_local global [10 x i32], align 16
@c = external dso_local global [10 x i32], align 16
@sum = external dso_local global i32, align 4
@ans = external dso_local global [4096 x i32], align 16
@vis = external dso_local global [32000 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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 void @_Z3dfsii(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
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %60, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 32000
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %63

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [32000 x i8], ptr @vis, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !9, !range !11, !noundef !12
  %19 = trunc i8 %18 to i1
  br i1 %19, label %26, label %20

20:                                               ; preds = %14
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr @tot, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %22 to i64
  %25 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %24
  store i32 %21, ptr %25, align 4, !tbaa !5
  br label %26

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

27:                                               ; preds = %55, %26
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr @tot, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %39

31:                                               ; preds = %27
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = mul nsw i32 %32, %36
  store i32 %37, ptr %5, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 32000
  br label %39

39:                                               ; preds = %31, %27
  %40 = phi i1 [ false, %27 ], [ %38, %31 ]
  br i1 %40, label %42, label %41

41:                                               ; preds = %39
  store i32 5, ptr %3, align 4
  br label %58

42:                                               ; preds = %39
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [32000 x i8], ptr @vis, i64 0, i64 %44
  store i8 1, ptr %45, align 1, !tbaa !9
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = srem i32 %46, %50
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %42
  store i32 5, ptr %3, align 4
  br label %58

54:                                               ; preds = %42
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %4, align 4, !tbaa !5
  br label %27, !llvm.loop !13

58:                                               ; preds = %53, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !15

63:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %198, %63
  %65 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @xx, ptr noundef @n, ptr noundef @r0)
  %66 = icmp eq i32 %65, 3
  br i1 %66, label %67, label %74

67:                                               ; preds = %64
  %68 = load i32, ptr @xx, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = add nsw i32 %68, %69
  %71 = load i32, ptr @r0, align 4, !tbaa !5
  %72 = add nsw i32 %70, %71
  %73 = icmp ne i32 %72, 0
  br label %74

74:                                               ; preds = %67, %64
  %75 = phi i1 [ false, %64 ], [ %73, %67 ]
  br i1 %75, label %77, label %76

76:                                               ; preds = %74
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %201

77:                                               ; preds = %74
  store i32 0, ptr @sum, align 4, !tbaa !5
  store i32 0, ptr @cnt, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %78 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %78, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %141, %77
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = load i32, ptr @tot, align 4, !tbaa !5
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %83, label %95

83:                                               ; preds = %79
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = mul nsw i32 %87, %91
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = icmp sle i32 %92, %93
  br label %95

95:                                               ; preds = %83, %79
  %96 = phi i1 [ false, %79 ], [ %94, %83 ]
  br i1 %96, label %98, label %97

97:                                               ; preds = %95
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %144

98:                                               ; preds = %95
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = srem i32 %99, %103
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %140

106:                                              ; preds = %98
  %107 = load i32, ptr @cnt, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [10 x i32], ptr @c, i64 0, i64 %108
  store i32 0, ptr %109, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %119, %106
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = srem i32 %111, %115
  %117 = icmp eq i32 %116, 0
  br i1 %117, label %118, label %131

118:                                              ; preds = %110
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sdiv i32 %124, %123
  store i32 %125, ptr %7, align 4, !tbaa !5
  %126 = load i32, ptr @cnt, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [10 x i32], ptr @c, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %128, align 4, !tbaa !5
  br label %110, !llvm.loop !16

131:                                              ; preds = %110
  %132 = load i32, ptr %8, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr @cnt, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr @cnt, align 4, !tbaa !5
  %138 = sext i32 %136 to i64
  %139 = getelementptr inbounds [10 x i32], ptr @p, i64 0, i64 %138
  store i32 %135, ptr %139, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %131, %98
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %8, align 4, !tbaa !5
  br label %79, !llvm.loop !17

144:                                              ; preds = %97
  %145 = load i32, ptr %7, align 4, !tbaa !5
  %146 = icmp sgt i32 %145, 1
  br i1 %146, label %147, label %156

147:                                              ; preds = %144
  %148 = load i32, ptr @cnt, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [10 x i32], ptr @c, i64 0, i64 %149
  store i32 1, ptr %150, align 4, !tbaa !5
  %151 = load i32, ptr %7, align 4, !tbaa !5
  %152 = load i32, ptr @cnt, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr @cnt, align 4, !tbaa !5
  %154 = sext i32 %152 to i64
  %155 = getelementptr inbounds [10 x i32], ptr @p, i64 0, i64 %154
  store i32 %151, ptr %155, align 4, !tbaa !5
  br label %156

156:                                              ; preds = %147, %144
  %157 = load i32, ptr @r0, align 4, !tbaa !5
  %158 = load i32, ptr @sum, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr @sum, align 4, !tbaa !5
  %160 = sext i32 %158 to i64
  %161 = getelementptr inbounds [4096 x i32], ptr @ans, i64 0, i64 %160
  store i32 %157, ptr %161, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  %162 = load i32, ptr @sum, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds i32, ptr @ans, i64 %163
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @ans, ptr noundef %164)
  %165 = load i32, ptr @sum, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i32, ptr @ans, i64 %166
  %168 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @ans, ptr noundef %167)
  %169 = ptrtoint ptr %168 to i64
  %170 = sub i64 %169, ptrtoint (ptr @ans to i64)
  %171 = sdiv exact i64 %170, 4
  %172 = trunc i64 %171 to i32
  store i32 %172, ptr @sum, align 4, !tbaa !5
  %173 = load i32, ptr %6, align 4, !tbaa !5
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %173)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %175

175:                                              ; preds = %194, %156
  %176 = load i32, ptr %9, align 4, !tbaa !5
  %177 = load i32, ptr @sum, align 4, !tbaa !5
  %178 = icmp slt i32 %176, %177
  br i1 %178, label %180, label %179

179:                                              ; preds = %175
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %197

180:                                              ; preds = %175
  %181 = load i32, ptr %9, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [4096 x i32], ptr @ans, i64 0, i64 %182
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = load i32, ptr %9, align 4, !tbaa !5
  %186 = load i32, ptr @sum, align 4, !tbaa !5
  %187 = sub nsw i32 %186, 1
  %188 = icmp eq i32 %185, %187
  %189 = zext i1 %188 to i64
  %190 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %189
  %191 = load i8, ptr %190, align 1, !tbaa !18
  %192 = sext i8 %191 to i32
  %193 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %184, i32 noundef %192)
  br label %194

194:                                              ; preds = %180
  %195 = load i32, ptr %9, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1
  store i32 %196, ptr %9, align 4, !tbaa !5
  br label %175, !llvm.loop !19

197:                                              ; preds = %179
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %198

198:                                              ; preds = %197
  %199 = load i32, ptr %6, align 4, !tbaa !5
  %200 = add nsw i32 %199, 1
  store i32 %200, ptr %6, align 4, !tbaa !5
  br label %64, !llvm.loop !20

201:                                              ; preds = %76
  ret i32 0
}

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

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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


; 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
@prime = external dso_local local_unnamed_addr global [32000 x i32], align 16
@n = external dso_local global i32, align 4
@xx = external dso_local global i32, align 4
@r0 = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local local_unnamed_addr global [10 x i32], align 16
@c = external dso_local local_unnamed_addr global [10 x i32], align 16
@sum = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local global [4096 x i32], align 16
@vis = external dso_local local_unnamed_addr global [32000 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %3

.preheader:                                       ; preds = %.critedge
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @xx, ptr noundef nonnull @n, ptr noundef nonnull @r0)
  %2 = icmp eq i32 %1, 3
  br i1 %2, label %.lr.ph63, label %.critedge2

3:                                                ; preds = %0, %.critedge
  %indvars.iv67 = phi i64 [ 2, %0 ], [ %indvars.iv.next68, %.critedge ]
  %4 = phi i32 [ %tot.promoted, %0 ], [ %14, %.critedge ]
  %5 = getelementptr inbounds [32000 x i8], ptr @vis, i64 0, i64 %indvars.iv67
  %6 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %13, label %8

8:                                                ; preds = %3
  %9 = add nsw i32 %4, 1
  store i32 %9, ptr @tot, align 4, !tbaa !5
  %10 = sext i32 %4 to i64
  %11 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %10
  %12 = trunc nuw nsw i64 %indvars.iv67 to i32
  store i32 %12, ptr %11, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %8, %3
  %14 = phi i32 [ %9, %8 ], [ %4, %3 ]
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %13
  %16 = zext nneg i32 %14 to i64
  %17 = trunc nuw nsw i64 %indvars.iv67 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %22 ]
  %18 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %indvars.iv
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = mul nsw i32 %19, %17
  %21 = icmp slt i32 %20, 32000
  br i1 %21, label %22, label %.critedge

22:                                               ; preds = %.lr.ph
  %23 = sext i32 %20 to i64
  %24 = getelementptr inbounds [32000 x i8], ptr @vis, i64 0, i64 %23
  store i8 1, ptr %24, align 1, !tbaa !9
  %25 = srem i32 %17, %19
  %26 = icmp ne i32 %25, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = icmp ult i64 %indvars.iv.next, %16
  %or.cond = select i1 %26, i1 %27, i1 false
  br i1 %or.cond, label %.lr.ph, label %.critedge, !llvm.loop !13

.critedge:                                        ; preds = %.lr.ph, %22, %13
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next68, 32000
  br i1 %exitcond.not, label %.preheader, label %3, !llvm.loop !15

.lr.ph63:                                         ; preds = %.preheader, %._crit_edge61
  %.03762 = phi i32 [ %75, %._crit_edge61 ], [ 1, %.preheader ]
  %28 = load i32, ptr @xx, align 4, !tbaa !5
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = add nsw i32 %29, %28
  %31 = load i32, ptr @r0, align 4, !tbaa !5
  %32 = sub i32 0, %31
  %.not = icmp eq i32 %30, %32
  br i1 %.not, label %.critedge2, label %33

.critedge2:                                       ; preds = %.lr.ph63, %._crit_edge61, %.preheader
  ret i32 0

33:                                               ; preds = %.lr.ph63
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %34 = load i32, ptr @tot, align 4, !tbaa !5
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph54.preheader, label %.critedge4

.lr.ph54.preheader:                               ; preds = %33
  %wide.trip.count = zext nneg i32 %34 to i64
  br label %.lr.ph54

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %53
  %indvars.iv70 = phi i64 [ 0, %.lr.ph54.preheader ], [ %indvars.iv.next71, %53 ]
  %.03651 = phi i32 [ %29, %.lr.ph54.preheader ], [ %.2, %53 ]
  %36 = phi i32 [ 0, %.lr.ph54.preheader ], [ %54, %53 ]
  %37 = getelementptr inbounds [32000 x i32], ptr @prime, i64 0, i64 %indvars.iv70
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = mul nsw i32 %38, %38
  %.not42 = icmp sgt i32 %39, %.03651
  br i1 %.not42, label %.critedge4, label %42

.critedge4:                                       ; preds = %.lr.ph54, %53, %33
  %40 = phi i32 [ 0, %33 ], [ %54, %53 ], [ %36, %.lr.ph54 ]
  %.036.lcssa = phi i32 [ %29, %33 ], [ %.2, %53 ], [ %.03651, %.lr.ph54 ]
  %41 = icmp sgt i32 %.036.lcssa, 1
  br i1 %41, label %55, label %60

42:                                               ; preds = %.lr.ph54
  %43 = srem i32 %.03651, %38
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %.lr.ph49.preheader, label %53

.lr.ph49.preheader:                               ; preds = %42
  %45 = sext i32 %36 to i64
  %46 = getelementptr inbounds [10 x i32], ptr @c, i64 0, i64 %45
  br label %.lr.ph49

.lr.ph49:                                         ; preds = %.lr.ph49.preheader, %.lr.ph49
  %.148 = phi i32 [ %47, %.lr.ph49 ], [ %.03651, %.lr.ph49.preheader ]
  %storemerge47 = phi i32 [ %48, %.lr.ph49 ], [ 0, %.lr.ph49.preheader ]
  %47 = sdiv i32 %.148, %38
  %48 = add nuw nsw i32 %storemerge47, 1
  %49 = srem i32 %47, %38
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %.lr.ph49, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph49
  store i32 %48, ptr %46, align 4, !tbaa !5
  %51 = add nsw i32 %36, 1
  store i32 %51, ptr @cnt, align 4, !tbaa !5
  %52 = getelementptr inbounds [10 x i32], ptr @p, i64 0, i64 %45
  store i32 %38, ptr %52, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %42, %._crit_edge
  %54 = phi i32 [ %51, %._crit_edge ], [ %36, %42 ]
  %.2 = phi i32 [ %47, %._crit_edge ], [ %.03651, %42 ]
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next71, %wide.trip.count
  br i1 %exitcond73.not, label %.critedge4, label %.lr.ph54, !llvm.loop !17

55:                                               ; preds = %.critedge4
  %56 = sext i32 %40 to i64
  %57 = getelementptr inbounds [10 x i32], ptr @c, i64 0, i64 %56
  store i32 1, ptr %57, align 4, !tbaa !5
  %58 = add nsw i32 %40, 1
  store i32 %58, ptr @cnt, align 4, !tbaa !5
  %59 = getelementptr inbounds [10 x i32], ptr @p, i64 0, i64 %56
  store i32 %.036.lcssa, ptr %59, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %55, %.critedge4
  store i32 1, ptr @sum, align 4, !tbaa !5
  store i32 %31, ptr @ans, align 16, !tbaa !5
  tail call void @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  %61 = load i32, ptr @sum, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr @ans, i64 %62
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @ans, ptr noundef nonnull %63)
  %64 = load i32, ptr @sum, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr @ans, i64 %65
  %67 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @ans, ptr noundef nonnull %66)
  %68 = ptrtoint ptr %67 to i64
  %69 = sub i64 %68, ptrtoint (ptr @ans to i64)
  %70 = lshr exact i64 %69, 2
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr @sum, align 4, !tbaa !5
  %72 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.03762)
  %73 = load i32, ptr @sum, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %.lr.ph60, label %._crit_edge61

._crit_edge61:                                    ; preds = %.lr.ph60, %60
  %75 = add nuw nsw i32 %.03762, 1
  %76 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @xx, ptr noundef nonnull @n, ptr noundef nonnull @r0)
  %77 = icmp eq i32 %76, 3
  br i1 %77, label %.lr.ph63, label %.critedge2, !llvm.loop !18

.lr.ph60:                                         ; preds = %60, %.lr.ph60
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.lr.ph60 ], [ 0, %60 ]
  %78 = phi i32 [ %89, %.lr.ph60 ], [ %73, %60 ]
  %79 = getelementptr inbounds [4096 x i32], ptr @ans, i64 0, i64 %indvars.iv74
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = add nsw i32 %78, -1
  %82 = zext i32 %81 to i64
  %83 = icmp eq i64 %indvars.iv74, %82
  %84 = zext i1 %83 to i64
  %85 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !19
  %87 = sext i8 %86 to i32
  %88 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %80, i32 noundef %87)
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %89 = load i32, ptr @sum, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = icmp slt i64 %indvars.iv.next75, %90
  br i1 %91, label %.lr.ph60, label %._crit_edge61, !llvm.loop !20
}

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

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !14}


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