; LLVM IR from tangjz/acm-icpc :: codeforces/complete/721D.ll (Z13solve_abs_minv)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@v = external dso_local global i32, align 4
@a = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ13solve_abs_minvE1b = external hidden global [200001 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sgnd(double noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) #2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nounwind
declare double @log(double noundef) #4

; 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) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13solve_abs_minv() #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::priority_queue", align 8
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca double, align 8
  %8 = alloca { double, i32 }, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca double, align 8
  %15 = alloca { double, i32 }, align 8
  %16 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #7
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

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

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %62

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %29
  store i64 %27, ptr %30, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = invoke noundef i64 @_ZSt3absx(i64 noundef %34)
          to label %36 unwind label %53

36:                                               ; preds = %22
  store i64 %35, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %37 = load i64, ptr %3, align 8, !tbaa !9
  %38 = sitofp i64 %37 to double
  %39 = call double @log(double noundef %38) #7
  %40 = load i64, ptr %3, align 8, !tbaa !9
  %41 = load i32, ptr @v, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = sub nsw i64 %40, %42
  %44 = sitofp i64 %43 to double
  %45 = call double @log(double noundef %44) #7
  %46 = fsub double %39, %45
  store double %46, ptr %7, align 8, !tbaa !11
  %47 = invoke { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %48 unwind label %57

48:                                               ; preds = %36
  store { double, i32 } %47, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %8, i64 12, i1 false)
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 8 dereferenceable(12) %6)
          to label %49 unwind label %57

49:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !13

53:                                               ; preds = %22
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %4, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %5, align 4
  br label %61

57:                                               ; preds = %48, %36
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %4, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #7
  br label %61

61:                                               ; preds = %57, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %174

62:                                               ; preds = %21
  br label %63

63:                                               ; preds = %133, %62
  %64 = load i32, ptr @m, align 4, !tbaa !5
  %65 = add nsw i32 %64, -1
  store i32 %65, ptr @m, align 4, !tbaa !5
  %66 = icmp ne i32 %64, 0
  br i1 %66, label %67, label %145

67:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %68 = invoke noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %69 unwind label %76

69:                                               ; preds = %67
  %70 = getelementptr inbounds %"struct.std::pair", ptr %68, i32 0, i32 0
  %71 = load double, ptr %70, align 8, !tbaa !15
  store double %71, ptr %9, align 8, !tbaa !11
  %72 = load double, ptr %9, align 8, !tbaa !11
  %73 = call noundef i32 @_Z3sgnd(double noundef %72)
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %75, label %80

75:                                               ; preds = %69
  store i32 6, ptr %10, align 4
  br label %131

76:                                               ; preds = %67
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %4, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %5, align 4
  br label %144

80:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %81 = invoke noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %82 unwind label %99

82:                                               ; preds = %80
  %83 = getelementptr inbounds %"struct.std::pair", ptr %81, i32 0, i32 1
  %84 = load i32, ptr %83, align 8, !tbaa !17
  store i32 %84, ptr %11, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %85 unwind label %99

85:                                               ; preds = %82
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = icmp sgt i64 %89, 0
  br i1 %90, label %91, label %103

91:                                               ; preds = %85
  %92 = load i32, ptr @v, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !9
  %98 = sub nsw i64 %97, %93
  store i64 %98, ptr %96, align 8, !tbaa !9
  br label %111

99:                                               ; preds = %82, %80
  %100 = landingpad { ptr, i32 }
          cleanup
  %101 = extractvalue { ptr, i32 } %100, 0
  store ptr %101, ptr %4, align 8
  %102 = extractvalue { ptr, i32 } %100, 1
  store i32 %102, ptr %5, align 4
  br label %143

103:                                              ; preds = %85
  %104 = load i32, ptr @v, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = load i32, ptr %11, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !9
  %110 = add nsw i64 %109, %105
  store i64 %110, ptr %108, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %103, %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %112 = load i32, ptr %11, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !9
  %116 = invoke noundef i64 @_ZSt3absx(i64 noundef %115)
          to label %117 unwind label %134

117:                                              ; preds = %111
  store i64 %116, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %118 = load i64, ptr %12, align 8, !tbaa !9
  %119 = sitofp i64 %118 to double
  %120 = call double @log(double noundef %119) #7
  %121 = load i64, ptr %12, align 8, !tbaa !9
  %122 = load i32, ptr @v, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = sub nsw i64 %121, %123
  %125 = sitofp i64 %124 to double
  %126 = call double @log(double noundef %125) #7
  %127 = fsub double %120, %126
  store double %127, ptr %14, align 8, !tbaa !11
  %128 = invoke { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %129 unwind label %138

129:                                              ; preds = %117
  store { double, i32 } %128, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %15, i64 12, i1 false)
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 8 dereferenceable(12) %13)
          to label %130 unwind label %138

130:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  store i32 0, ptr %10, align 4
  br label %131

131:                                              ; preds = %130, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %132 = load i32, ptr %10, align 4
  switch i32 %132, label %180 [
    i32 0, label %133
    i32 6, label %145
  ]

133:                                              ; preds = %131
  br label %63, !llvm.loop !18

134:                                              ; preds = %111
  %135 = landingpad { ptr, i32 }
          cleanup
  %136 = extractvalue { ptr, i32 } %135, 0
  store ptr %136, ptr %4, align 8
  %137 = extractvalue { ptr, i32 } %135, 1
  store i32 %137, ptr %5, align 4
  br label %142

138:                                              ; preds = %129, %117
  %139 = landingpad { ptr, i32 }
          cleanup
  %140 = extractvalue { ptr, i32 } %139, 0
  store ptr %140, ptr %4, align 8
  %141 = extractvalue { ptr, i32 } %139, 1
  store i32 %141, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  br label %142

142:                                              ; preds = %138, %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %143

143:                                              ; preds = %142, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %144

144:                                              ; preds = %143, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %174

145:                                              ; preds = %131, %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %166, %145
  %147 = load i32, ptr %16, align 4, !tbaa !5
  %148 = load i32, ptr @n, align 4, !tbaa !5
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %146
  store i32 7, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %173

151:                                              ; preds = %146
  %152 = load i32, ptr %16, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %153
  %155 = load i64, ptr %154, align 8, !tbaa !9
  %156 = load i32, ptr %16, align 4, !tbaa !5
  %157 = load i32, ptr @n, align 4, !tbaa !5
  %158 = sub nsw i32 %157, 1
  %159 = icmp eq i32 %156, %158
  %160 = zext i1 %159 to i64
  %161 = getelementptr inbounds [3 x i8], ptr @.str.1, i64 0, i64 %160
  %162 = load i8, ptr %161, align 1, !tbaa !19
  %163 = sext i8 %162 to i32
  %164 = invoke i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %155, i32 noundef %163)
          to label %165 unwind label %169

165:                                              ; preds = %151
  br label %166

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

169:                                              ; preds = %151
  %170 = landingpad { ptr, i32 }
          cleanup
  %171 = extractvalue { ptr, i32 } %170, 0
  store ptr %171, ptr %4, align 8
  %172 = extractvalue { ptr, i32 } %170, 1
  store i32 %172, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %174

173:                                              ; preds = %150
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #7
  ret void

174:                                              ; preds = %169, %144, %61
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #7
  br label %175

175:                                              ; preds = %174
  %176 = load ptr, ptr %4, align 8
  %177 = load i32, ptr %5, align 4
  %178 = insertvalue { ptr, i32 } poison, ptr %176, 0
  %179 = insertvalue { ptr, i32 } %178, i32 %177, 1
  resume { ptr, i32 } %179

180:                                              ; preds = %131
  unreachable
}

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

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

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

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

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@v = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ13solve_abs_minvE1b = external hidden local_unnamed_addr global [200001 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sgnd(double noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13solve_abs_minv() local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::priority_queue", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #6
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.sroa.210.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  br label %13

._crit_edge:                                      ; preds = %30, %0
  %10 = phi i32 [ %8, %0 ], [ %33, %30 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @m, align 4, !tbaa !5
  %.not30 = icmp eq i32 %11, 0
  br i1 %.not30, label %.thread, label %.lr.ph32

.lr.ph32:                                         ; preds = %._crit_edge
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  br label %37

13:                                               ; preds = %.lr.ph, %30
  %storemerge29 = phi i32 [ 0, %.lr.ph ], [ %32, %30 ]
  %14 = sext i32 %storemerge29 to i64
  %15 = getelementptr inbounds [200001 x i32], ptr @a, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %14
  store i64 %17, ptr %18, align 8, !tbaa !9
  %19 = call noundef i64 @_ZSt3absx(i64 noundef %17)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %20 = sitofp i64 %19 to double
  %21 = call double @log(double noundef %20) #6
  %22 = load i32, ptr @v, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = sub nsw i64 %19, %23
  %25 = sitofp i64 %24 to double
  %26 = call double @log(double noundef %25) #6
  %27 = fsub double %21, %26
  store double %27, ptr %4, align 8, !tbaa !11
  %28 = invoke { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %29 unwind label %35

29:                                               ; preds = %13
  %.fca.0.extract7 = extractvalue { double, i32 } %28, 0
  %.fca.1.extract8 = extractvalue { double, i32 } %28, 1
  store double %.fca.0.extract7, ptr %3, align 8
  store i32 %.fca.1.extract8, ptr %.sroa.210.0..sroa_idx, align 8
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 8 dereferenceable(12) %3)
          to label %30 unwind label %35

30:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %13, label %._crit_edge, !llvm.loop !13

35:                                               ; preds = %29, %13
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  br label %90

37:                                               ; preds = %.lr.ph32, %68
  %38 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = call noundef i32 @_Z3sgnd(double noundef %39)
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %.thread.loopexit, label %42

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %43 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %44 = getelementptr inbounds i8, ptr %43, i64 8
  %45 = load i32, ptr %44, align 8, !tbaa !17
  store i32 %45, ptr %5, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %46 unwind label %65

46:                                               ; preds = %42
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = icmp sgt i64 %50, 0
  %52 = load i32, ptr @v, align 4
  %53 = sext i32 %52 to i64
  %54 = sub nsw i64 0, %53
  %storemerge23.p = select i1 %51, i64 %54, i64 %53
  %storemerge23 = add i64 %storemerge23.p, %50
  store i64 %storemerge23, ptr %49, align 8, !tbaa !9
  %55 = call noundef i64 @_ZSt3absx(i64 noundef %storemerge23)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %56 = sitofp i64 %55 to double
  %57 = call double @log(double noundef %56) #6
  %58 = load i32, ptr @v, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = sub nsw i64 %55, %59
  %61 = sitofp i64 %60 to double
  %62 = call double @log(double noundef %61) #6
  %63 = fsub double %57, %62
  store double %63, ptr %7, align 8, !tbaa !11
  %64 = invoke { double, i32 } @_ZSt9make_pairIdRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %67 unwind label %71

65:                                               ; preds = %42
  %66 = landingpad { ptr, i32 }
          cleanup
  br label %73

67:                                               ; preds = %46
  %.fca.0.extract = extractvalue { double, i32 } %64, 0
  %.fca.1.extract = extractvalue { double, i32 } %64, 1
  store double %.fca.0.extract, ptr %6, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  invoke void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 8 dereferenceable(12) %6)
          to label %68 unwind label %71

68:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %70 = add nsw i32 %69, -1
  store i32 %70, ptr @m, align 4, !tbaa !5
  %.not = icmp eq i32 %69, 0
  br i1 %.not, label %.thread.loopexit, label %37

71:                                               ; preds = %67, %46
  %72 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  br label %73

73:                                               ; preds = %71, %65
  %.pn = phi { ptr, i32 } [ %72, %71 ], [ %66, %65 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  br label %90

.thread.loopexit:                                 ; preds = %37, %68
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.thread.loopexit, %._crit_edge
  %74 = phi i32 [ %.pre, %.thread.loopexit ], [ %10, %._crit_edge ]
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph35, label %._crit_edge36

._crit_edge36:                                    ; preds = %.lr.ph35, %.thread
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  ret void

.lr.ph35:                                         ; preds = %.thread, %.lr.ph35
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph35 ], [ 0, %.thread ]
  %76 = phi i32 [ %87, %.lr.ph35 ], [ %74, %.thread ]
  %77 = getelementptr inbounds [200001 x i64], ptr @_ZZ13solve_abs_minvE1b, i64 0, i64 %indvars.iv
  %78 = load i64, ptr %77, align 8, !tbaa !9
  %79 = add nsw i32 %76, -1
  %80 = zext i32 %79 to i64
  %81 = icmp eq i64 %indvars.iv, %80
  %82 = zext i1 %81 to i64
  %83 = getelementptr inbounds [3 x i8], ptr @.str.1, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !18
  %85 = sext i8 %84 to i32
  %86 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %78, i32 noundef %85)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next, %88
  br i1 %89, label %.lr.ph35, label %._crit_edge36, !llvm.loop !19

90:                                               ; preds = %73, %35
  %.pn25 = phi { ptr, i32 } [ %36, %35 ], [ %.pn, %73 ]
  call void @_ZNSt14priority_queueISt4pairIdiESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn25
}

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

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

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


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