; LLVM IR from tangjz/acm-icpc :: codeforces/453E.ll (Z5solveiP5Event)

; 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.Node = type { i32, i32, i32 }
%struct.Bit = type { [100001 x i64] }
%struct.Event = type { i32, i32, i32, i32 }

@n = external dso_local global i32, align 4
@tim = external dso_local global [100003 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@ans = external dso_local global [100001 x i64], align 16
@a = external dso_local global [100001 x %struct.Node], align 16
@b = external dso_local global [2 x %struct.Bit], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveiP5Event(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  br label %12

12:                                               ; preds = %115, %2
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %118

17:                                               ; preds = %12
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.Node, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = add nsw i64 %27, %23
  store i64 %28, ptr %26, align 8, !tbaa !13
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.Node, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = icmp slt i32 %33, %38
  br i1 %39, label %40, label %86

40:                                               ; preds = %17
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 4, !tbaa !16
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %86

47:                                               ; preds = %40
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.Node, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !16
  %53 = sext i32 %52 to i64
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds ([2 x %struct.Bit], ptr @b, i64 0, i64 1), i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !13
  %58 = add nsw i64 %57, %53
  store i64 %58, ptr %56, align 8, !tbaa !13
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Node, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !15
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.Node, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = sub nsw i32 %63, %68
  %70 = sub nsw i32 %69, 1
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.Node, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 4, !tbaa !16
  %76 = sdiv i32 %70, %75
  %77 = add nsw i32 %76, 1
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100003 x i32], ptr @tim, i64 0, i64 %79
  store i32 %77, ptr %80, align 4, !tbaa !5
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %84
  store i32 %81, ptr %85, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %47, %40, %17
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sub nsw i32 0, %89
  %91 = and i32 %88, %90
  %92 = add nsw i32 %87, %91
  store i32 %92, ptr %7, align 4, !tbaa !5
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = icmp sle i32 %92, %93
  br i1 %94, label %95, label %114

95:                                               ; preds = %86
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !13
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !13
  %104 = add nsw i64 %103, %99
  store i64 %104, ptr %102, align 8, !tbaa !13
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds ([2 x %struct.Bit], ptr @b, i64 0, i64 1), i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !13
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds ([2 x %struct.Bit], ptr @b, i64 0, i64 1), i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !13
  %113 = add nsw i64 %112, %108
  store i64 %113, ptr %111, align 8, !tbaa !13
  br label %114

114:                                              ; preds = %95, %86
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %6, align 4, !tbaa !5
  br label %12, !llvm.loop !17

118:                                              ; preds = %16
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i32, ptr @ord, i64 %120
  %122 = getelementptr inbounds i32, ptr %121, i64 1
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef getelementptr inbounds (i32, ptr @ord, i64 1), ptr noundef %122, ptr noundef @_Z3cmpRKiS0_)
  %123 = load ptr, ptr %4, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.Event, ptr %123, i64 1
  %125 = load ptr, ptr %4, align 8, !tbaa !9
  %126 = load i32, ptr %3, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds %struct.Event, ptr %125, i64 %127
  %129 = getelementptr inbounds %struct.Event, ptr %128, i64 1
  call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef %124, ptr noundef %129)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %229, %118
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = load i32, ptr %3, align 4, !tbaa !5
  %133 = icmp sle i32 %131, %132
  br i1 %133, label %135, label %134

134:                                              ; preds = %130
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %232

135:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  br label %136

136:                                              ; preds = %180, %135
  %137 = load i32, ptr %9, align 4, !tbaa !5
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = icmp sle i32 %137, %138
  br i1 %139, label %140, label %155

140:                                              ; preds = %136
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  store i32 %144, ptr %11, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100003 x i32], ptr @tim, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load ptr, ptr %4, align 8, !tbaa !9
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds %struct.Event, ptr %148, i64 %150
  %152 = getelementptr inbounds %struct.Event, ptr %151, i32 0, i32 1
  %153 = load i32, ptr %152, align 4, !tbaa !19
  %154 = icmp sle i32 %147, %153
  br label %155

155:                                              ; preds = %140, %136
  %156 = phi i1 [ false, %136 ], [ %154, %140 ]
  br i1 %156, label %158, label %157

157:                                              ; preds = %155
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %183

158:                                              ; preds = %155
  %159 = load i32, ptr %11, align 4, !tbaa !5
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.Node, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 4, !tbaa !15
  %165 = load i32, ptr %11, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %166
  %168 = getelementptr inbounds %struct.Node, ptr %167, i32 0, i32 0
  %169 = load i32, ptr %168, align 4, !tbaa !11
  %170 = sub nsw i32 %164, %169
  %171 = sext i32 %170 to i64
  call void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008) @b, i32 noundef %159, i64 noundef %171)
  %172 = load i32, ptr %11, align 4, !tbaa !5
  %173 = load i32, ptr %11, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %174
  %176 = getelementptr inbounds %struct.Node, ptr %175, i32 0, i32 2
  %177 = load i32, ptr %176, align 4, !tbaa !16
  %178 = sub nsw i32 0, %177
  %179 = sext i32 %178 to i64
  call void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008) getelementptr inbounds ([2 x %struct.Bit], ptr @b, i64 0, i64 1), i32 noundef %172, i64 noundef %179)
  br label %180

180:                                              ; preds = %158
  %181 = load i32, ptr %9, align 4, !tbaa !5
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr %9, align 4, !tbaa !5
  br label %136, !llvm.loop !21

183:                                              ; preds = %157
  %184 = load ptr, ptr %4, align 8, !tbaa !9
  %185 = load i32, ptr %8, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds %struct.Event, ptr %184, i64 %186
  %188 = getelementptr inbounds %struct.Event, ptr %187, i32 0, i32 2
  %189 = load i32, ptr %188, align 4, !tbaa !22
  %190 = load ptr, ptr %4, align 8, !tbaa !9
  %191 = load i32, ptr %8, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds %struct.Event, ptr %190, i64 %192
  %194 = getelementptr inbounds %struct.Event, ptr %193, i32 0, i32 3
  %195 = load i32, ptr %194, align 4, !tbaa !23
  %196 = call noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008) @b, i32 noundef %189, i32 noundef %195)
  %197 = load ptr, ptr %4, align 8, !tbaa !9
  %198 = load i32, ptr %8, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds %struct.Event, ptr %197, i64 %199
  %201 = getelementptr inbounds %struct.Event, ptr %200, i32 0, i32 1
  %202 = load i32, ptr %201, align 4, !tbaa !19
  %203 = sext i32 %202 to i64
  %204 = load ptr, ptr %4, align 8, !tbaa !9
  %205 = load i32, ptr %8, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds %struct.Event, ptr %204, i64 %206
  %208 = getelementptr inbounds %struct.Event, ptr %207, i32 0, i32 2
  %209 = load i32, ptr %208, align 4, !tbaa !22
  %210 = load ptr, ptr %4, align 8, !tbaa !9
  %211 = load i32, ptr %8, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds %struct.Event, ptr %210, i64 %212
  %214 = getelementptr inbounds %struct.Event, ptr %213, i32 0, i32 3
  %215 = load i32, ptr %214, align 4, !tbaa !23
  %216 = call noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008) getelementptr inbounds ([2 x %struct.Bit], ptr @b, i64 0, i64 1), i32 noundef %209, i32 noundef %215)
  %217 = mul nsw i64 %203, %216
  %218 = add nsw i64 %196, %217
  %219 = load ptr, ptr %4, align 8, !tbaa !9
  %220 = load i32, ptr %8, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds %struct.Event, ptr %219, i64 %221
  %223 = getelementptr inbounds %struct.Event, ptr %222, i32 0, i32 0
  %224 = load i32, ptr %223, align 4, !tbaa !24
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %225
  %227 = load i64, ptr %226, align 8, !tbaa !13
  %228 = add nsw i64 %227, %218
  store i64 %228, ptr %226, align 8, !tbaa !13
  br label %229

229:                                              ; preds = %183
  %230 = load i32, ptr %8, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %8, align 4, !tbaa !5
  br label %130, !llvm.loop !25

232:                                              ; preds = %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

; 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 @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008), i32 noundef, i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008), i32 noundef, i32 noundef) #1 align 2

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 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 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!12, !6, i64 4}
!16 = !{!12, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !6, i64 4}
!20 = !{!"_ZTS5Event", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!21 = distinct !{!21, !18}
!22 = !{!20, !6, i64 8}
!23 = !{!20, !6, i64 12}
!24 = !{!20, !6, i64 0}
!25 = distinct !{!25, !18}


; 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.Node = type { i32, i32, i32 }
%struct.Bit = type { [100001 x i64] }
%struct.Event = type { i32, i32, i32, i32 }

@n = external dso_local local_unnamed_addr global i32, align 4
@tim = external dso_local local_unnamed_addr global [100003 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i64], align 16
@a = external dso_local local_unnamed_addr global [100001 x %struct.Node], align 16
@b = external dso_local global [2 x %struct.Bit], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveiP5Event(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not62 = icmp slt i32 %3, 1
  br i1 %.not62, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %4 = add nuw i32 %3, 1
  %wide.trip.count = zext i32 %4 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %53, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %.1, %53 ]
  %5 = sext i32 %.0.lcssa to i64
  %6 = getelementptr inbounds i32, ptr @ord, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 4
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @ord, i64 4), ptr noundef nonnull %7, ptr noundef nonnull @_Z3cmpRKiS0_)
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = sext i32 %0 to i64
  %10 = getelementptr inbounds %struct.Event, ptr %1, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  tail call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef nonnull %8, ptr noundef nonnull %11)
  %.not5771 = icmp slt i32 %0, 1
  br i1 %.not5771, label %._crit_edge74, label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge
  %12 = add i32 %.0.lcssa, 1
  %13 = add nuw i32 %0, 1
  %wide.trip.count82 = zext i32 %13 to i64
  br label %.preheader

.lr.ph:                                           ; preds = %.lr.ph.preheader, %53
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %53 ]
  %.064 = phi i32 [ 0, %.lr.ph.preheader ], [ %.1, %53 ]
  %indvars75 = trunc i64 %indvars.iv to i32
  %14 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %indvars.iv
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = add nsw i64 %18, %16
  store i64 %19, ptr %17, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %14, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = icmp slt i32 %15, %21
  br i1 %22, label %23, label %39

23:                                               ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %14, i64 8
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %.not60 = icmp eq i32 %25, 0
  br i1 %.not60, label %39, label %26

26:                                               ; preds = %23
  %27 = sext i32 %25 to i64
  %28 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds (i8, ptr @b, i64 800008), i64 0, i64 %indvars.iv
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = add nsw i64 %29, %27
  store i64 %30, ptr %28, align 8, !tbaa !11
  %31 = xor i32 %15, -1
  %32 = add i32 %21, %31
  %33 = sdiv i32 %32, %25
  %34 = add nsw i32 %33, 1
  %35 = getelementptr inbounds [100003 x i32], ptr @tim, i64 0, i64 %indvars.iv
  store i32 %34, ptr %35, align 4, !tbaa !5
  %36 = add nsw i32 %.064, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %37
  store i32 %indvars75, ptr %38, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %26, %23, %.lr.ph
  %.1 = phi i32 [ %36, %26 ], [ %.064, %23 ], [ %.064, %.lr.ph ]
  %40 = sub nsw i32 0, %indvars75
  %41 = and i32 %indvars75, %40
  %42 = add nuw nsw i32 %41, %indvars75
  %.not61 = icmp sgt i32 %42, %3
  br i1 %.not61, label %53, label %43

43:                                               ; preds = %39
  %44 = zext nneg i32 %42 to i64
  %45 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = add nsw i64 %46, %19
  store i64 %47, ptr %45, align 8, !tbaa !11
  %48 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds (i8, ptr @b, i64 800008), i64 0, i64 %indvars.iv
  %49 = load i64, ptr %48, align 8, !tbaa !11
  %50 = getelementptr inbounds [100001 x i64], ptr getelementptr inbounds (i8, ptr @b, i64 800008), i64 0, i64 %44
  %51 = load i64, ptr %50, align 8, !tbaa !11
  %52 = add nsw i64 %51, %49
  store i64 %52, ptr %50, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %39, %43
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

.preheader:                                       ; preds = %.preheader.preheader, %.critedge
  %indvars.iv79 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next80, %.critedge ]
  %.05173 = phi i32 [ 1, %.preheader.preheader ], [ %.152.lcssa, %.critedge ]
  %.not5865 = icmp sgt i32 %.05173, %.0.lcssa
  br i1 %.not5865, label %.critedge, label %.lr.ph67

.lr.ph67:                                         ; preds = %.preheader
  %54 = getelementptr inbounds %struct.Event, ptr %1, i64 %indvars.iv79, i32 1
  %55 = sext i32 %.05173 to i64
  br label %56

._crit_edge74:                                    ; preds = %.critedge, %._crit_edge
  ret void

56:                                               ; preds = %.lr.ph67, %83
  %indvars.iv76 = phi i64 [ %55, %.lr.ph67 ], [ %indvars.iv.next77, %83 ]
  %57 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv76
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100003 x i32], ptr @tim, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %54, align 4, !tbaa !17
  %.not59 = icmp sgt i32 %61, %62
  br i1 %.not59, label %.critedge.loopexit.split.loop.exit84, label %83

.critedge.loopexit.split.loop.exit84:             ; preds = %56
  %63 = trunc nsw i64 %indvars.iv76 to i32
  br label %.critedge

.critedge:                                        ; preds = %83, %.critedge.loopexit.split.loop.exit84, %.preheader
  %.152.lcssa = phi i32 [ %.05173, %.preheader ], [ %63, %.critedge.loopexit.split.loop.exit84 ], [ %12, %83 ]
  %64 = getelementptr inbounds %struct.Event, ptr %1, i64 %indvars.iv79
  %65 = getelementptr inbounds i8, ptr %64, i64 8
  %66 = load i32, ptr %65, align 4, !tbaa !19
  %67 = getelementptr inbounds i8, ptr %64, i64 12
  %68 = load i32, ptr %67, align 4, !tbaa !20
  %69 = tail call noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008) @b, i32 noundef %66, i32 noundef %68)
  %70 = getelementptr inbounds i8, ptr %64, i64 4
  %71 = load i32, ptr %70, align 4, !tbaa !17
  %72 = sext i32 %71 to i64
  %73 = load i32, ptr %65, align 4, !tbaa !19
  %74 = load i32, ptr %67, align 4, !tbaa !20
  %75 = tail call noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008) getelementptr inbounds (i8, ptr @b, i64 800008), i32 noundef %73, i32 noundef %74)
  %76 = mul nsw i64 %75, %72
  %77 = add nsw i64 %76, %69
  %78 = load i32, ptr %64, align 4, !tbaa !21
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = add nsw i64 %77, %81
  store i64 %82, ptr %80, align 8, !tbaa !11
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next80, %wide.trip.count82
  br i1 %exitcond83.not, label %._crit_edge74, label %.preheader, !llvm.loop !22

83:                                               ; preds = %56
  %84 = getelementptr inbounds [100001 x %struct.Node], ptr @a, i64 0, i64 %59
  %85 = getelementptr inbounds i8, ptr %84, i64 4
  %86 = load i32, ptr %85, align 4, !tbaa !13
  %87 = load i32, ptr %84, align 4, !tbaa !9
  %88 = sub nsw i32 %86, %87
  %89 = sext i32 %88 to i64
  tail call void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008) @b, i32 noundef %58, i64 noundef %89)
  %90 = getelementptr inbounds i8, ptr %84, i64 8
  %91 = load i32, ptr %90, align 4, !tbaa !14
  %92 = sub nsw i32 0, %91
  %93 = sext i32 %92 to i64
  tail call void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008) getelementptr inbounds (i8, ptr @b, i64 800008), i32 noundef %58, i64 noundef %93)
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, 1
  %.not58.not = icmp slt i64 %indvars.iv76, %5
  br i1 %.not58.not, label %56, label %.critedge, !llvm.loop !23
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Bit3updEix(ptr noundef nonnull align 8 dereferenceable(800008), i32 noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3Bit3queEii(ptr noundef nonnull align 8 dereferenceable(800008), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

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

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

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


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