; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101174F)

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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@lnk = external dso_local global [100001 x i32], align 16
@rt = external dso_local global i32, align 4
@in = external dso_local global [100001 x i32], align 16
@out = external dso_local global [100001 x i32], align 16
@e = external dso_local global [100001 x %struct.Edge], align 16
@rk = external dso_local global [100001 x i32], align 16
@val = external dso_local global [100001 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@ans = external dso_local global [100001 x i64], 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 [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsi(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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7bit_addii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7bit_sumi(i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.Edge, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %10

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

14:                                               ; preds = %10
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %53

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr @rk, i64 %17
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @val, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4, ptr noundef %18, ptr noundef %21)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %25
  store i32 %23, ptr %26, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = icmp eq i32 %27, -1
  br i1 %28, label %29, label %31

29:                                               ; preds = %15
  %30 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %30, ptr @rt, align 4, !tbaa !5
  store i32 4, ptr %3, align 4
  br label %47

31:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %32 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %32, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %38 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %38, ptr %37, align 4, !tbaa !11
  %39 = load i32, ptr @tot, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr @tot, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %41
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %42, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  %43 = load i32, ptr @tot, align 4, !tbaa !5
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %45
  store i32 %43, ptr %46, align 4, !tbaa !5
  store i32 0, ptr %3, align 4
  br label %47

47:                                               ; preds = %31, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %48 = load i32, ptr %3, align 4
  switch i32 %48, label %149 [
    i32 0, label %49
    i32 4, label %50
  ]

49:                                               ; preds = %47
  br label %50

50:                                               ; preds = %49, %47
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !13

53:                                               ; preds = %14
  store i32 0, ptr @tot, align 4, !tbaa !5
  %54 = load i32, ptr @rt, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %54)
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr @ord, i64 %56
  %58 = getelementptr inbounds i32, ptr %57, i64 1
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef getelementptr inbounds (i32, ptr @ord, i64 1), ptr noundef %58, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %130, %53
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %133

64:                                               ; preds = %59
  br label %65

65:                                               ; preds = %102, %64
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %69, label %85

69:                                               ; preds = %65
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100001 x i32], ptr @rk, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @rk, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp slt i32 %76, %83
  br label %85

85:                                               ; preds = %69, %65
  %86 = phi i1 [ false, %65 ], [ %84, %69 ]
  br i1 %86, label %87, label %105

87:                                               ; preds = %85
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100001 x i32], ptr @in, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [100001 x i32], ptr @val, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %94, i32 noundef %101)
  br label %102

102:                                              ; preds = %87
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %7, align 4, !tbaa !5
  br label %65, !llvm.loop !15

105:                                              ; preds = %85
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i32], ptr @out, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = call noundef i64 @_Z7bit_sumi(i32 noundef %112)
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100001 x i32], ptr @in, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 1
  %122 = call noundef i64 @_Z7bit_sumi(i32 noundef %121)
  %123 = sub nsw i64 %113, %122
  %124 = load i32, ptr %6, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %128
  store i64 %123, ptr %129, align 8, !tbaa !16
  br label %130

130:                                              ; preds = %105
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %6, align 4, !tbaa !5
  br label %59, !llvm.loop !18

133:                                              ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %145, %133
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = icmp sle i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %148

139:                                              ; preds = %134
  %140 = load i32, ptr %8, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %141
  %143 = load i64, ptr %142, align 8, !tbaa !16
  %144 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %143)
  br label %145

145:                                              ; preds = %139
  %146 = load i32, ptr %8, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %8, align 4, !tbaa !5
  br label %134, !llvm.loop !19

148:                                              ; preds = %138
  ret i32 0

149:                                              ; preds = %47
  unreachable
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

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 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 #3 = { 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 #4 = { "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: readwrite) }
attributes #6 = { 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 #7 = { 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 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


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

%struct.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [100001 x i32], align 16
@rt = external dso_local local_unnamed_addr global i32, align 4
@in = external dso_local local_unnamed_addr global [100001 x i32], align 16
@out = external dso_local local_unnamed_addr global [100001 x i32], align 16
@e = external dso_local local_unnamed_addr global [100001 x %struct.Edge], align 16
@rk = external dso_local global [100001 x i32], align 16
@val = external dso_local global [100001 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i64], 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 [7 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7bit_addii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7bit_sumi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %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
  %.not30 = icmp slt i32 %3, 1
  br i1 %.not30, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %26, %0
  store i32 0, ptr @tot, align 4, !tbaa !5
  %4 = load i32, ptr @rt, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %4)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i32, ptr @ord, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @ord, i64 4), ptr noundef nonnull %8, ptr noundef nonnull @_Z3cmpRKiS0_)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %.not2637 = icmp slt i32 %9, 1
  br i1 %.not2637, label %._crit_edge43, label %.preheader29

.lr.ph:                                           ; preds = %0, %26
  %indvars.iv = phi i64 [ %indvars.iv.next, %26 ], [ 1, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %10 = getelementptr inbounds i32, ptr @rk, i64 %indvars.iv
  %11 = getelementptr inbounds i32, ptr @val, i64 %indvars.iv
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %13 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %14, ptr %13, align 4, !tbaa !5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = icmp eq i32 %15, -1
  br i1 %16, label %17, label %18

17:                                               ; preds = %.lr.ph
  store i32 %14, ptr @rt, align 4, !tbaa !5
  br label %26

18:                                               ; preds = %.lr.ph
  %19 = sext i32 %15 to i64
  %20 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = load i32, ptr @tot, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %24
  store i32 %21, ptr %25, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %25, i64 4
  store i32 %14, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  store i32 %23, ptr %20, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %18, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %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 !9

.preheader29:                                     ; preds = %._crit_edge, %.critedge
  %29 = phi i32 [ %67, %.critedge ], [ %9, %._crit_edge ]
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %.critedge ], [ 1, %._crit_edge ]
  %.02239 = phi i32 [ %.1.lcssa, %.critedge ], [ 1, %._crit_edge ]
  %.not2832 = icmp sgt i32 %.02239, %29
  br i1 %.not2832, label %.critedge, label %.lr.ph34

.lr.ph34:                                         ; preds = %.preheader29
  %30 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv48
  %31 = sext i32 %.02239 to i64
  br label %33

.preheader:                                       ; preds = %.critedge
  %32 = icmp slt i32 %67, 1
  br i1 %32, label %._crit_edge43, label %.lr.ph42

33:                                               ; preds = %.lr.ph34, %44
  %indvars.iv45 = phi i64 [ %31, %.lr.ph34 ], [ %indvars.iv.next46, %44 ]
  %34 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv45
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x i32], ptr @rk, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %30, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i32], ptr @rk, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = icmp slt i32 %38, %42
  br i1 %43, label %44, label %.critedge.loopexit

44:                                               ; preds = %33
  %45 = getelementptr inbounds [100001 x i32], ptr @in, i64 0, i64 %36
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = getelementptr inbounds [100001 x i32], ptr @val, i64 0, i64 %36
  %48 = load i32, ptr %47, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %46, i32 noundef %48)
  %indvars.iv.next46 = add nsw i64 %indvars.iv45, 1
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %.not28.not = icmp slt i64 %indvars.iv45, %50
  br i1 %.not28.not, label %33, label %.critedge.loopexit, !llvm.loop !11

.critedge.loopexit:                               ; preds = %44, %33
  %.1.lcssa.ph.in = phi i64 [ %indvars.iv45, %33 ], [ %indvars.iv.next46, %44 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader29
  %.1.lcssa = phi i32 [ %.02239, %.preheader29 ], [ %.1.lcssa.ph, %.critedge.loopexit ]
  %51 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv48
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @out, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = call noundef i64 @_Z7bit_sumi(i32 noundef %55)
  %57 = load i32, ptr %51, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100001 x i32], ptr @in, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = add nsw i32 %60, -1
  %62 = call noundef i64 @_Z7bit_sumi(i32 noundef %61)
  %63 = sub nsw i64 %56, %62
  %64 = load i32, ptr %51, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %65
  store i64 %63, ptr %66, align 8, !tbaa !12
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %.not26.not = icmp slt i64 %indvars.iv48, %68
  br i1 %.not26.not, label %.preheader29, label %.preheader, !llvm.loop !14

._crit_edge43:                                    ; preds = %.lr.ph42, %._crit_edge, %.preheader
  ret i32 0

.lr.ph42:                                         ; preds = %.preheader, %.lr.ph42
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph42 ], [ 1, %.preheader ]
  %69 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %indvars.iv52
  %70 = load i64, ptr %69, align 8, !tbaa !12
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %70)
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %.not27.not = icmp slt i64 %indvars.iv52, %73
  br i1 %.not27.not, label %.lr.ph42, label %._crit_edge43, !llvm.loop !15
}

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

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

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

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

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

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


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