; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-11 (J)

; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@k = external dso_local global i32, align 4
@a = external dso_local global [751 x i32], align 16
@b = external dso_local global [751 x i32], align 16
@c = external dso_local global [751 x i32], align 16
@id = external dso_local global [751 x i32], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; 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 %"struct.std::pair", align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::pair", align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %15

15:                                               ; preds = %160, %0
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @k)
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %161

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @k, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr @a, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %27)
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !9

32:                                               ; preds = %23
  %33 = load i32, ptr @k, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr @a, i64 %34
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @a, ptr noundef %35)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %134, %32
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr @k, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %137

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

42:                                               ; preds = %52, %41
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = load i32, ptr @k, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %55

47:                                               ; preds = %42
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr @b, i64 %49
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %50)
  br label %52

52:                                               ; preds = %47
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !5
  br label %42, !llvm.loop !11

55:                                               ; preds = %46
  %56 = load i32, ptr @k, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr @b, i64 %57
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @b, ptr noundef %58)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %75, %55
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = load i32, ptr @k, align 4, !tbaa !5
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %78

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [751 x i32], ptr @id, i64 0, i64 %70
  store i32 0, ptr %71, align 4, !tbaa !5
  %72 = load i32, ptr @b, align 16, !tbaa !5
  %73 = add nsw i32 %68, %72
  store i32 %73, ptr %8, align 4, !tbaa !5
  %74 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %6)
  store i64 %74, ptr %7, align 4
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %75

75:                                               ; preds = %64
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %6, align 4, !tbaa !5
  br label %59, !llvm.loop !12

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

79:                                               ; preds = %108, %78
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = load i32, ptr @k, align 4, !tbaa !5
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %111

84:                                               ; preds = %79
  %85 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %86 = getelementptr inbounds %"struct.std::pair", ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 4, !tbaa !13
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [751 x i32], ptr @c, i64 0, i64 %89
  store i32 %87, ptr %90, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %91 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %92 = getelementptr inbounds %"struct.std::pair", ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !15
  store i32 %93, ptr %10, align 4, !tbaa !5
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = load i32, ptr %10, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [751 x i32], ptr @id, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %100, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [751 x i32], ptr @b, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %97, %105
  store i32 %106, ptr %12, align 4, !tbaa !5
  %107 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %10)
  store i64 %107, ptr %11, align 4
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %108

108:                                              ; preds = %84
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %9, align 4, !tbaa !5
  br label %79, !llvm.loop !16

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

112:                                              ; preds = %125, %111
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = load i32, ptr @k, align 4, !tbaa !5
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %112
  store i32 19, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %128

117:                                              ; preds = %112
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [751 x i32], ptr @c, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = load i32, ptr %13, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %123
  store i32 %121, ptr %124, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %117
  %126 = load i32, ptr %13, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %13, align 4, !tbaa !5
  br label %112, !llvm.loop !17

128:                                              ; preds = %116
  br label %129

129:                                              ; preds = %132, %128
  %130 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %131 = xor i1 %130, true
  br i1 %131, label %132, label %133

132:                                              ; preds = %129
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br label %129, !llvm.loop !18

133:                                              ; preds = %129
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %3, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %3, align 4, !tbaa !5
  br label %36, !llvm.loop !19

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

138:                                              ; preds = %157, %137
  %139 = load i32, ptr %14, align 4, !tbaa !5
  %140 = load i32, ptr @k, align 4, !tbaa !5
  %141 = icmp slt i32 %139, %140
  br i1 %141, label %143, label %142

142:                                              ; preds = %138
  store i32 24, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %160

143:                                              ; preds = %138
  %144 = load i32, ptr %14, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %14, align 4, !tbaa !5
  %149 = load i32, ptr @k, align 4, !tbaa !5
  %150 = sub nsw i32 %149, 1
  %151 = icmp eq i32 %148, %150
  %152 = zext i1 %151 to i64
  %153 = getelementptr inbounds [3 x i8], ptr @.str.2, i64 0, i64 %152
  %154 = load i8, ptr %153, align 1, !tbaa !20
  %155 = sext i8 %154 to i32
  %156 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %147, i32 noundef %155)
  br label %157

157:                                              ; preds = %143
  %158 = load i32, ptr %14, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %14, align 4, !tbaa !5
  br label %138, !llvm.loop !21

160:                                              ; preds = %142
  br label %15, !llvm.loop !22

161:                                              ; preds = %15
  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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(8)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #5 align 2

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

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 = { 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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

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

%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@k = external dso_local global i32, align 4
@a = external dso_local global [751 x i32], align 16
@b = external dso_local global [751 x i32], align 16
@c = external dso_local local_unnamed_addr global [751 x i32], align 16
@id = external dso_local local_unnamed_addr global [751 x i32], align 16
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.std::pair", align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca i32, align 4
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @k)
  %.not53 = icmp eq i32 %7, -1
  br i1 %.not53, label %._crit_edge54, label %.preheader30

.loopexit:                                        ; preds = %.lr.ph52, %.preheader29
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @k)
  %.not = icmp eq i32 %8, -1
  br i1 %.not, label %._crit_edge54, label %.preheader30, !llvm.loop !5

.preheader30:                                     ; preds = %0, %.loopexit
  %9 = load i32, ptr @k, align 4, !tbaa !7
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.preheader30.._crit_edge_crit_edge

.preheader30.._crit_edge_crit_edge:               ; preds = %.preheader30
  %.pre = sext i32 %9 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader30.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader30.._crit_edge_crit_edge ], [ %17, %.lr.ph ]
  %11 = getelementptr inbounds i32, ptr @a, i64 %.pre-phi
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %11)
  %12 = load i32, ptr @k, align 4, !tbaa !7
  %13 = icmp sgt i32 %12, 1
  br i1 %13, label %.preheader28, label %.preheader29

.lr.ph:                                           ; preds = %.preheader30, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader30 ]
  %14 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @k, align 4, !tbaa !7
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader29:                                     ; preds = %._crit_edge49, %._crit_edge
  %19 = phi i32 [ %12, %._crit_edge ], [ %70, %._crit_edge49 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph52, label %.loopexit

.preheader28:                                     ; preds = %._crit_edge, %._crit_edge49
  %21 = phi i32 [ %70, %._crit_edge49 ], [ %12, %._crit_edge ]
  %.02250 = phi i32 [ %69, %._crit_edge49 ], [ 1, %._crit_edge ]
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph35, label %.preheader28.._crit_edge36_crit_edge

.preheader28.._crit_edge36_crit_edge:             ; preds = %.preheader28
  %.pre71 = sext i32 %21 to i64
  br label %._crit_edge36

._crit_edge36:                                    ; preds = %.lr.ph35, %.preheader28.._crit_edge36_crit_edge
  %.pre-phi72 = phi i64 [ %.pre71, %.preheader28.._crit_edge36_crit_edge ], [ %29, %.lr.ph35 ]
  %23 = getelementptr inbounds i32, ptr @b, i64 %.pre-phi72
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @b, ptr noundef nonnull %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr %1, align 4, !tbaa !7
  %24 = load i32, ptr @k, align 4, !tbaa !7
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph40, label %._crit_edge41.thread

._crit_edge41.thread:                             ; preds = %._crit_edge36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  br label %.preheader

.lr.ph35:                                         ; preds = %.preheader28, %.lr.ph35
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %.lr.ph35 ], [ 0, %.preheader28 ]
  %26 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv59
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %26)
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %28 = load i32, ptr @k, align 4, !tbaa !7
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next60, %29
  br i1 %30, label %.lr.ph35, label %._crit_edge36, !llvm.loop !12

._crit_edge41:                                    ; preds = %.lr.ph40
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %31 = icmp sgt i32 %41, 0
  br i1 %31, label %.lr.ph44, label %.preheader

.lr.ph40:                                         ; preds = %._crit_edge36, %.lr.ph40
  %storemerge38 = phi i32 [ %40, %.lr.ph40 ], [ 0, %._crit_edge36 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %32 = sext i32 %storemerge38 to i64
  %33 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !7
  %35 = getelementptr inbounds [751 x i32], ptr @id, i64 0, i64 %32
  store i32 0, ptr %35, align 4, !tbaa !7
  %36 = load i32, ptr @b, align 16, !tbaa !7
  %37 = add nsw i32 %36, %34
  store i32 %37, ptr %3, align 4, !tbaa !7
  %38 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %1)
  store i64 %38, ptr %2, align 8
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %39 = load i32, ptr %1, align 4, !tbaa !7
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %1, align 4, !tbaa !7
  %41 = load i32, ptr @k, align 4, !tbaa !7
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %.lr.ph40, label %._crit_edge41, !llvm.loop !13

.preheader27:                                     ; preds = %.lr.ph44
  %43 = icmp sgt i32 %64, 0
  br i1 %43, label %.lr.ph47.preheader, label %.preheader

.lr.ph47.preheader:                               ; preds = %.preheader27
  %44 = zext nneg i32 %64 to i64
  %45 = shl nuw nsw i64 %44, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @a, ptr nonnull align 16 @c, i64 %45, i1 false), !tbaa !7
  br label %.preheader

.lr.ph44:                                         ; preds = %._crit_edge41, %.lr.ph44
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph44 ], [ 0, %._crit_edge41 ]
  %46 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %47 = load i32, ptr %46, align 4, !tbaa !14
  %48 = getelementptr inbounds [751 x i32], ptr @c, i64 0, i64 %indvars.iv62
  store i32 %47, ptr %48, align 4, !tbaa !7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %49 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %50 = getelementptr inbounds i8, ptr %49, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !16
  store i32 %51, ptr %4, align 4, !tbaa !7
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %52 = load i32, ptr %4, align 4, !tbaa !7
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !7
  %56 = getelementptr inbounds [751 x i32], ptr @id, i64 0, i64 %53
  %57 = load i32, ptr %56, align 4, !tbaa !7
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %56, align 4, !tbaa !7
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [751 x i32], ptr @b, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !7
  %62 = add nsw i32 %61, %55
  store i32 %62, ptr %6, align 4, !tbaa !7
  %63 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i64 %63, ptr %5, align 8
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %64 = load i32, ptr @k, align 4, !tbaa !7
  %65 = sext i32 %64 to i64
  %66 = icmp slt i64 %indvars.iv.next63, %65
  br i1 %66, label %.lr.ph44, label %.preheader27, !llvm.loop !17

.preheader:                                       ; preds = %._crit_edge41.thread, %._crit_edge41, %.lr.ph47.preheader, %.preheader27
  %67 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %67, label %._crit_edge49, label %.lr.ph48

.lr.ph48:                                         ; preds = %.preheader, %.lr.ph48
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %68 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %68, label %._crit_edge49, label %.lr.ph48, !llvm.loop !18

._crit_edge49:                                    ; preds = %.lr.ph48, %.preheader
  %69 = add nuw nsw i32 %.02250, 1
  %70 = load i32, ptr @k, align 4, !tbaa !7
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %.preheader28, label %.preheader29, !llvm.loop !19

.lr.ph52:                                         ; preds = %.preheader29, %.lr.ph52
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph52 ], [ 0, %.preheader29 ]
  %72 = phi i32 [ %83, %.lr.ph52 ], [ %19, %.preheader29 ]
  %73 = getelementptr inbounds [751 x i32], ptr @a, i64 0, i64 %indvars.iv68
  %74 = load i32, ptr %73, align 4, !tbaa !7
  %75 = add nsw i32 %72, -1
  %76 = zext i32 %75 to i64
  %77 = icmp eq i64 %indvars.iv68, %76
  %78 = zext i1 %77 to i64
  %79 = getelementptr inbounds [3 x i8], ptr @.str.2, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !20
  %81 = sext i8 %80 to i32
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %74, i32 noundef %81)
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %83 = load i32, ptr @k, align 4, !tbaa !7
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv.next69, %84
  br i1 %85, label %.lr.ph52, label %.loopexit, !llvm.loop !21

._crit_edge54:                                    ; preds = %.loopexit, %0
  ret i32 0
}

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #5 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

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

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


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