; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2014.12 (marathon)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@s = external dso_local global ptr, align 8
@N = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@x = external dso_local global [100000 x i32], align 16
@y = external dso_local global [100000 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", 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
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %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
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %16
  %18 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %17, ptr noundef null)
  %19 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %20 = load ptr, ptr @stdin, align 8, !tbaa !8
  %21 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %20)
  %22 = load ptr, ptr @stdout, align 8, !tbaa !8
  %23 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %22)
  %24 = 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)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %40, %0
  %27 = load i32, ptr %2, align 4, !tbaa !11
  %28 = load i32, ptr @N, align 4, !tbaa !11
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %43

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100000 x i32], ptr @x, i64 0, i64 %33
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %34)
  %36 = load i32, ptr %2, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100000 x i32], ptr @y, i64 0, i64 %37
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 4 dereferenceable(4) %38)
  br label %40

40:                                               ; preds = %31
  %41 = load i32, ptr %2, align 4, !tbaa !11
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %2, align 4, !tbaa !11
  br label %26, !llvm.loop !13

43:                                               ; preds = %30
  %44 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #9
  %45 = load i32, ptr @N, align 4, !tbaa !11
  %46 = sub nsw i32 %45, 1
  invoke void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %44, i32 noundef 0, i32 noundef %46)
          to label %47 unwind label %53

47:                                               ; preds = %43
  store ptr %44, ptr @s, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %68, %47
  %49 = load i32, ptr %5, align 4, !tbaa !11
  %50 = load i32, ptr @N, align 4, !tbaa !11
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %57, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %71

53:                                               ; preds = %43
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %3, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %44, i64 noundef 40) #10
  br label %146

57:                                               ; preds = %48
  %58 = load ptr, ptr @s, align 8, !tbaa !8
  %59 = load i32, ptr %5, align 4, !tbaa !11
  %60 = load i32, ptr %5, align 4, !tbaa !11
  %61 = sub nsw i32 %60, 1
  %62 = load i32, ptr %5, align 4, !tbaa !11
  %63 = call noundef i32 @_Z4distii(i32 noundef %61, i32 noundef %62)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %58, i32 noundef %59, i32 noundef %63, i1 noundef zeroext false)
  %64 = load ptr, ptr @s, align 8, !tbaa !8
  %65 = load i32, ptr %5, align 4, !tbaa !11
  %66 = load i32, ptr %5, align 4, !tbaa !11
  %67 = call noundef i32 @_Z4diffi(i32 noundef %66)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %64, i32 noundef %65, i32 noundef %67, i1 noundef zeroext true)
  br label %68

68:                                               ; preds = %57
  %69 = load i32, ptr %5, align 4, !tbaa !11
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !11
  br label %48, !llvm.loop !15

71:                                               ; preds = %52
  br label %72

72:                                               ; preds = %143, %71
  %73 = load i32, ptr @Q, align 4, !tbaa !11
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr @Q, align 4, !tbaa !11
  %75 = icmp ne i32 %73, 0
  br i1 %75, label %76, label %144

76:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #8
  %77 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %6)
  %78 = load i8, ptr %6, align 1, !tbaa !16
  %79 = sext i8 %78 to i32
  %80 = icmp eq i32 %79, 85
  br i1 %80, label %81, label %125

81:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %82 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %83 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %82, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %84 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %83, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %85 = load i32, ptr %8, align 4, !tbaa !11
  %86 = load i32, ptr %7, align 4, !tbaa !11
  %87 = sub nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100000 x i32], ptr @x, i64 0, i64 %88
  store i32 %85, ptr %89, align 4, !tbaa !11
  %90 = load i32, ptr %9, align 4, !tbaa !11
  %91 = load i32, ptr %7, align 4, !tbaa !11
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100000 x i32], ptr @y, i64 0, i64 %93
  store i32 %90, ptr %94, align 4, !tbaa !11
  %95 = load ptr, ptr @s, align 8, !tbaa !8
  %96 = load i32, ptr %7, align 4, !tbaa !11
  %97 = sub nsw i32 %96, 1
  %98 = load i32, ptr %7, align 4, !tbaa !11
  %99 = sub nsw i32 %98, 2
  %100 = load i32, ptr %7, align 4, !tbaa !11
  %101 = sub nsw i32 %100, 1
  %102 = call noundef i32 @_Z4distii(i32 noundef %99, i32 noundef %101)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %95, i32 noundef %97, i32 noundef %102, i1 noundef zeroext false)
  %103 = load ptr, ptr @s, align 8, !tbaa !8
  %104 = load i32, ptr %7, align 4, !tbaa !11
  %105 = load i32, ptr %7, align 4, !tbaa !11
  %106 = sub nsw i32 %105, 1
  %107 = load i32, ptr %7, align 4, !tbaa !11
  %108 = call noundef i32 @_Z4distii(i32 noundef %106, i32 noundef %107)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %103, i32 noundef %104, i32 noundef %108, i1 noundef zeroext false)
  %109 = load ptr, ptr @s, align 8, !tbaa !8
  %110 = load i32, ptr %7, align 4, !tbaa !11
  %111 = sub nsw i32 %110, 1
  %112 = load i32, ptr %7, align 4, !tbaa !11
  %113 = sub nsw i32 %112, 1
  %114 = call noundef i32 @_Z4diffi(i32 noundef %113)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %109, i32 noundef %111, i32 noundef %114, i1 noundef zeroext true)
  %115 = load ptr, ptr @s, align 8, !tbaa !8
  %116 = load i32, ptr %7, align 4, !tbaa !11
  %117 = sub nsw i32 %116, 2
  %118 = load i32, ptr %7, align 4, !tbaa !11
  %119 = sub nsw i32 %118, 2
  %120 = call noundef i32 @_Z4diffi(i32 noundef %119)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %115, i32 noundef %117, i32 noundef %120, i1 noundef zeroext true)
  %121 = load ptr, ptr @s, align 8, !tbaa !8
  %122 = load i32, ptr %7, align 4, !tbaa !11
  %123 = load i32, ptr %7, align 4, !tbaa !11
  %124 = call noundef i32 @_Z4diffi(i32 noundef %123)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %121, i32 noundef %122, i32 noundef %124, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %143

125:                                              ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %126 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %127 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %126, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %128 = load ptr, ptr @s, align 8, !tbaa !8
  %129 = load i32, ptr %10, align 4, !tbaa !11
  %130 = load i32, ptr %11, align 4, !tbaa !11
  %131 = sub nsw i32 %130, 1
  %132 = call noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40) %128, i32 noundef %129, i32 noundef %131, i1 noundef zeroext false)
  store i32 %132, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %133 = load ptr, ptr @s, align 8, !tbaa !8
  %134 = load i32, ptr %10, align 4, !tbaa !11
  %135 = load i32, ptr %11, align 4, !tbaa !11
  %136 = sub nsw i32 %135, 2
  %137 = call noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40) %133, i32 noundef %134, i32 noundef %136, i1 noundef zeroext true)
  store i32 %137, ptr %13, align 4, !tbaa !11
  %138 = load i32, ptr %12, align 4, !tbaa !11
  %139 = load i32, ptr %13, align 4, !tbaa !11
  %140 = add nsw i32 %138, %139
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %140)
  %142 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %141, ptr noundef @.str.4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %143

143:                                              ; preds = %125, %81
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #8
  br label %72, !llvm.loop !17

144:                                              ; preds = %72
  %145 = load i32, ptr %1, align 4
  ret i32 %145

146:                                              ; preds = %53
  %147 = load ptr, ptr %3, align 8
  %148 = load i32, ptr %4, align 4
  %149 = insertvalue { ptr, i32 } poison, ptr %147, 0
  %150 = insertvalue { ptr, i32 } %149, i32 %148, 1
  resume { ptr, i32 } %150
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

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

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

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

; Function Attrs: 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) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) unnamed_addr #5 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i1 noundef zeroext) #5 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i1 noundef zeroext) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #7

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #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 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 = { 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 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@s = external dso_local local_unnamed_addr global ptr, align 8
@N = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@x = external dso_local global [100000 x i32], align 16
@y = external dso_local global [100000 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", 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
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i8, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = load ptr, ptr @stdin, align 8, !tbaa !8
  %14 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %13)
  %15 = load ptr, ptr @stdout, align 8, !tbaa !8
  %16 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %15)
  %17 = 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)
  %18 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  %19 = load i32, ptr @N, align 4, !tbaa !11
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %19, %0 ], [ %27, %.lr.ph ]
  %21 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #8
  %22 = add nsw i32 %.lcssa, -1
  invoke void @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %21, i32 noundef 0, i32 noundef %22)
          to label %30 unwind label %35

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %23 = getelementptr inbounds [100000 x i32], ptr @x, i64 0, i64 %indvars.iv
  %24 = 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) %23)
  %25 = getelementptr inbounds [100000 x i32], ptr @y, i64 0, i64 %indvars.iv
  %26 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(4) %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr @N, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !13

30:                                               ; preds = %._crit_edge
  store ptr %21, ptr @s, align 8, !tbaa !8
  %31 = load i32, ptr @N, align 4, !tbaa !11
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph19, label %.preheader

.preheader:                                       ; preds = %.lr.ph19, %30
  %33 = load i32, ptr @Q, align 4, !tbaa !11
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr @Q, align 4, !tbaa !11
  %.not20 = icmp eq i32 %33, 0
  br i1 %.not20, label %._crit_edge22, label %.lr.ph21

35:                                               ; preds = %._crit_edge
  %36 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %21, i64 noundef 40) #9
  resume { ptr, i32 } %36

.lr.ph19:                                         ; preds = %30, %.lr.ph19
  %.01517 = phi i32 [ %42, %.lr.ph19 ], [ 0, %30 ]
  %37 = load ptr, ptr @s, align 8, !tbaa !8
  %38 = add nsw i32 %.01517, -1
  %39 = tail call noundef i32 @_Z4distii(i32 noundef %38, i32 noundef %.01517)
  tail call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %37, i32 noundef %.01517, i32 noundef %39, i1 noundef zeroext false)
  %40 = load ptr, ptr @s, align 8, !tbaa !8
  %41 = tail call noundef i32 @_Z4diffi(i32 noundef %.01517)
  tail call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %40, i32 noundef %.01517, i32 noundef %41, i1 noundef zeroext true)
  %42 = add nuw nsw i32 %.01517, 1
  %43 = load i32, ptr @N, align 4, !tbaa !11
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %.lr.ph19, label %.preheader, !llvm.loop !15

.lr.ph21:                                         ; preds = %.preheader, %93
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #10
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %1)
  %46 = load i8, ptr %1, align 1, !tbaa !16
  %47 = icmp eq i8 %46, 85
  br i1 %47, label %48, label %77

48:                                               ; preds = %.lr.ph21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #10
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %49, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %51 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %52 = load i32, ptr %3, align 4, !tbaa !11
  %53 = load i32, ptr %2, align 4, !tbaa !11
  %54 = add nsw i32 %53, -1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100000 x i32], ptr @x, i64 0, i64 %55
  store i32 %52, ptr %56, align 4, !tbaa !11
  %57 = load i32, ptr %4, align 4, !tbaa !11
  %58 = getelementptr inbounds [100000 x i32], ptr @y, i64 0, i64 %55
  store i32 %57, ptr %58, align 4, !tbaa !11
  %59 = load ptr, ptr @s, align 8, !tbaa !8
  %60 = add nsw i32 %53, -2
  %61 = call noundef i32 @_Z4distii(i32 noundef %60, i32 noundef %54)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %59, i32 noundef %54, i32 noundef %61, i1 noundef zeroext false)
  %62 = load ptr, ptr @s, align 8, !tbaa !8
  %63 = load i32, ptr %2, align 4, !tbaa !11
  %64 = add nsw i32 %63, -1
  %65 = call noundef i32 @_Z4distii(i32 noundef %64, i32 noundef %63)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %62, i32 noundef %63, i32 noundef %65, i1 noundef zeroext false)
  %66 = load ptr, ptr @s, align 8, !tbaa !8
  %67 = load i32, ptr %2, align 4, !tbaa !11
  %68 = add nsw i32 %67, -1
  %69 = call noundef i32 @_Z4diffi(i32 noundef %68)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %66, i32 noundef %68, i32 noundef %69, i1 noundef zeroext true)
  %70 = load ptr, ptr @s, align 8, !tbaa !8
  %71 = load i32, ptr %2, align 4, !tbaa !11
  %72 = add nsw i32 %71, -2
  %73 = call noundef i32 @_Z4diffi(i32 noundef %72)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %70, i32 noundef %72, i32 noundef %73, i1 noundef zeroext true)
  %74 = load ptr, ptr @s, align 8, !tbaa !8
  %75 = load i32, ptr %2, align 4, !tbaa !11
  %76 = call noundef i32 @_Z4diffi(i32 noundef %75)
  call void @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40) %74, i32 noundef %75, i32 noundef %76, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #10
  br label %93

77:                                               ; preds = %.lr.ph21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #10
  %78 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %79 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %78, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %80 = load ptr, ptr @s, align 8, !tbaa !8
  %81 = load i32, ptr %5, align 4, !tbaa !11
  %82 = load i32, ptr %6, align 4, !tbaa !11
  %83 = add nsw i32 %82, -1
  %84 = call noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40) %80, i32 noundef %81, i32 noundef %83, i1 noundef zeroext false)
  %85 = load ptr, ptr @s, align 8, !tbaa !8
  %86 = load i32, ptr %5, align 4, !tbaa !11
  %87 = load i32, ptr %6, align 4, !tbaa !11
  %88 = add nsw i32 %87, -2
  %89 = call noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40) %85, i32 noundef %86, i32 noundef %88, i1 noundef zeroext true)
  %90 = add nsw i32 %89, %84
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %90)
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %91, ptr noundef nonnull @.str.4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #10
  br label %93

93:                                               ; preds = %77, %48
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #10
  %94 = load i32, ptr @Q, align 4, !tbaa !11
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr @Q, align 4, !tbaa !11
  %.not = icmp eq i32 %94, 0
  br i1 %.not, label %._crit_edge22, label %.lr.ph21, !llvm.loop !17

._crit_edge22:                                    ; preds = %93, %.preheader
  ret i32 0
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

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

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 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 @_ZN4segtC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) 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 @_ZN4segt3updEiib(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #5 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4segt3qryEiib(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #7

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 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 = { 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 = { 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 #8 = { builtin allocsize(0) }
attributes #9 = { builtin nounwind }
attributes #10 = { 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 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !14}


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