; LLVM IR from Lakhankumawat/LearnCPP :: T-Tree/F-FenwickTree (K_Query)

; 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.event = type { i64, i64, i64, i64 }
%struct.P = type { i64, i64 }

@ans = external dso_local global [200005 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3com1PS_(i64, i64, i64, i64) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7compare5eventS_(ptr noundef byval(%struct.event) align 8, ptr noundef byval(%struct.event) align 8) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updatexx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z5querix(i64 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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = add nsw i64 %13, 1
  %15 = call ptr @llvm.stacksave.p0()
  store ptr %15, ptr %3, align 8
  %16 = alloca %struct.P, i64 %14, align 16
  store i64 %14, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %35, %0
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = icmp sle i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %38

23:                                               ; preds = %17
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds %struct.P, ptr %16, i64 %25
  %27 = getelementptr inbounds %struct.P, ptr %26, i32 0, i32 0
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %27)
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.P, ptr %16, i64 %32
  %34 = getelementptr inbounds %struct.P, ptr %33, i32 0, i32 1
  store i64 %30, ptr %34, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %23
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !9
  br label %17, !llvm.loop !13

38:                                               ; preds = %22
  %39 = getelementptr inbounds %struct.P, ptr %16, i64 1
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.P, ptr %16, i64 %40
  %42 = getelementptr inbounds %struct.P, ptr %41, i64 1
  call void @_ZSt4sortIP1PPFbS0_S0_EEvT_S4_T0_(ptr noundef %39, ptr noundef %42, ptr noundef @_Z3com1PS_)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6)
  %44 = load i64, ptr %6, align 8, !tbaa !5
  %45 = alloca %struct.event, i64 %44, align 16
  store i64 %44, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %72, %38
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = load i64, ptr %6, align 8, !tbaa !5
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %75

52:                                               ; preds = %46
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.event, ptr %45, i64 %54
  %56 = getelementptr inbounds %struct.event, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.event, ptr %45, i64 %58
  %60 = getelementptr inbounds %struct.event, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %struct.event, ptr %45, i64 %62
  %64 = getelementptr inbounds %struct.event, ptr %63, i32 0, i32 0
  %65 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %56, ptr noundef %60, ptr noundef %64)
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.event, ptr %45, i64 %69
  %71 = getelementptr inbounds %struct.event, ptr %70, i32 0, i32 3
  store i64 %67, ptr %71, align 8, !tbaa !15
  br label %72

72:                                               ; preds = %52
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %8, align 4, !tbaa !9
  br label %46, !llvm.loop !17

75:                                               ; preds = %51
  %76 = load i64, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.event, ptr %45, i64 %76
  call void @_ZSt4sortIP5eventPFbS0_S0_EEvT_S4_T0_(ptr noundef %45, ptr noundef %77, ptr noundef @_Z7compare5eventS_)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 1, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %124, %75
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = load i64, ptr %6, align 8, !tbaa !5
  %82 = icmp slt i64 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %127

84:                                               ; preds = %78
  br label %85

85:                                               ; preds = %96, %84
  %86 = load i64, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.P, ptr %16, i64 %86
  %88 = getelementptr inbounds %struct.P, ptr %87, i32 0, i32 0
  %89 = load i64, ptr %88, align 16, !tbaa !18
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.event, ptr %45, i64 %91
  %93 = getelementptr inbounds %struct.event, ptr %92, i32 0, i32 0
  %94 = load i64, ptr %93, align 16, !tbaa !19
  %95 = icmp sgt i64 %89, %94
  br i1 %95, label %96, label %103

96:                                               ; preds = %85
  %97 = load i64, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.P, ptr %16, i64 %97
  %99 = getelementptr inbounds %struct.P, ptr %98, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !11
  call void @_Z6updatexx(i64 noundef %100, i64 noundef 1)
  %101 = load i64, ptr %9, align 8, !tbaa !5
  %102 = add nsw i64 %101, 1
  store i64 %102, ptr %9, align 8, !tbaa !5
  br label %85, !llvm.loop !20

103:                                              ; preds = %85
  %104 = load i32, ptr %10, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.event, ptr %45, i64 %105
  %107 = getelementptr inbounds %struct.event, ptr %106, i32 0, i32 2
  %108 = load i64, ptr %107, align 16, !tbaa !21
  %109 = call noundef i64 @_Z5querix(i64 noundef %108)
  %110 = load i32, ptr %10, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %struct.event, ptr %45, i64 %111
  %113 = getelementptr inbounds %struct.event, ptr %112, i32 0, i32 1
  %114 = load i64, ptr %113, align 8, !tbaa !22
  %115 = sub nsw i64 %114, 1
  %116 = call noundef i64 @_Z5querix(i64 noundef %115)
  %117 = sub nsw i64 %109, %116
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.event, ptr %45, i64 %119
  %121 = getelementptr inbounds %struct.event, ptr %120, i32 0, i32 3
  %122 = load i64, ptr %121, align 8, !tbaa !15
  %123 = getelementptr inbounds [200005 x i64], ptr @ans, i64 0, i64 %122
  store i64 %117, ptr %123, align 8, !tbaa !5
  br label %124

124:                                              ; preds = %103
  %125 = load i32, ptr %10, align 4, !tbaa !9
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %10, align 4, !tbaa !9
  br label %78, !llvm.loop !23

127:                                              ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %128

128:                                              ; preds = %140, %127
  %129 = load i32, ptr %11, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = load i64, ptr %6, align 8, !tbaa !5
  %132 = icmp slt i64 %130, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %128
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %143

134:                                              ; preds = %128
  %135 = load i32, ptr %11, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [200005 x i64], ptr @ans, i64 0, i64 %136
  %138 = load i64, ptr %137, align 8, !tbaa !5
  %139 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %138)
  br label %140

140:                                              ; preds = %134
  %141 = load i32, ptr %11, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %11, align 4, !tbaa !9
  br label %128, !llvm.loop !24

143:                                              ; preds = %133
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %144 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %144)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %145 = load i32, ptr %1, align 4
  ret i32 %145
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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 = { 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 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS1P", !6, i64 0, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 24}
!16 = !{!"_ZTS5event", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = distinct !{!17, !14}
!18 = !{!12, !6, i64 0}
!19 = !{!16, !6, i64 0}
!20 = distinct !{!20, !14}
!21 = !{!16, !6, i64 16}
!22 = !{!16, !6, i64 8}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !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"

%struct.event = type { i64, i64, i64, i64 }
%struct.P = type { i64, i64 }

@ans = external dso_local local_unnamed_addr global [200005 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3com1PS_(i64, i64, i64, i64) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7compare5eventS_(ptr noundef byval(%struct.event) align 8, ptr noundef byval(%struct.event) align 8) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updatexx(i64 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = add nsw i64 %4, 1
  %6 = call ptr @llvm.stacksave.p0()
  %7 = alloca %struct.P, i64 %5, align 16
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %.not37 = icmp slt i64 %8, 1
  br i1 %.not37, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa36 = phi i64 [ %8, %0 ], [ %19, %.lr.ph ]
  %9 = getelementptr inbounds i8, ptr %7, i64 16
  %10 = getelementptr inbounds %struct.P, ptr %7, i64 %.lcssa36
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  call void @_ZSt4sortIP1PPFbS0_S0_EEvT_S4_T0_(ptr noundef nonnull %9, ptr noundef nonnull %11, ptr noundef nonnull @_Z3com1PS_)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = alloca %struct.event, i64 %13, align 16
  %15 = icmp sgt i64 %13, 0
  br i1 %15, label %.lr.ph41, label %._crit_edge42

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %16 = getelementptr inbounds %struct.P, ptr %7, i64 %indvars.iv
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %16)
  %18 = getelementptr inbounds i8, ptr %16, i64 8
  store i64 %indvars.iv, ptr %18, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not = icmp sgt i64 %19, %indvars.iv
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge42:                                    ; preds = %.lr.ph41, %._crit_edge
  %.lcssa35 = phi i64 [ %13, %._crit_edge ], [ %28, %.lr.ph41 ]
  %20 = getelementptr inbounds %struct.event, ptr %14, i64 %.lcssa35
  call void @_ZSt4sortIP5eventPFbS0_S0_EEvT_S4_T0_(ptr noundef nonnull %14, ptr noundef nonnull %20, ptr noundef nonnull @_Z7compare5eventS_)
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %.preheader34, label %._crit_edge53

.lr.ph41:                                         ; preds = %._crit_edge, %.lr.ph41
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.lr.ph41 ], [ 0, %._crit_edge ]
  %23 = getelementptr inbounds %struct.event, ptr %14, i64 %indvars.iv57
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = getelementptr inbounds i8, ptr %23, i64 16
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %24, ptr noundef nonnull %25, ptr noundef nonnull %23)
  %27 = getelementptr inbounds i8, ptr %23, i64 24
  store i64 %indvars.iv57, ptr %27, align 8, !tbaa !13
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %28 = load i64, ptr %2, align 8, !tbaa !5
  %29 = icmp sgt i64 %28, %indvars.iv.next58
  br i1 %29, label %.lr.ph41, label %._crit_edge42, !llvm.loop !15

.preheader34:                                     ; preds = %._crit_edge42, %._crit_edge46
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %._crit_edge46 ], [ 0, %._crit_edge42 ]
  %.02649 = phi i64 [ %.1.lcssa, %._crit_edge46 ], [ 1, %._crit_edge42 ]
  %30 = getelementptr inbounds %struct.event, ptr %14, i64 %indvars.iv60
  %31 = getelementptr inbounds %struct.P, ptr %7, i64 %.02649
  %32 = load i64, ptr %31, align 16, !tbaa !16
  %33 = load i64, ptr %30, align 16, !tbaa !17
  %34 = icmp sgt i64 %32, %33
  br i1 %34, label %.lr.ph45, label %._crit_edge46

.preheader:                                       ; preds = %._crit_edge46
  %35 = icmp sgt i64 %54, 0
  br i1 %35, label %.lr.ph52, label %._crit_edge53

.lr.ph45:                                         ; preds = %.preheader34, %.lr.ph45
  %.144 = phi i64 [ %38, %.lr.ph45 ], [ %.02649, %.preheader34 ]
  %36 = getelementptr inbounds %struct.P, ptr %7, i64 %.144, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !9
  call void @_Z6updatexx(i64 noundef %37, i64 noundef 1)
  %38 = add nsw i64 %.144, 1
  %39 = getelementptr inbounds %struct.P, ptr %7, i64 %38
  %40 = load i64, ptr %39, align 16, !tbaa !16
  %41 = load i64, ptr %30, align 16, !tbaa !17
  %42 = icmp sgt i64 %40, %41
  br i1 %42, label %.lr.ph45, label %._crit_edge46, !llvm.loop !18

._crit_edge46:                                    ; preds = %.lr.ph45, %.preheader34
  %.1.lcssa = phi i64 [ %.02649, %.preheader34 ], [ %38, %.lr.ph45 ]
  %43 = getelementptr inbounds i8, ptr %30, i64 16
  %44 = load i64, ptr %43, align 16, !tbaa !19
  %45 = call noundef i64 @_Z5querix(i64 noundef %44)
  %46 = getelementptr inbounds i8, ptr %30, i64 8
  %47 = load i64, ptr %46, align 8, !tbaa !20
  %48 = add nsw i64 %47, -1
  %49 = call noundef i64 @_Z5querix(i64 noundef %48)
  %50 = sub nsw i64 %45, %49
  %51 = getelementptr inbounds i8, ptr %30, i64 24
  %52 = load i64, ptr %51, align 8, !tbaa !13
  %53 = getelementptr inbounds [200005 x i64], ptr @ans, i64 0, i64 %52
  store i64 %50, ptr %53, align 8, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %54 = load i64, ptr %2, align 8, !tbaa !5
  %55 = icmp sgt i64 %54, %indvars.iv.next61
  br i1 %55, label %.preheader34, label %.preheader, !llvm.loop !21

._crit_edge53:                                    ; preds = %.lr.ph52, %._crit_edge42, %.preheader
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.stackrestore.p0(ptr %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 0

.lr.ph52:                                         ; preds = %.preheader, %.lr.ph52
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %.lr.ph52 ], [ 0, %.preheader ]
  %56 = getelementptr inbounds [200005 x i64], ptr @ans, i64 0, i64 %indvars.iv63
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %57)
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %59 = load i64, ptr %2, align 8, !tbaa !5
  %60 = icmp sgt i64 %59, %indvars.iv.next64
  br i1 %60, label %.lr.ph52, label %._crit_edge53, !llvm.loop !22
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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 = { 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 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS1P", !6, i64 0, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 24}
!14 = !{!"_ZTS5event", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = distinct !{!15, !12}
!16 = !{!10, !6, i64 0}
!17 = !{!14, !6, i64 0}
!18 = distinct !{!18, !12}
!19 = !{!14, !6, i64 16}
!20 = !{!14, !6, i64 8}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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