; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2015.12 (haybales)

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

@N = external dso_local global i64, align 8
@Q = external dso_local global i64, align 8
@h = external dso_local global [200000 x i64], align 16
@ts = external dso_local global ptr, align 8
@tmin = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %14 = load ptr, ptr @stdin, align 8, !tbaa !5
  %15 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %14)
  %16 = load ptr, ptr @stdout, align 8, !tbaa !5
  %17 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %16)
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @N, ptr noundef @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %28, %0
  %20 = load i64, ptr %2, align 8, !tbaa !9
  %21 = load i64, ptr @N, align 8, !tbaa !9
  %22 = icmp slt i64 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i64, ptr %2, align 8, !tbaa !9
  %26 = getelementptr inbounds [200000 x i64], ptr @h, i64 0, i64 %25
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %26)
  br label %28

28:                                               ; preds = %24
  %29 = load i64, ptr %2, align 8, !tbaa !9
  %30 = add nsw i64 %29, 1
  store i64 %30, ptr %2, align 8, !tbaa !9
  br label %19, !llvm.loop !11

31:                                               ; preds = %23
  %32 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #8
  %33 = load i64, ptr @N, align 8, !tbaa !9
  %34 = sub nsw i64 %33, 1
  invoke void @_ZN4segtC2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48) %32, i64 noundef 0, i64 noundef %34, ptr noundef nonnull align 8 dereferenceable(1600000) @h)
          to label %35 unwind label %45

35:                                               ; preds = %31
  store ptr %32, ptr @ts, align 8, !tbaa !5
  %36 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #8
  %37 = load i64, ptr @N, align 8, !tbaa !9
  %38 = sub nsw i64 %37, 1
  invoke void @_ZN5segt2C2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48) %36, i64 noundef 0, i64 noundef %38, ptr noundef nonnull align 8 dereferenceable(1600000) @h)
          to label %39 unwind label %49

39:                                               ; preds = %35
  store ptr %36, ptr @tmin, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %99, %39
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = load i64, ptr @Q, align 8, !tbaa !9
  %43 = icmp slt i64 %41, %42
  br i1 %43, label %53, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %102

45:                                               ; preds = %31
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %3, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %32, i64 noundef 48) #9
  br label %112

49:                                               ; preds = %35
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %3, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %36, i64 noundef 48) #9
  br label %112

53:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  %54 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.6, ptr noundef %6)
  %55 = load i8, ptr %6, align 1, !tbaa !13
  %56 = sext i8 %55 to i32
  %57 = icmp eq i32 %56, 83
  br i1 %57, label %58, label %67

58:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %59 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.7, ptr noundef %7, ptr noundef %8)
  %60 = load ptr, ptr @ts, align 8, !tbaa !5
  %61 = load i64, ptr %7, align 8, !tbaa !9
  %62 = sub nsw i64 %61, 1
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = sub nsw i64 %63, 1
  %65 = call noundef i64 @_ZN4segt3qryExx(ptr noundef nonnull align 8 dereferenceable(48) %60, i64 noundef %62, i64 noundef %64)
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %67

67:                                               ; preds = %58, %53
  %68 = load i8, ptr %6, align 1, !tbaa !13
  %69 = sext i8 %68 to i32
  %70 = icmp eq i32 %69, 80
  br i1 %70, label %71, label %85

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %72 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.9, ptr noundef %9, ptr noundef %10, ptr noundef %11)
  %73 = load ptr, ptr @ts, align 8, !tbaa !5
  %74 = load i64, ptr %9, align 8, !tbaa !9
  %75 = sub nsw i64 %74, 1
  %76 = load i64, ptr %10, align 8, !tbaa !9
  %77 = sub nsw i64 %76, 1
  %78 = load i64, ptr %11, align 8, !tbaa !9
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(48) %73, i64 noundef %75, i64 noundef %77, i64 noundef %78)
  %79 = load ptr, ptr @tmin, align 8, !tbaa !5
  %80 = load i64, ptr %9, align 8, !tbaa !9
  %81 = sub nsw i64 %80, 1
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = sub nsw i64 %82, 1
  %84 = load i64, ptr %11, align 8, !tbaa !9
  call void @_ZN5segt23updExxx(ptr noundef nonnull align 8 dereferenceable(48) %79, i64 noundef %81, i64 noundef %83, i64 noundef %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %85

85:                                               ; preds = %71, %67
  %86 = load i8, ptr %6, align 1, !tbaa !13
  %87 = sext i8 %86 to i32
  %88 = icmp eq i32 %87, 77
  br i1 %88, label %89, label %98

89:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %90 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.7, ptr noundef %12, ptr noundef %13)
  %91 = load ptr, ptr @tmin, align 8, !tbaa !5
  %92 = load i64, ptr %12, align 8, !tbaa !9
  %93 = sub nsw i64 %92, 1
  %94 = load i64, ptr %13, align 8, !tbaa !9
  %95 = sub nsw i64 %94, 1
  %96 = call noundef i64 @_ZN5segt23qryExx(ptr noundef nonnull align 8 dereferenceable(48) %91, i64 noundef %93, i64 noundef %95)
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %96)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %98

98:                                               ; preds = %89, %85
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  br label %99

99:                                               ; preds = %98
  %100 = load i64, ptr %5, align 8, !tbaa !9
  %101 = add nsw i64 %100, 1
  store i64 %101, ptr %5, align 8, !tbaa !9
  br label %40, !llvm.loop !14

102:                                              ; preds = %44
  %103 = load ptr, ptr @ts, align 8, !tbaa !5
  %104 = icmp eq ptr %103, null
  br i1 %104, label %106, label %105

105:                                              ; preds = %102
  call void @_ZN4segtD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %103) #7
  call void @_ZdlPvm(ptr noundef %103, i64 noundef 48) #9
  br label %106

106:                                              ; preds = %105, %102
  %107 = load ptr, ptr @tmin, align 8, !tbaa !5
  %108 = icmp eq ptr %107, null
  br i1 %108, label %110, label %109

109:                                              ; preds = %106
  call void @_ZN5segt2D2Ev(ptr noundef nonnull align 8 dereferenceable(48) %107) #7
  call void @_ZdlPvm(ptr noundef %107, i64 noundef 48) #9
  br label %110

110:                                              ; preds = %109, %106
  %111 = load i32, ptr %1, align 4
  ret i32 %111

112:                                              ; preds = %49, %45
  %113 = load ptr, ptr %3, align 8
  %114 = load i32, ptr %4, align 4
  %115 = insertvalue { ptr, i32 } poison, ptr %113, 0
  %116 = insertvalue { ptr, i32 } %115, i32 %114, 1
  resume { ptr, i32 } %116
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segtC2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(1600000)) unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5segt2C2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(1600000)) unnamed_addr #4 align 2

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4segtD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5segt2D2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #6 align 2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nobuiltin 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 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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 = !{!"any pointer", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


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

@N = external dso_local global i64, align 8
@Q = external dso_local global i64, align 8
@h = external dso_local global [200000 x i64], align 16
@ts = external dso_local local_unnamed_addr global ptr, align 8
@tmin = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i8, align 1
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = load ptr, ptr @stdin, align 8, !tbaa !5
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %9)
  %11 = load ptr, ptr @stdout, align 8, !tbaa !5
  %12 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %11)
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @N, ptr noundef nonnull @Q)
  %14 = load i64, ptr @N, align 8, !tbaa !9
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i64 [ %14, %0 ], [ %21, %.lr.ph ]
  %16 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #8
  %17 = add nsw i64 %.lcssa, -1
  invoke void @_ZN4segtC2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48) %16, i64 noundef 0, i64 noundef %17, ptr noundef nonnull align 8 dereferenceable(1600000) @h)
          to label %23 unwind label %32

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.0913 = phi i64 [ %20, %.lr.ph ], [ 0, %0 ]
  %18 = getelementptr inbounds [200000 x i64], ptr @h, i64 0, i64 %.0913
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %18)
  %20 = add nuw nsw i64 %.0913, 1
  %21 = load i64, ptr @N, align 8, !tbaa !9
  %22 = icmp slt i64 %20, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !11

23:                                               ; preds = %._crit_edge
  store ptr %16, ptr @ts, align 8, !tbaa !5
  %24 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #8
  %25 = load i64, ptr @N, align 8, !tbaa !9
  %26 = add nsw i64 %25, -1
  invoke void @_ZN5segt2C2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48) %24, i64 noundef 0, i64 noundef %26, ptr noundef nonnull align 8 dereferenceable(1600000) @h)
          to label %27 unwind label %34

27:                                               ; preds = %23
  store ptr %24, ptr @tmin, align 8, !tbaa !5
  %28 = load i64, ptr @Q, align 8, !tbaa !9
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph16, label %._crit_edge17

._crit_edge17:                                    ; preds = %77, %27
  %30 = load ptr, ptr @ts, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %82, label %81

32:                                               ; preds = %._crit_edge
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %87

34:                                               ; preds = %23
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %87

.lr.ph16:                                         ; preds = %27, %77
  %.014 = phi i64 [ %78, %77 ], [ 0, %27 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #9
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.6, ptr noundef nonnull %1)
  %37 = load i8, ptr %1, align 1, !tbaa !13
  %38 = icmp eq i8 %37, 83
  br i1 %38, label %39, label %48

39:                                               ; preds = %.lr.ph16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #9
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.7, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %41 = load ptr, ptr @ts, align 8, !tbaa !5
  %42 = load i64, ptr %2, align 8, !tbaa !9
  %43 = add nsw i64 %42, -1
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %45 = add nsw i64 %44, -1
  %46 = call noundef i64 @_ZN4segt3qryExx(ptr noundef nonnull align 8 dereferenceable(48) %41, i64 noundef %43, i64 noundef %45)
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %46)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #9
  %.pr = load i8, ptr %1, align 1, !tbaa !13
  br label %48

48:                                               ; preds = %39, %.lr.ph16
  %49 = phi i8 [ %.pr, %39 ], [ %37, %.lr.ph16 ]
  %50 = icmp eq i8 %49, 80
  br i1 %50, label %51, label %65

51:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #9
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.9, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %53 = load ptr, ptr @ts, align 8, !tbaa !5
  %54 = load i64, ptr %4, align 8, !tbaa !9
  %55 = add nsw i64 %54, -1
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = add nsw i64 %56, -1
  %58 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(48) %53, i64 noundef %55, i64 noundef %57, i64 noundef %58)
  %59 = load ptr, ptr @tmin, align 8, !tbaa !5
  %60 = load i64, ptr %4, align 8, !tbaa !9
  %61 = add nsw i64 %60, -1
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = add nsw i64 %62, -1
  %64 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN5segt23updExxx(ptr noundef nonnull align 8 dereferenceable(48) %59, i64 noundef %61, i64 noundef %63, i64 noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #9
  %.pre = load i8, ptr %1, align 1, !tbaa !13
  br label %65

65:                                               ; preds = %51, %48
  %66 = phi i8 [ %.pre, %51 ], [ %49, %48 ]
  %67 = icmp eq i8 %66, 77
  br i1 %67, label %68, label %77

68:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #9
  %69 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.7, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %70 = load ptr, ptr @tmin, align 8, !tbaa !5
  %71 = load i64, ptr %7, align 8, !tbaa !9
  %72 = add nsw i64 %71, -1
  %73 = load i64, ptr %8, align 8, !tbaa !9
  %74 = add nsw i64 %73, -1
  %75 = call noundef i64 @_ZN5segt23qryExx(ptr noundef nonnull align 8 dereferenceable(48) %70, i64 noundef %72, i64 noundef %74)
  %76 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %75)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #9
  br label %77

77:                                               ; preds = %68, %65
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #9
  %78 = add nuw nsw i64 %.014, 1
  %79 = load i64, ptr @Q, align 8, !tbaa !9
  %80 = icmp slt i64 %78, %79
  br i1 %80, label %.lr.ph16, label %._crit_edge17, !llvm.loop !14

81:                                               ; preds = %._crit_edge17
  call void @_ZN4segtD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %30) #9
  call void @_ZdlPvm(ptr noundef nonnull %30, i64 noundef 48) #10
  br label %82

82:                                               ; preds = %81, %._crit_edge17
  %83 = load ptr, ptr @tmin, align 8, !tbaa !5
  %84 = icmp eq ptr %83, null
  br i1 %84, label %86, label %85

85:                                               ; preds = %82
  call void @_ZN5segt2D2Ev(ptr noundef nonnull align 8 dereferenceable(48) %83) #9
  call void @_ZdlPvm(ptr noundef nonnull %83, i64 noundef 48) #10
  br label %86

86:                                               ; preds = %85, %82
  ret i32 0

87:                                               ; preds = %34, %32
  %.sink = phi ptr [ %24, %34 ], [ %16, %32 ]
  %.pn = phi { ptr, i32 } [ %35, %34 ], [ %33, %32 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.sink, i64 noundef 48) #10
  resume { ptr, i32 } %.pn
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segtC2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(1600000)) unnamed_addr #5 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5segt2C2ExxRA200000_x(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(1600000)) unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN4segt3qryExx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segt3updExxx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5segt23updExxx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN5segt23qryExx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4segtD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #7 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5segt2D2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #7 align 2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress 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 = { nobuiltin 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 #7 = { 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 #8 = { builtin allocsize(0) }
attributes #9 = { nounwind }
attributes #10 = { builtin 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 = !{!"any pointer", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


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