; LLVM IR from upupming/algorithm :: acwing/算法竞赛进阶指南/0x43-线段树/247. 亚特兰蒂斯 (main)

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

%struct.Segment = type { double, double, double, i32 }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<double, std::pair<const double, int>, std::_Select1st<std::pair<const double, int>>, std::less<double>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<double, std::pair<const double, int>, std::_Select1st<std::pair<const double, int>>, std::less<double>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.SegmentTree = type { i32, i32, i32, double }
%"class.std::basic_istream" = type { ptr, i64, %"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 }

@seg = external dso_local global [20020 x %struct.Segment], align 16
@raw = external dso_local global [20020 x double], align 16
@val = external dso_local global %"class.std::map", align 8
@tree = external dso_local global [80080 x %struct.SegmentTree], align 16
@n = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@x1 = external dso_local global double, align 8
@y1 = external dso_local global double, align 8
@x2 = external dso_local global double, align 8
@y2 = external dso_local global double, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, i32 noundef, i32 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %10

10:                                               ; preds = %177, %0
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr %11, i64 %14
  %16 = call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264) %15)
  br i1 %16, label %17, label %20

17:                                               ; preds = %10
  %18 = load i32, ptr @n, align 4, !tbaa !8
  %19 = icmp ne i32 %18, 0
  br label %20

20:                                               ; preds = %17, %10
  %21 = phi i1 [ false, %10 ], [ %19, %17 ]
  br i1 %21, label %22, label %182

22:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !8
  br label %23

23:                                               ; preds = %94, %22
  %24 = load i32, ptr %2, align 4, !tbaa !8
  %25 = load i32, ptr @n, align 4, !tbaa !8
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @x1)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 8 dereferenceable(8) @y1)
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 8 dereferenceable(8) @x2)
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %31, ptr noundef nonnull align 8 dereferenceable(8) @y2)
  %33 = load double, ptr @x1, align 8, !tbaa !11
  %34 = load i32, ptr %2, align 4, !tbaa !8
  %35 = mul nsw i32 2, %34
  %36 = sub nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.Segment, ptr %38, i32 0, i32 0
  store double %33, ptr %39, align 16, !tbaa !13
  %40 = load double, ptr @y1, align 8, !tbaa !11
  %41 = load i32, ptr %2, align 4, !tbaa !8
  %42 = mul nsw i32 2, %41
  %43 = sub nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.Segment, ptr %45, i32 0, i32 1
  store double %40, ptr %46, align 8, !tbaa !15
  %47 = load double, ptr @y2, align 8, !tbaa !11
  %48 = load i32, ptr %2, align 4, !tbaa !8
  %49 = mul nsw i32 2, %48
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Segment, ptr %52, i32 0, i32 2
  store double %47, ptr %53, align 16, !tbaa !16
  %54 = load i32, ptr %2, align 4, !tbaa !8
  %55 = mul nsw i32 2, %54
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.Segment, ptr %58, i32 0, i32 3
  store i32 1, ptr %59, align 8, !tbaa !17
  %60 = load double, ptr @x2, align 8, !tbaa !11
  %61 = load i32, ptr %2, align 4, !tbaa !8
  %62 = mul nsw i32 2, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.Segment, ptr %64, i32 0, i32 0
  store double %60, ptr %65, align 16, !tbaa !13
  %66 = load double, ptr @y1, align 8, !tbaa !11
  %67 = load i32, ptr %2, align 4, !tbaa !8
  %68 = mul nsw i32 2, %67
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Segment, ptr %70, i32 0, i32 1
  store double %66, ptr %71, align 8, !tbaa !15
  %72 = load double, ptr @y2, align 8, !tbaa !11
  %73 = load i32, ptr %2, align 4, !tbaa !8
  %74 = mul nsw i32 2, %73
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.Segment, ptr %76, i32 0, i32 2
  store double %72, ptr %77, align 16, !tbaa !16
  %78 = load i32, ptr %2, align 4, !tbaa !8
  %79 = mul nsw i32 2, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %80
  %82 = getelementptr inbounds %struct.Segment, ptr %81, i32 0, i32 3
  store i32 -1, ptr %82, align 8, !tbaa !17
  %83 = load double, ptr @y1, align 8, !tbaa !11
  %84 = load i32, ptr %2, align 4, !tbaa !8
  %85 = mul nsw i32 2, %84
  %86 = sub nsw i32 %85, 1
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %87
  store double %83, ptr %88, align 8, !tbaa !11
  %89 = load double, ptr @y2, align 8, !tbaa !11
  %90 = load i32, ptr %2, align 4, !tbaa !8
  %91 = mul nsw i32 2, %90
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %92
  store double %89, ptr %93, align 8, !tbaa !11
  br label %94

94:                                               ; preds = %28
  %95 = load i32, ptr %2, align 4, !tbaa !8
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %2, align 4, !tbaa !8
  br label %23, !llvm.loop !18

97:                                               ; preds = %27
  %98 = load i32, ptr @n, align 4, !tbaa !8
  %99 = mul nsw i32 2, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds double, ptr getelementptr inbounds (double, ptr @raw, i64 1), i64 %100
  call void @_ZSt4sortIPdEvT_S1_(ptr noundef getelementptr inbounds (double, ptr @raw, i64 1), ptr noundef %101)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %102 = load i32, ptr @n, align 4, !tbaa !8
  %103 = mul nsw i32 2, %102
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr getelementptr inbounds (double, ptr @raw, i64 1), i64 %104
  %106 = call noundef ptr @_ZSt6uniqueIPdET_S1_S1_(ptr noundef getelementptr inbounds (double, ptr @raw, i64 1), ptr noundef %105)
  %107 = ptrtoint ptr %106 to i64
  %108 = sub i64 %107, ptrtoint (ptr getelementptr inbounds (double, ptr @raw, i64 1) to i64)
  %109 = sdiv exact i64 %108, 8
  %110 = trunc i64 %109 to i32
  store i32 %110, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %111

111:                                              ; preds = %122, %97
  %112 = load i32, ptr %4, align 4, !tbaa !8
  %113 = load i32, ptr %3, align 4, !tbaa !8
  %114 = icmp sle i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %125

116:                                              ; preds = %111
  %117 = load i32, ptr %4, align 4, !tbaa !8
  %118 = load i32, ptr %4, align 4, !tbaa !8
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %119
  %121 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %120)
  store i32 %117, ptr %121, align 4, !tbaa !8
  br label %122

122:                                              ; preds = %116
  %123 = load i32, ptr %4, align 4, !tbaa !8
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %4, align 4, !tbaa !8
  br label %111, !llvm.loop !20

125:                                              ; preds = %115
  %126 = load i32, ptr @n, align 4, !tbaa !8
  %127 = mul nsw i32 2, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds %struct.Segment, ptr getelementptr inbounds (%struct.Segment, ptr @seg, i64 1), i64 %128
  call void @_ZSt4sortIP7SegmentEvT_S2_(ptr noundef getelementptr inbounds (%struct.Segment, ptr @seg, i64 1), ptr noundef %129)
  %130 = load i32, ptr %3, align 4, !tbaa !8
  call void @_Z5buildiii(i32 noundef 1, i32 noundef 1, i32 noundef %130)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !8
  br label %131

131:                                              ; preds = %174, %125
  %132 = load i32, ptr %6, align 4, !tbaa !8
  %133 = load i32, ptr @n, align 4, !tbaa !8
  %134 = mul nsw i32 2, %133
  %135 = icmp sle i32 %132, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %177

137:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %138 = load double, ptr getelementptr inbounds (%struct.SegmentTree, ptr getelementptr inbounds ([80080 x %struct.SegmentTree], ptr @tree, i64 0, i64 1), i32 0, i32 3), align 8, !tbaa !21
  store double %138, ptr %7, align 8, !tbaa !11
  %139 = load double, ptr %7, align 8, !tbaa !11
  %140 = load i32, ptr %6, align 4, !tbaa !8
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %141
  %143 = getelementptr inbounds %struct.Segment, ptr %142, i32 0, i32 0
  %144 = load double, ptr %143, align 16, !tbaa !13
  %145 = load i32, ptr %6, align 4, !tbaa !8
  %146 = sub nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.Segment, ptr %148, i32 0, i32 0
  %150 = load double, ptr %149, align 16, !tbaa !13
  %151 = fsub double %144, %150
  %152 = load double, ptr %5, align 8, !tbaa !11
  %153 = call double @llvm.fmuladd.f64(double %139, double %151, double %152)
  store double %153, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %154 = load i32, ptr %6, align 4, !tbaa !8
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %155
  %157 = getelementptr inbounds %struct.Segment, ptr %156, i32 0, i32 1
  %158 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %157)
  %159 = load i32, ptr %158, align 4, !tbaa !8
  store i32 %159, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %160 = load i32, ptr %6, align 4, !tbaa !8
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.Segment, ptr %162, i32 0, i32 2
  %164 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %163)
  %165 = load i32, ptr %164, align 4, !tbaa !8
  %166 = sub nsw i32 %165, 1
  store i32 %166, ptr %9, align 4, !tbaa !8
  %167 = load i32, ptr %8, align 4, !tbaa !8
  %168 = load i32, ptr %9, align 4, !tbaa !8
  %169 = load i32, ptr %6, align 4, !tbaa !8
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %170
  %172 = getelementptr inbounds %struct.Segment, ptr %171, i32 0, i32 3
  %173 = load i32, ptr %172, align 8, !tbaa !17
  call void @_Z6changeiiii(i32 noundef 1, i32 noundef %167, i32 noundef %168, i32 noundef %173)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %174

174:                                              ; preds = %137
  %175 = load i32, ptr %6, align 4, !tbaa !8
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %6, align 4, !tbaa !8
  br label %131, !llvm.loop !23

177:                                              ; preds = %136
  %178 = load i32, ptr @t, align 4, !tbaa !8
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr @t, align 4, !tbaa !8
  %180 = load double, ptr %5, align 8, !tbaa !11
  %181 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %179, double noundef %180)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %10, !llvm.loop !24

182:                                              ; preds = %20
  %183 = load i32, ptr %1, align 4
  ret i32 %183
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264)) #0 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPdET_S1_S1_(ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !10, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTS7Segment", !12, i64 0, !12, i64 8, !12, i64 16, !9, i64 24}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !12, i64 16}
!17 = !{!14, !9, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!22, !12, i64 16}
!22 = !{!"_ZTS11SegmentTree", !9, i64 0, !9, i64 4, !9, i64 8, !12, i64 16}
!23 = distinct !{!23, !19}
!24 = distinct !{!24, !19}


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

%struct.Segment = type { double, double, double, i32 }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<double, std::pair<const double, int>, std::_Select1st<std::pair<const double, int>>, std::less<double>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<double, std::pair<const double, int>, std::_Select1st<std::pair<const double, int>>, std::less<double>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.SegmentTree = type { i32, i32, i32, double }
%"class.std::basic_istream" = type { ptr, i64, %"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 }

@seg = external dso_local global [20020 x %struct.Segment], align 16
@raw = external dso_local global [20020 x double], align 16
@val = external dso_local global %"class.std::map", align 8
@tree = external dso_local local_unnamed_addr global [80080 x %struct.SegmentTree], align 16
@n = external dso_local global i32, align 4
@t = external dso_local local_unnamed_addr global i32, align 4
@x1 = external dso_local global double, align 8
@y1 = external dso_local global double, align 8
@x2 = external dso_local global double, align 8
@y2 = external dso_local global double, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [42 x i8], align 1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %2 = load ptr, ptr %1, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr %1, i64 %4
  %6 = tail call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264) %5)
  %7 = load i32, ptr @n, align 4
  %8 = icmp ne i32 %7, 0
  %9 = select i1 %6, i1 %8, i1 false
  br i1 %9, label %.preheader, label %._crit_edge51

.preheader:                                       ; preds = %0, %._crit_edge49
  %10 = phi i32 [ %63, %._crit_edge49 ], [ %7, %0 ]
  %.not37 = icmp slt i32 %10, 1
  br i1 %.not37, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.lcssa = phi i32 [ %10, %.preheader ], [ %44, %.lr.ph ]
  %11 = shl nsw i32 %.lcssa, 1
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds double, ptr getelementptr inbounds (i8, ptr @raw, i64 8), i64 %12
  tail call void @_ZSt4sortIPdEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @raw, i64 8), ptr noundef nonnull %13)
  %14 = load i32, ptr @n, align 4, !tbaa !8
  %15 = shl nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds double, ptr getelementptr inbounds (i8, ptr @raw, i64 8), i64 %16
  %18 = tail call noundef ptr @_ZSt6uniqueIPdET_S1_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @raw, i64 8), ptr noundef nonnull %17)
  %19 = ptrtoint ptr %18 to i64
  %20 = sub i64 %19, ptrtoint (ptr getelementptr inbounds (i8, ptr @raw, i64 8) to i64)
  %21 = lshr exact i64 %20, 3
  %22 = trunc i64 %21 to i32
  %.not3539 = icmp slt i32 %22, 1
  br i1 %.not3539, label %._crit_edge43, label %.lr.ph42.preheader

.lr.ph42.preheader:                               ; preds = %._crit_edge
  %23 = add nuw nsw i64 %21, 1
  %wide.trip.count = and i64 %23, 4294967295
  br label %.lr.ph42

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.preheader ]
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @x1)
  %25 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 8 dereferenceable(8) @y1)
  %26 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) @x2)
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERd(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(8) @y2)
  %28 = load double, ptr @x1, align 8, !tbaa !11
  %29 = shl nuw nsw i64 %indvars.iv, 1
  %30 = add nsw i64 %29, -1
  %31 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %30
  store double %28, ptr %31, align 16, !tbaa !13
  %32 = load double, ptr @y1, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %31, i64 8
  store double %32, ptr %33, align 8, !tbaa !15
  %34 = load double, ptr @y2, align 8, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %31, i64 16
  store double %34, ptr %35, align 16, !tbaa !16
  %36 = getelementptr inbounds i8, ptr %31, i64 24
  store i32 1, ptr %36, align 8, !tbaa !17
  %37 = load double, ptr @x2, align 8, !tbaa !11
  %38 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %29
  store double %37, ptr %38, align 16, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  store double %32, ptr %39, align 8, !tbaa !15
  %40 = getelementptr inbounds i8, ptr %38, i64 16
  store double %34, ptr %40, align 16, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %38, i64 24
  store i32 -1, ptr %41, align 8, !tbaa !17
  %42 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %30
  store double %32, ptr %42, align 8, !tbaa !11
  %43 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %29
  store double %34, ptr %43, align 16, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %44 = load i32, ptr @n, align 4, !tbaa !8
  %45 = sext i32 %44 to i64
  %.not.not = icmp slt i64 %indvars.iv, %45
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge43:                                    ; preds = %.lr.ph42, %._crit_edge
  %46 = load i32, ptr @n, align 4, !tbaa !8
  %47 = shl nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.Segment, ptr getelementptr inbounds (i8, ptr @seg, i64 32), i64 %48
  tail call void @_ZSt4sortIP7SegmentEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @seg, i64 32), ptr noundef nonnull %49)
  tail call void @_Z5buildiii(i32 noundef 1, i32 noundef 1, i32 noundef %22)
  %50 = load i32, ptr @n, align 4, !tbaa !8
  %.not3644 = icmp slt i32 %50, 1
  br i1 %.not3644, label %._crit_edge49, label %.lr.ph48

.lr.ph42:                                         ; preds = %.lr.ph42.preheader, %.lr.ph42
  %indvars.iv55 = phi i64 [ 1, %.lr.ph42.preheader ], [ %indvars.iv.next56, %.lr.ph42 ]
  %51 = getelementptr inbounds [20020 x double], ptr @raw, i64 0, i64 %indvars.iv55
  %52 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %51)
  %53 = trunc nuw nsw i64 %indvars.iv55 to i32
  store i32 %53, ptr %52, align 4, !tbaa !8
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge43, label %.lr.ph42, !llvm.loop !20

._crit_edge49:                                    ; preds = %.lr.ph48, %._crit_edge43
  %.031.lcssa = phi double [ 0.000000e+00, %._crit_edge43 ], [ %73, %.lr.ph48 ]
  %54 = load i32, ptr @t, align 4, !tbaa !8
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr @t, align 4, !tbaa !8
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %55, double noundef %.031.lcssa)
  %57 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr i8, ptr %58, i64 -24
  %60 = load i64, ptr %59, align 8
  %61 = getelementptr inbounds i8, ptr %57, i64 %60
  %62 = tail call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264) %61)
  %63 = load i32, ptr @n, align 4
  %64 = icmp ne i32 %63, 0
  %65 = select i1 %62, i1 %64, i1 false
  br i1 %65, label %.preheader, label %._crit_edge51, !llvm.loop !21

.lr.ph48:                                         ; preds = %._crit_edge43, %.lr.ph48
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %.lr.ph48 ], [ 1, %._crit_edge43 ]
  %.03146 = phi double [ %73, %.lr.ph48 ], [ 0.000000e+00, %._crit_edge43 ]
  %66 = load double, ptr getelementptr inbounds (i8, ptr @tree, i64 40), align 8, !tbaa !22
  %67 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %indvars.iv58
  %68 = load double, ptr %67, align 16, !tbaa !13
  %69 = add nsw i64 %indvars.iv58, -1
  %70 = getelementptr inbounds [20020 x %struct.Segment], ptr @seg, i64 0, i64 %69
  %71 = load double, ptr %70, align 16, !tbaa !13
  %72 = fsub double %68, %71
  %73 = tail call double @llvm.fmuladd.f64(double %66, double %72, double %.03146)
  %74 = getelementptr inbounds i8, ptr %67, i64 8
  %75 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %74)
  %76 = load i32, ptr %75, align 4, !tbaa !8
  %77 = getelementptr inbounds i8, ptr %67, i64 16
  %78 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @val, ptr noundef nonnull align 8 dereferenceable(8) %77)
  %79 = load i32, ptr %78, align 4, !tbaa !8
  %80 = add nsw i32 %79, -1
  %81 = getelementptr inbounds i8, ptr %67, i64 24
  %82 = load i32, ptr %81, align 8, !tbaa !17
  tail call void @_Z6changeiiii(i32 noundef 1, i32 noundef %76, i32 noundef %80, i32 noundef %82)
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %83 = load i32, ptr @n, align 4, !tbaa !8
  %84 = shl nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %.not36.not = icmp slt i64 %indvars.iv58, %85
  br i1 %.not36.not, label %.lr.ph48, label %._crit_edge49, !llvm.loop !24

._crit_edge51:                                    ; preds = %._crit_edge49, %0
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264)) local_unnamed_addr #0 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIdiSt4lessIdESaISt4pairIKdiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !10, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTS7Segment", !12, i64 0, !12, i64 8, !12, i64 16, !9, i64 24}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !12, i64 16}
!17 = !{!14, !9, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}
!22 = !{!23, !12, i64 16}
!23 = !{!"_ZTS11SegmentTree", !9, i64 0, !9, i64 4, !9, i64 8, !12, i64 16}
!24 = distinct !{!24, !19}


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