; LLVM IR from ADJA/algos :: Graphs (MSTPrim)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@e = external dso_local global [1050 x [1050 x i64]], align 16
@dist = external dso_local global [1050 x i64], align 16
@used = external dso_local global [1050 x i8], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %15

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

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

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

21:                                               ; preds = %33, %20
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %36

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %28
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1050 x i64], ptr %29, i64 0, i64 %31
  store i64 1000000000000, ptr %32, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %26
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !11

36:                                               ; preds = %25
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !13

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

41:                                               ; preds = %62, %40
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr @m, align 4, !tbaa !5
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %51
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1050 x i64], ptr %52, i64 0, i64 %54
  store i64 %49, ptr %55, align 8, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1050 x i64], ptr %58, i64 0, i64 %60
  store i64 %49, ptr %61, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %62

62:                                               ; preds = %46
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !5
  br label %41, !llvm.loop !14

65:                                               ; preds = %45
  store i64 0, ptr getelementptr inbounds ([1050 x i64], ptr @dist, i64 0, i64 1), align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %75, %65
  %67 = load i32, ptr %9, 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
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %78

71:                                               ; preds = %66
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %73
  store i64 1000000000000, ptr %74, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %71
  %76 = load i32, ptr %9, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %9, align 4, !tbaa !5
  br label %66, !llvm.loop !15

78:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %166, %78
  %80 = load i32, ptr %10, align 4, !tbaa !5
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = icmp sle i32 %80, %81
  br i1 %82, label %84, label %83

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

84:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 -1, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %112, %84
  %86 = load i32, ptr %12, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %115

90:                                               ; preds = %85
  %91 = load i32, ptr %12, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %92
  %94 = load i8, ptr %93, align 1, !tbaa !16, !range !18, !noundef !19
  %95 = trunc i8 %94 to i1
  br i1 %95, label %111, label %96

96:                                               ; preds = %90
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = icmp eq i32 %97, -1
  br i1 %98, label %109, label %99

99:                                               ; preds = %96
  %100 = load i32, ptr %12, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !9
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = icmp slt i64 %103, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %99, %96
  %110 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %110, ptr %11, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %109, %99, %90
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %12, align 4, !tbaa !5
  br label %85, !llvm.loop !20

115:                                              ; preds = %89
  %116 = load i32, ptr %11, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %117
  store i8 1, ptr %118, align 1, !tbaa !16
  %119 = load i32, ptr %11, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %120
  %122 = load i64, ptr %121, align 8, !tbaa !9
  %123 = load i64, ptr @ans, align 8, !tbaa !9
  %124 = add nsw i64 %123, %122
  store i64 %124, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %162, %115
  %126 = load i32, ptr %13, align 4, !tbaa !5
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = icmp sle i32 %126, %127
  br i1 %128, label %130, label %129

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

130:                                              ; preds = %125
  %131 = load i32, ptr %13, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %132
  %134 = load i8, ptr %133, align 1, !tbaa !16, !range !18, !noundef !19
  %135 = trunc i8 %134 to i1
  br i1 %135, label %136, label %137

136:                                              ; preds = %130
  br label %162

137:                                              ; preds = %130
  %138 = load i32, ptr %13, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = load i32, ptr %11, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %143
  %145 = load i32, ptr %13, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1050 x i64], ptr %144, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !9
  %149 = icmp sgt i64 %141, %148
  br i1 %149, label %150, label %161

150:                                              ; preds = %137
  %151 = load i32, ptr %11, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %152
  %154 = load i32, ptr %13, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [1050 x i64], ptr %153, i64 0, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !9
  %158 = load i32, ptr %13, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %159
  store i64 %157, ptr %160, align 8, !tbaa !9
  br label %161

161:                                              ; preds = %150, %137
  br label %162

162:                                              ; preds = %161, %136
  %163 = load i32, ptr %13, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %13, align 4, !tbaa !5
  br label %125, !llvm.loop !21

165:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %10, align 4, !tbaa !5
  br label %79, !llvm.loop !22

169:                                              ; preds = %83
  %170 = load i64, ptr @ans, align 8, !tbaa !9
  %171 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %170)
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %171, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@e = external dso_local local_unnamed_addr global [1050 x [1050 x i64]], align 16
@dist = external dso_local local_unnamed_addr global [1050 x i64], align 16
@used = external dso_local local_unnamed_addr global [1050 x i8], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not50 = icmp slt i32 %5, 1
  br i1 %.not50, label %.preheader46, label %.preheader47.preheader

.preheader47.preheader:                           ; preds = %0
  %6 = add nuw i32 %5, 1
  %wide.trip.count78 = zext i32 %6 to i64
  %7 = zext nneg i32 %5 to i64
  %min.iters.check = icmp ult i32 %5, 4
  %n.vec = and i64 %7, 2147483644
  %ind.end = or disjoint i64 %n.vec, 1
  %cmp.n = icmp eq i64 %n.vec, %7
  br label %.preheader47

.preheader47:                                     ; preds = %.preheader47.preheader, %._crit_edge
  %indvars.iv75 = phi i64 [ 1, %.preheader47.preheader ], [ %indvars.iv.next76, %._crit_edge ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader47
  %indvars.iv.ph = phi i64 [ 1, %.preheader47 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.body:                                      ; preds = %.preheader47, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader47 ]
  %offset.idx = or disjoint i64 %index, 1
  %8 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %indvars.iv75, i64 %offset.idx
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x i64> <i64 1000000000000, i64 1000000000000>, ptr %8, align 8, !tbaa !9
  store <2 x i64> <i64 1000000000000, i64 1000000000000>, ptr %9, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %10 = icmp eq i64 %index.next, %n.vec
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

.preheader46:                                     ; preds = %._crit_edge, %0
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %.not3952 = icmp slt i32 %11, 1
  br i1 %.not3952, label %._crit_edge54, label %.lr.ph

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond79.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count78
  br i1 %exitcond79.not, label %.preheader46, label %.preheader47, !llvm.loop !15

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %12 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %indvars.iv75, i64 %indvars.iv
  store i64 1000000000000, ptr %12, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count78
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !16

._crit_edge54.loopexit:                           ; preds = %.lr.ph
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge54

._crit_edge54:                                    ; preds = %._crit_edge54.loopexit, %.preheader46
  %13 = phi i32 [ %.pre, %._crit_edge54.loopexit ], [ %5, %.preheader46 ]
  store i64 0, ptr getelementptr inbounds (i8, ptr @dist, i64 8), align 8, !tbaa !9
  %.not4055 = icmp slt i32 %13, 2
  br i1 %.not4055, label %.preheader45, label %.lr.ph58.preheader

.lr.ph58.preheader:                               ; preds = %._crit_edge54
  %14 = add nuw i32 %13, 1
  %wide.trip.count83 = zext i32 %14 to i64
  %15 = add nsw i64 %wide.trip.count83, -2
  %min.iters.check99 = icmp ult i64 %15, 4
  br i1 %min.iters.check99, label %.lr.ph58.preheader110, label %vector.ph100

.lr.ph58.preheader110:                            ; preds = %middle.block97, %.lr.ph58.preheader
  %indvars.iv80.ph = phi i64 [ 2, %.lr.ph58.preheader ], [ %ind.end103, %middle.block97 ]
  br label %.lr.ph58

vector.ph100:                                     ; preds = %.lr.ph58.preheader
  %n.vec102 = and i64 %15, -4
  %ind.end103 = or disjoint i64 %n.vec102, 2
  br label %vector.body105

vector.body105:                                   ; preds = %vector.body105, %vector.ph100
  %index106 = phi i64 [ 0, %vector.ph100 ], [ %index.next108, %vector.body105 ]
  %offset.idx107 = or disjoint i64 %index106, 2
  %16 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %offset.idx107
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store <2 x i64> <i64 1000000000000, i64 1000000000000>, ptr %16, align 16, !tbaa !9
  store <2 x i64> <i64 1000000000000, i64 1000000000000>, ptr %17, align 16, !tbaa !9
  %index.next108 = add nuw i64 %index106, 4
  %18 = icmp eq i64 %index.next108, %n.vec102
  br i1 %18, label %middle.block97, label %vector.body105, !llvm.loop !17

middle.block97:                                   ; preds = %vector.body105
  %cmp.n109 = icmp eq i64 %15, %n.vec102
  br i1 %cmp.n109, label %.preheader45, label %.lr.ph58.preheader110

.lr.ph:                                           ; preds = %.preheader46, %.lr.ph
  %.03553 = phi i32 [ %28, %.lr.ph ], [ 1, %.preheader46 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %23, i64 %25
  store i64 %21, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %25, i64 %23
  store i64 %21, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %28 = add nuw nsw i32 %.03553, 1
  %29 = load i32, ptr @m, align 4, !tbaa !5
  %.not39.not = icmp slt i32 %.03553, %29
  br i1 %.not39.not, label %.lr.ph, label %._crit_edge54.loopexit, !llvm.loop !18

.preheader45:                                     ; preds = %.lr.ph58, %middle.block97, %._crit_edge54
  %.not4170 = icmp slt i32 %13, 1
  %.pre96 = load i64, ptr @ans, align 8, !tbaa !9
  br i1 %.not4170, label %.preheader45._crit_edge, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader45
  %30 = zext nneg i32 %13 to i64
  %31 = zext nneg i32 %13 to i64
  %32 = add nsw i64 %31, -1
  %xtraiter = and i64 %30, 1
  %33 = icmp eq i64 %32, 0
  %unroll_iter = and i64 %30, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %xtraiter112 = and i64 %30, 1
  %34 = icmp eq i64 %32, 0
  %unroll_iter114 = and i64 %30, 2147483646
  %lcmp.mod113.not = icmp eq i64 %xtraiter112, 0
  br label %.lr.ph62.preheader

.lr.ph58:                                         ; preds = %.lr.ph58.preheader110, %.lr.ph58
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %.lr.ph58 ], [ %indvars.iv80.ph, %.lr.ph58.preheader110 ]
  %35 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv80
  store i64 1000000000000, ptr %35, align 8, !tbaa !9
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %exitcond84.not = icmp eq i64 %indvars.iv.next81, %wide.trip.count83
  br i1 %exitcond84.not, label %.preheader45, label %.lr.ph58, !llvm.loop !19

.lr.ph62.preheader:                               ; preds = %._crit_edge69, %.preheader.lr.ph
  %.03371 = phi i32 [ 1, %.preheader.lr.ph ], [ %98, %._crit_edge69 ]
  %36 = phi i64 [ %.pre96, %.preheader.lr.ph ], [ %58, %._crit_edge69 ]
  br i1 %33, label %.lr.ph68.preheader.unr-lcssa, label %.lr.ph62

._crit_edge72:                                    ; preds = %._crit_edge69
  store i64 %58, ptr @ans, align 8, !tbaa !9
  br label %.preheader45._crit_edge

.preheader45._crit_edge:                          ; preds = %.preheader45, %._crit_edge72
  %37 = phi i64 [ %58, %._crit_edge72 ], [ %.pre96, %.preheader45 ]
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %37)
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph68.preheader.unr-lcssa:                     ; preds = %87, %.lr.ph62.preheader
  %.1.lcssa.ph = phi i32 [ poison, %.lr.ph62.preheader ], [ %.1.1, %87 ]
  %indvars.iv85.unr = phi i64 [ 1, %.lr.ph62.preheader ], [ %indvars.iv.next86.1, %87 ]
  %.03260.unr = phi i32 [ -1, %.lr.ph62.preheader ], [ %.1.1, %87 ]
  br i1 %lcmp.mod.not, label %.lr.ph68.preheader, label %.lr.ph62.epil

.lr.ph62.epil:                                    ; preds = %.lr.ph68.preheader.unr-lcssa
  %40 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv85.unr
  %41 = load i8, ptr %40, align 1, !tbaa !20, !range !22, !noundef !23
  %42 = trunc nuw i8 %41 to i1
  br i1 %42, label %.lr.ph68.preheader, label %43

43:                                               ; preds = %.lr.ph62.epil
  %44 = icmp eq i32 %.03260.unr, -1
  br i1 %44, label %52, label %45

45:                                               ; preds = %43
  %46 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv85.unr
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = sext i32 %.03260.unr to i64
  %49 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = icmp slt i64 %47, %50
  br i1 %51, label %52, label %.lr.ph68.preheader

52:                                               ; preds = %45, %43
  %53 = trunc nuw nsw i64 %indvars.iv85.unr to i32
  br label %.lr.ph68.preheader

.lr.ph68.preheader:                               ; preds = %.lr.ph62.epil, %45, %52, %.lr.ph68.preheader.unr-lcssa
  %.1.lcssa = phi i32 [ %.1.lcssa.ph, %.lr.ph68.preheader.unr-lcssa ], [ %.03260.unr, %.lr.ph62.epil ], [ %53, %52 ], [ %.03260.unr, %45 ]
  %54 = sext i32 %.1.lcssa to i64
  %55 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %54
  store i8 1, ptr %55, align 1, !tbaa !20
  %56 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %54
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = add nsw i64 %36, %57
  br i1 %34, label %._crit_edge69.unr-lcssa, label %.lr.ph68

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %87
  %indvars.iv85 = phi i64 [ %indvars.iv.next86.1, %87 ], [ 1, %.lr.ph62.preheader ]
  %.03260 = phi i32 [ %.1.1, %87 ], [ -1, %.lr.ph62.preheader ]
  %niter = phi i64 [ %niter.next.1, %87 ], [ 0, %.lr.ph62.preheader ]
  %59 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv85
  %60 = load i8, ptr %59, align 1, !tbaa !20, !range !22, !noundef !23
  %61 = trunc nuw i8 %60 to i1
  br i1 %61, label %.lr.ph62.1, label %62

62:                                               ; preds = %.lr.ph62
  %63 = icmp eq i32 %.03260, -1
  br i1 %63, label %71, label %64

64:                                               ; preds = %62
  %65 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv85
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = sext i32 %.03260 to i64
  %68 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = icmp slt i64 %66, %69
  br i1 %70, label %71, label %.lr.ph62.1

71:                                               ; preds = %64, %62
  %72 = trunc nuw nsw i64 %indvars.iv85 to i32
  br label %.lr.ph62.1

.lr.ph62.1:                                       ; preds = %.lr.ph62, %64, %71
  %.1 = phi i32 [ %.03260, %.lr.ph62 ], [ %72, %71 ], [ %.03260, %64 ]
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %73 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv.next86
  %74 = load i8, ptr %73, align 1, !tbaa !20, !range !22, !noundef !23
  %75 = trunc nuw i8 %74 to i1
  br i1 %75, label %87, label %76

76:                                               ; preds = %.lr.ph62.1
  %77 = icmp eq i32 %.1, -1
  br i1 %77, label %85, label %78

78:                                               ; preds = %76
  %79 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv.next86
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %81 = sext i32 %.1 to i64
  %82 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !9
  %84 = icmp slt i64 %80, %83
  br i1 %84, label %85, label %87

85:                                               ; preds = %78, %76
  %86 = trunc nuw nsw i64 %indvars.iv.next86 to i32
  br label %87

87:                                               ; preds = %85, %78, %.lr.ph62.1
  %.1.1 = phi i32 [ %.1, %.lr.ph62.1 ], [ %86, %85 ], [ %.1, %78 ]
  %indvars.iv.next86.1 = add nuw nsw i64 %indvars.iv85, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.lr.ph68.preheader.unr-lcssa, label %.lr.ph62, !llvm.loop !24

._crit_edge69.unr-lcssa:                          ; preds = %119, %.lr.ph68.preheader
  %indvars.iv90.unr = phi i64 [ 1, %.lr.ph68.preheader ], [ %indvars.iv.next91.1, %119 ]
  br i1 %lcmp.mod113.not, label %._crit_edge69, label %.lr.ph68.epil

.lr.ph68.epil:                                    ; preds = %._crit_edge69.unr-lcssa
  %88 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv90.unr
  %89 = load i8, ptr %88, align 1, !tbaa !20, !range !22, !noundef !23
  %90 = trunc nuw i8 %89 to i1
  br i1 %90, label %._crit_edge69, label %91

91:                                               ; preds = %.lr.ph68.epil
  %92 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv90.unr
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %54, i64 %indvars.iv90.unr
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = icmp sgt i64 %93, %95
  br i1 %96, label %97, label %._crit_edge69

97:                                               ; preds = %91
  store i64 %95, ptr %92, align 8, !tbaa !9
  br label %._crit_edge69

._crit_edge69:                                    ; preds = %.lr.ph68.epil, %91, %97, %._crit_edge69.unr-lcssa
  %98 = add nuw i32 %.03371, 1
  %exitcond95.not = icmp eq i32 %.03371, %13
  br i1 %exitcond95.not, label %._crit_edge72, label %.lr.ph62.preheader, !llvm.loop !25

.lr.ph68:                                         ; preds = %.lr.ph68.preheader, %119
  %indvars.iv90 = phi i64 [ %indvars.iv.next91.1, %119 ], [ 1, %.lr.ph68.preheader ]
  %niter115 = phi i64 [ %niter115.next.1, %119 ], [ 0, %.lr.ph68.preheader ]
  %99 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv90
  %100 = load i8, ptr %99, align 1, !tbaa !20, !range !22, !noundef !23
  %101 = trunc nuw i8 %100 to i1
  br i1 %101, label %.lr.ph68.1, label %102

102:                                              ; preds = %.lr.ph68
  %103 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv90
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %54, i64 %indvars.iv90
  %106 = load i64, ptr %105, align 8, !tbaa !9
  %107 = icmp sgt i64 %104, %106
  br i1 %107, label %108, label %.lr.ph68.1

108:                                              ; preds = %102
  store i64 %106, ptr %103, align 8, !tbaa !9
  br label %.lr.ph68.1

.lr.ph68.1:                                       ; preds = %102, %108, %.lr.ph68
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %109 = getelementptr inbounds [1050 x i8], ptr @used, i64 0, i64 %indvars.iv.next91
  %110 = load i8, ptr %109, align 1, !tbaa !20, !range !22, !noundef !23
  %111 = trunc nuw i8 %110 to i1
  br i1 %111, label %119, label %112

112:                                              ; preds = %.lr.ph68.1
  %113 = getelementptr inbounds [1050 x i64], ptr @dist, i64 0, i64 %indvars.iv.next91
  %114 = load i64, ptr %113, align 8, !tbaa !9
  %115 = getelementptr inbounds [1050 x [1050 x i64]], ptr @e, i64 0, i64 %54, i64 %indvars.iv.next91
  %116 = load i64, ptr %115, align 8, !tbaa !9
  %117 = icmp sgt i64 %114, %116
  br i1 %117, label %118, label %119

118:                                              ; preds = %112
  store i64 %116, ptr %113, align 8, !tbaa !9
  br label %119

119:                                              ; preds = %118, %112, %.lr.ph68.1
  %indvars.iv.next91.1 = add nuw nsw i64 %indvars.iv90, 2
  %niter115.next.1 = add i64 %niter115, 2
  %niter115.ncmp.1 = icmp eq i64 %niter115.next.1, %unroll_iter114
  br i1 %niter115.ncmp.1, label %._crit_edge69.unr-lcssa, label %.lr.ph68, !llvm.loop !26
}

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12, !13, !14}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !14, !13}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}


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