; LLVM IR from tangjz/acm-icpc :: hackerrank (chocolate-game)

; 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 i32, align 4
@a = external dso_local global [100003 x i32], align 16
@f = external dso_local global [100003 x i32], align 16
@tot = external dso_local global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@cnt = external dso_local global [2 x [100003 x i32]], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %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
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %18, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i32, ptr @a, i64 %15
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %16)
  br label %18

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !9

21:                                               ; preds = %12
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = add nsw i32 %22, 2
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %24
  store i32 0, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %28
  store i32 0, ptr %29, align 4, !tbaa !5
  store i32 0, ptr @a, align 16, !tbaa !5
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %32
  store i32 0, ptr %33, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %34 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %34, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %67, %21
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp sge i32 %36, 1
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %70

39:                                               ; preds = %35
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = add nsw i32 %40, 2
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sub nsw i32 %48, %53
  %55 = xor i32 %44, %54
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %57
  store i32 %55, ptr %58, align 4, !tbaa !5
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = load i32, ptr @tot, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @tot, align 4, !tbaa !5
  %65 = sext i32 %63 to i64
  %66 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %39
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !11

70:                                               ; preds = %38
  %71 = load i32, ptr @tot, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr @que, i64 %72
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %73)
  %74 = load i32, ptr @tot, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr @que, i64 %75
  %77 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %76)
  %78 = ptrtoint ptr %77 to i64
  %79 = sub i64 %78, ptrtoint (ptr @que to i64)
  %80 = sdiv exact i64 %79, 4
  %81 = trunc i64 %80 to i32
  store i32 %81, ptr @tot, align 4, !tbaa !5
  %82 = load i32, ptr @tot, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %83
  store i32 2147483647, ptr %84, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %85 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %85, ptr %4, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %167, %70
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = icmp sge i32 %87, 1
  br i1 %88, label %90, label %89

89:                                               ; preds = %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %170

90:                                               ; preds = %86
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = xor i32 %91, -1
  %93 = and i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %94
  %96 = load i32, ptr @tot, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i32, ptr @que, i64 %97
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %101
  %103 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %98, ptr noundef nonnull align 4 dereferenceable(4) %102)
  %104 = ptrtoint ptr %103 to i64
  %105 = sub i64 %104, ptrtoint (ptr @que to i64)
  %106 = sdiv exact i64 %105, 4
  %107 = getelementptr inbounds [100003 x i32], ptr %95, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = load i64, ptr @ans, align 8, !tbaa !12
  %111 = add nsw i64 %110, %109
  store i64 %111, ptr @ans, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %112 = load i32, ptr %4, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load i32, ptr %4, align 4, !tbaa !5
  %117 = add nsw i32 %116, 2
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = xor i32 %115, %120
  store i32 %121, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %122 = load i32, ptr @tot, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr @que, i64 %123
  %125 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %124, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %126 = ptrtoint ptr %125 to i64
  %127 = sub i64 %126, ptrtoint (ptr @que to i64)
  %128 = sdiv exact i64 %127, 4
  %129 = trunc i64 %128 to i32
  store i32 %129, ptr %6, align 4, !tbaa !5
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = load i32, ptr %5, align 4, !tbaa !5
  %135 = icmp eq i32 %133, %134
  br i1 %135, label %136, label %148

136:                                              ; preds = %90
  %137 = load i32, ptr %4, align 4, !tbaa !5
  %138 = and i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %139
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100003 x i32], ptr %140, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = load i64, ptr @ans, align 8, !tbaa !12
  %147 = add nsw i64 %146, %145
  store i64 %147, ptr @ans, align 8, !tbaa !12
  br label %148

148:                                              ; preds = %136, %90
  %149 = load i32, ptr %4, align 4, !tbaa !5
  %150 = and i32 %149, 1
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %151
  %153 = load i32, ptr @tot, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds i32, ptr @que, i64 %154
  %156 = load i32, ptr %4, align 4, !tbaa !5
  %157 = add nsw i32 %156, 2
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %158
  %160 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %155, ptr noundef nonnull align 4 dereferenceable(4) %159)
  %161 = ptrtoint ptr %160 to i64
  %162 = sub i64 %161, ptrtoint (ptr @que to i64)
  %163 = sdiv exact i64 %162, 4
  %164 = getelementptr inbounds [100003 x i32], ptr %152, i64 0, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %164, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %167

167:                                              ; preds = %148
  %168 = load i32, ptr %4, align 4, !tbaa !5
  %169 = add nsw i32 %168, -1
  store i32 %169, ptr %4, align 4, !tbaa !5
  br label %86, !llvm.loop !14

170:                                              ; preds = %89
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = load i32, ptr @n, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = sub nsw i64 %174, 1
  %176 = mul nsw i64 %172, %175
  %177 = ashr i64 %176, 1
  %178 = load i64, ptr @ans, align 8, !tbaa !12
  %179 = sub nsw i64 %177, %178
  %180 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %179)
  ret i32 0
}

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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}


; 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 i32, align 4
@a = external dso_local global [100003 x i32], align 16
@f = external dso_local global [100003 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@cnt = external dso_local local_unnamed_addr global [2 x [100003 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not25 = icmp slt i32 %3, 1
  br i1 %.not25, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %3, %0 ], [ %27, %.lr.ph ]
  %4 = add nsw i32 %.lcssa, 2
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %5
  store i32 0, ptr %6, align 4, !tbaa !5
  %7 = add nsw i32 %.lcssa, 1
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %8
  store i32 0, ptr %9, align 4, !tbaa !5
  store i32 0, ptr @a, align 16, !tbaa !5
  %10 = load i32, ptr @tot, align 4, !tbaa !5
  %11 = add i32 %10, 1
  store i32 %11, ptr @tot, align 4, !tbaa !5
  %12 = sext i32 %10 to i64
  %13 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %12
  store i32 0, ptr %13, align 4, !tbaa !5
  %14 = icmp sgt i32 %.lcssa, 0
  br i1 %14, label %.lr.ph29.preheader, label %30

.lr.ph29.preheader:                               ; preds = %._crit_edge
  %15 = zext nneg i32 %.lcssa to i64
  %16 = sext i32 %11 to i64
  %.phi.trans.insert = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %15
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %min.iters.check = icmp eq i32 %.lcssa, 1
  br i1 %min.iters.check, label %.lr.ph29.preheader59, label %vector.ph

.lr.ph29.preheader59:                             ; preds = %middle.block, %.lr.ph29.preheader
  %.ph = phi i32 [ %.pre, %.lr.ph29.preheader ], [ %vector.recur.extract, %middle.block ]
  %indvars.iv41.ph = phi i64 [ %16, %.lr.ph29.preheader ], [ %ind.end, %middle.block ]
  %indvars.iv39.ph = phi i64 [ %15, %.lr.ph29.preheader ], [ %ind.end53, %middle.block ]
  br label %.lr.ph29

vector.ph:                                        ; preds = %.lr.ph29.preheader
  %n.vec = and i64 %15, 2147483646
  %ind.end = add nsw i64 %n.vec, %16
  %ind.end53 = and i64 %15, 1
  %vector.recur.init = insertelement <2 x i32> poison, i32 %.pre, i64 1
  %17 = shl nuw nsw i64 %15, 2
  %18 = getelementptr i8, ptr @f, i64 %17
  %scevgep = getelementptr i8, ptr %18, i64 4
  %load_initial = load <2 x i32>, ptr %scevgep, align 4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %store_forwarded = phi <2 x i32> [ %load_initial, %vector.ph ], [ %reverse58, %vector.body ]
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vector.recur = phi <2 x i32> [ %vector.recur.init, %vector.ph ], [ %reverse57, %vector.body ]
  %offset.idx = add i64 %index, %16
  %offset.idx55 = sub i64 %15, %index
  %reverse = shufflevector <2 x i32> %store_forwarded, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
  %19 = add nsw i64 %offset.idx55, -1
  %gep = getelementptr [100003 x i32], ptr getelementptr (i8, ptr @a, i64 -4), i64 0, i64 %19
  %wide.load56 = load <2 x i32>, ptr %gep, align 4, !tbaa !5
  %reverse57 = shufflevector <2 x i32> %wide.load56, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
  %20 = shufflevector <2 x i32> %vector.recur, <2 x i32> %reverse57, <2 x i32> <i32 1, i32 2>
  %21 = sub nsw <2 x i32> %20, %reverse57
  %22 = xor <2 x i32> %21, %reverse
  %gep64 = getelementptr [100003 x i32], ptr getelementptr (i8, ptr @f, i64 -4), i64 0, i64 %offset.idx55
  %reverse58 = shufflevector <2 x i32> %22, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
  store <2 x i32> %reverse58, ptr %gep64, align 4, !tbaa !5
  %23 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %offset.idx
  store <2 x i32> %22, ptr %23, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %vector.recur.extract = extractelement <2 x i32> %wide.load56, i64 0
  %cmp.n = icmp eq i64 %n.vec, %15
  br i1 %cmp.n, label %._crit_edge30, label %.lr.ph29.preheader59

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %25 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %26 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %.not.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge30:                                    ; preds = %.lr.ph29, %middle.block
  %indvars.iv.next42.lcssa = phi i64 [ %ind.end, %middle.block ], [ %indvars.iv.next42, %.lr.ph29 ]
  %29 = trunc nsw i64 %indvars.iv.next42.lcssa to i32
  store i32 %29, ptr @tot, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %._crit_edge30, %._crit_edge
  %31 = phi i32 [ %29, %._crit_edge30 ], [ %11, %._crit_edge ]
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr @que, i64 %32
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %33)
  %34 = load i32, ptr @tot, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr @que, i64 %35
  %37 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %36)
  %38 = ptrtoint ptr %37 to i64
  %39 = sub i64 %38, ptrtoint (ptr @que to i64)
  %40 = lshr exact i64 %39, 2
  %41 = trunc i64 %40 to i32
  store i32 %41, ptr @tot, align 4, !tbaa !5
  %sext = shl i64 %39, 30
  %42 = ashr i64 %sext, 32
  %43 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %42
  store i32 2147483647, ptr %43, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph34.preheader, label %._crit_edge35

.lr.ph34.preheader:                               ; preds = %30
  %46 = zext nneg i32 %44 to i64
  br label %.lr.ph34

.lr.ph29:                                         ; preds = %.lr.ph29.preheader59, %.lr.ph29
  %47 = phi i32 [ %52, %.lr.ph29 ], [ %.ph, %.lr.ph29.preheader59 ]
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %.lr.ph29 ], [ %indvars.iv41.ph, %.lr.ph29.preheader59 ]
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph29 ], [ %indvars.iv39.ph, %.lr.ph29.preheader59 ]
  %48 = add nuw nsw i64 %indvars.iv39, 2
  %49 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %indvars.iv.next40 = add nsw i64 %indvars.iv39, -1
  %51 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv.next40
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sub nsw i32 %47, %52
  %54 = xor i32 %53, %50
  %55 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %indvars.iv39
  store i32 %54, ptr %55, align 4, !tbaa !5
  %indvars.iv.next42 = add nsw i64 %indvars.iv41, 1
  %56 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %indvars.iv41
  store i32 %54, ptr %56, align 4, !tbaa !5
  %57 = icmp ugt i64 %indvars.iv39, 1
  br i1 %57, label %.lr.ph29, label %._crit_edge30, !llvm.loop !14

._crit_edge35.loopexit:                           ; preds = %.lr.ph34._crit_edge
  %.pre49 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge35

._crit_edge35:                                    ; preds = %._crit_edge35.loopexit, %30
  %58 = phi i32 [ %.pre49, %._crit_edge35.loopexit ], [ %44, %30 ]
  %59 = sext i32 %58 to i64
  %60 = add nsw i64 %59, -1
  %61 = mul nsw i64 %60, %59
  %62 = ashr i64 %61, 1
  %63 = load i64, ptr @ans, align 8, !tbaa !15
  %64 = sub nsw i64 %62, %63
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %64)
  ret i32 0

.lr.ph34:                                         ; preds = %.lr.ph34.preheader, %.lr.ph34._crit_edge
  %indvars.iv46 = phi i64 [ %46, %.lr.ph34.preheader ], [ %indvars.iv.next47, %.lr.ph34._crit_edge ]
  %66 = and i64 %indvars.iv46, 1
  %67 = xor i64 %66, 1
  %68 = load i32, ptr @tot, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr @que, i64 %69
  %71 = add nuw nsw i64 %indvars.iv46, 1
  %72 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %71
  %73 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %70, ptr noundef nonnull align 4 dereferenceable(4) %72)
  %74 = ptrtoint ptr %73 to i64
  %75 = sub i64 %74, ptrtoint (ptr @que to i64)
  %76 = ashr exact i64 %75, 2
  %77 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %67, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = load i64, ptr @ans, align 8, !tbaa !15
  %81 = add nsw i64 %80, %79
  store i64 %81, ptr @ans, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %82 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv46
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nuw nsw i64 %indvars.iv46, 2
  %85 = getelementptr inbounds [100003 x i32], ptr @f, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = xor i32 %86, %83
  store i32 %87, ptr %1, align 4, !tbaa !5
  %88 = load i32, ptr @tot, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr @que, i64 %89
  %91 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %90, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %92 = ptrtoint ptr %91 to i64
  %93 = sub i64 %92, ptrtoint (ptr @que to i64)
  %sext24 = shl i64 %93, 30
  %94 = ashr i64 %sext24, 32
  %95 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = icmp eq i32 %96, %97
  %99 = and i64 %indvars.iv46, 1
  br i1 %98, label %100, label %.lr.ph34._crit_edge

100:                                              ; preds = %.lr.ph34
  %101 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %99, i64 %94
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = load i64, ptr @ans, align 8, !tbaa !15
  %105 = add nsw i64 %104, %103
  store i64 %105, ptr @ans, align 8, !tbaa !15
  br label %.lr.ph34._crit_edge

.lr.ph34._crit_edge:                              ; preds = %.lr.ph34, %100
  %106 = load i32, ptr @tot, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr @que, i64 %107
  %109 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %108, ptr noundef nonnull align 4 dereferenceable(4) %85)
  %110 = ptrtoint ptr %109 to i64
  %111 = sub i64 %110, ptrtoint (ptr @que to i64)
  %112 = ashr exact i64 %111, 2
  %113 = getelementptr inbounds [2 x [100003 x i32]], ptr @cnt, i64 0, i64 %99, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %113, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %indvars.iv.next47 = add nsw i64 %indvars.iv46, -1
  %116 = icmp sgt i64 %indvars.iv46, 1
  br i1 %116, label %.lr.ph34, label %._crit_edge35.loopexit, !llvm.loop !17
}

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

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

; Function Attrs: mustprogress 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 @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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 = { 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 #2 = { mustprogress 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 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12, !11}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = distinct !{!17, !10}


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