; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100624D)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@val = external dso_local global [200001 x i32], align 16
@tot = external dso_local global i32, align 4
@que = external dso_local global [200001 x i32], align 16
@pos = external dso_local global [200001 x i32], align 16
@l = external dso_local global [200001 x i32], align 16
@r = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z6boringii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %6

6:                                                ; preds = %132, %0
  %7 = load i32, ptr @t, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @t, align 4, !tbaa !5
  %9 = icmp ne i32 %7, 0
  br i1 %9, label %10, label %138

10:                                               ; preds = %6
  store i32 0, ptr @tot, align 4, !tbaa !5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

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

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @val, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %20)
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = load i32, ptr @tot, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %28
  store i32 %25, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %17
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

33:                                               ; preds = %16
  %34 = load i32, ptr @tot, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr @que, i64 %35
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %36)
  %37 = load i32, ptr @tot, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr @que, i64 %38
  %40 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %39)
  %41 = ptrtoint ptr %40 to i64
  %42 = sub i64 %41, ptrtoint (ptr @que to i64)
  %43 = sdiv exact i64 %42, 4
  %44 = trunc i64 %43 to i32
  store i32 %44, ptr @tot, align 4, !tbaa !5
  %45 = load i32, ptr @tot, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = mul i64 %46, 4
  call void @llvm.memset.p0.i64(ptr align 16 @pos, i8 0, i64 %47, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %85, %33
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %53, label %52

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

53:                                               ; preds = %48
  %54 = load i32, ptr @tot, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @que, i64 %55
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %58
  %60 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %56, ptr noundef nonnull align 4 dereferenceable(4) %59)
  %61 = ptrtoint ptr %60 to i64
  %62 = sub i64 %61, ptrtoint (ptr @que to i64)
  %63 = sdiv exact i64 %62, 4
  %64 = trunc i64 %63 to i32
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %66
  store i32 %64, ptr %67, align 4, !tbaa !5
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [200001 x i32], ptr @l, i64 0, i64 %76
  store i32 %74, ptr %77, align 4, !tbaa !5
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %83
  store i32 %78, ptr %84, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %53
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %3, align 4, !tbaa !5
  br label %48, !llvm.loop !11

88:                                               ; preds = %52
  %89 = load i32, ptr @tot, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = mul i64 %90, 4
  call void @llvm.memset.p0.i64(ptr align 16 @pos, i8 0, i64 %91, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %92 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %92, ptr %4, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %129, %88
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %97, label %96

96:                                               ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %132

97:                                               ; preds = %93
  %98 = load i32, ptr %4, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %114

106:                                              ; preds = %97
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  br label %117

114:                                              ; preds = %97
  %115 = load i32, ptr @n, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  br label %117

117:                                              ; preds = %114, %106
  %118 = phi i32 [ %113, %106 ], [ %116, %114 ]
  %119 = load i32, ptr %4, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [200001 x i32], ptr @r, i64 0, i64 %120
  store i32 %118, ptr %121, align 4, !tbaa !5
  %122 = load i32, ptr %4, align 4, !tbaa !5
  %123 = load i32, ptr %4, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %127
  store i32 %122, ptr %128, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %117
  %130 = load i32, ptr %4, align 4, !tbaa !5
  %131 = add nsw i32 %130, -1
  store i32 %131, ptr %4, align 4, !tbaa !5
  br label %93, !llvm.loop !12

132:                                              ; preds = %96
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = call noundef zeroext i1 @_Z6boringii(i32 noundef 1, i32 noundef %133)
  %135 = zext i1 %134 to i64
  %136 = select i1 %134, ptr @.str.1, ptr @.str.2
  %137 = call i32 @puts(ptr noundef %136)
  br label %6, !llvm.loop !13

138:                                              ; preds = %6
  ret i32 0
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

declare i32 @puts(ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@val = external dso_local global [200001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [200001 x i32], align 16
@pos = external dso_local local_unnamed_addr global [200001 x i32], align 16
@l = external dso_local local_unnamed_addr global [200001 x i32], align 16
@r = external dso_local local_unnamed_addr global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z6boringii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not40 = icmp eq i32 %2, 0
  br i1 %.not40, label %._crit_edge43, label %.lr.ph42

.lr.ph42:                                         ; preds = %0, %._crit_edge39
  store i32 0, ptr @tot, align 4, !tbaa !5
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not2228 = icmp slt i32 %5, 1
  br i1 %.not2228, label %.lr.ph42.._crit_edge_crit_edge, label %.lr.ph

.lr.ph42.._crit_edge_crit_edge:                   ; preds = %.lr.ph42
  %.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph42.._crit_edge_crit_edge
  %6 = phi i32 [ %.pre, %.lr.ph42.._crit_edge_crit_edge ], [ %24, %.lr.ph ]
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds i32, ptr @que, i64 %7
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %8)
  %9 = load i32, ptr @tot, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i32, ptr @que, i64 %10
  %12 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %11)
  %13 = ptrtoint ptr %12 to i64
  %14 = sub i64 %13, ptrtoint (ptr @que to i64)
  %15 = lshr exact i64 %14, 2
  %16 = trunc i64 %15 to i32
  store i32 %16, ptr @tot, align 4, !tbaa !5
  %sext = shl i64 %14, 30
  %17 = ashr exact i64 %sext, 30
  %18 = and i64 %17, -4
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @pos, i8 0, i64 %18, i1 false)
  %19 = load i32, ptr @n, align 4
  %.not2330 = icmp slt i32 %19, 1
  br i1 %.not2330, label %._crit_edge34, label %.lr.ph33

.lr.ph:                                           ; preds = %.lr.ph42, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph42 ]
  %20 = getelementptr inbounds i32, ptr @val, i64 %indvars.iv
  %21 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %20)
  %22 = load i32, ptr %20, align 4, !tbaa !5
  %23 = load i32, ptr @tot, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @tot, align 4, !tbaa !5
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %25
  store i32 %22, ptr %26, align 4, !tbaa !5
  %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
  %.not22.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not22.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge34.loopexit:                           ; preds = %.lr.ph33
  %.pre52 = load i32, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge34

._crit_edge34:                                    ; preds = %._crit_edge34.loopexit, %._crit_edge
  %29 = phi i32 [ %16, %._crit_edge ], [ %.pre52, %._crit_edge34.loopexit ]
  %.lcssa = phi i32 [ %19, %._crit_edge ], [ %56, %._crit_edge34.loopexit ]
  %30 = sext i32 %29 to i64
  %31 = shl nsw i64 %30, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @pos, i8 0, i64 %31, i1 false)
  %.not2435 = icmp eq i32 %.lcssa, 0
  br i1 %.not2435, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %._crit_edge34
  %32 = add nsw i32 %.lcssa, 1
  %33 = sext i32 %.lcssa to i64
  %xtraiter = and i64 %33, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %.lr.ph38
  %34 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %.not25.prol = icmp eq i32 %38, 0
  %39 = select i1 %.not25.prol, i32 %32, i32 %38
  %40 = getelementptr inbounds [200001 x i32], ptr @r, i64 0, i64 %33
  store i32 %39, ptr %40, align 4, !tbaa !5
  store i32 %.lcssa, ptr %37, align 4, !tbaa !5
  %indvars.iv.next50.prol = add nsw i64 %33, -1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph38
  %indvars.iv49.unr = phi i64 [ %33, %.lr.ph38 ], [ %indvars.iv.next50.prol, %.prol.loopexit.unr-lcssa ]
  %41 = icmp eq i32 %.lcssa, 1
  br i1 %41, label %._crit_edge39, label %.lr.ph38.new

.lr.ph33:                                         ; preds = %._crit_edge, %.lr.ph33
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %.lr.ph33 ], [ 1, %._crit_edge ]
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr @que, i64 %43
  %45 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %indvars.iv46
  %46 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %44, ptr noundef nonnull align 4 dereferenceable(4) %45)
  %47 = ptrtoint ptr %46 to i64
  %48 = sub i64 %47, ptrtoint (ptr @que to i64)
  %49 = lshr exact i64 %48, 2
  %50 = trunc i64 %49 to i32
  store i32 %50, ptr %45, align 4, !tbaa !5
  %sext26 = shl i64 %48, 30
  %51 = ashr i64 %sext26, 32
  %52 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = getelementptr inbounds [200001 x i32], ptr @l, i64 0, i64 %indvars.iv46
  store i32 %53, ptr %54, align 4, !tbaa !5
  %55 = trunc nuw nsw i64 %indvars.iv46 to i32
  store i32 %55, ptr %52, align 4, !tbaa !5
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %56 = load i32, ptr @n, align 4
  %57 = sext i32 %56 to i64
  %.not23.not = icmp slt i64 %indvars.iv46, %57
  br i1 %.not23.not, label %.lr.ph33, label %._crit_edge34.loopexit, !llvm.loop !11

._crit_edge39:                                    ; preds = %.prol.loopexit, %.lr.ph38.new, %._crit_edge34
  %58 = tail call noundef zeroext i1 @_Z6boringii(i32 noundef 1, i32 noundef %.lcssa)
  %59 = select i1 %58, ptr @.str.1, ptr @.str.2
  %60 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %59)
  %61 = load i32, ptr @t, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %61, 0
  br i1 %.not, label %._crit_edge43, label %.lr.ph42, !llvm.loop !12

.lr.ph38.new:                                     ; preds = %.prol.loopexit, %.lr.ph38.new
  %indvars.iv49 = phi i64 [ %indvars.iv.next50.1, %.lr.ph38.new ], [ %indvars.iv49.unr, %.prol.loopexit ]
  %63 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %indvars.iv49
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %.not25 = icmp eq i32 %67, 0
  %68 = select i1 %.not25, i32 %32, i32 %67
  %69 = getelementptr inbounds [200001 x i32], ptr @r, i64 0, i64 %indvars.iv49
  store i32 %68, ptr %69, align 4, !tbaa !5
  %70 = trunc nsw i64 %indvars.iv49 to i32
  store i32 %70, ptr %66, align 4, !tbaa !5
  %indvars.iv.next50 = add nsw i64 %indvars.iv49, -1
  %71 = getelementptr inbounds [200001 x i32], ptr @val, i64 0, i64 %indvars.iv.next50
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %.not25.1 = icmp eq i32 %75, 0
  %76 = select i1 %.not25.1, i32 %32, i32 %75
  %77 = getelementptr inbounds [200001 x i32], ptr @r, i64 0, i64 %indvars.iv.next50
  store i32 %76, ptr %77, align 4, !tbaa !5
  %78 = trunc nsw i64 %indvars.iv.next50 to i32
  store i32 %78, ptr %74, align 4, !tbaa !5
  %indvars.iv.next50.1 = add nsw i64 %indvars.iv49, -2
  %.not24.1 = icmp eq i64 %indvars.iv.next50.1, 0
  br i1 %.not24.1, label %._crit_edge39, label %.lr.ph38.new, !llvm.loop !13

._crit_edge43:                                    ; preds = %._crit_edge39, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; 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 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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