; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LONG/JAN15/CLPERM (a)

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

@t = external dso_local global i32, align 4
@flag = external dso_local global i32, align 4
@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@s = external dso_local global i64, align 8
@tot = external dso_local global i64, align 8
@cap = external dso_local global i64, align 8
@sum = external dso_local global i64, align 8
@b = external dso_local global [100001 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 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
  store i32 0, ptr %1, align 4
  %4 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  br label %6

6:                                                ; preds = %180, %30, %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 %181

10:                                               ; preds = %6
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %13 = load i64, ptr @n, align 8, !tbaa !9
  %14 = load i64, ptr @n, align 8, !tbaa !9
  %15 = add i64 %14, 1
  %16 = mul i64 %13, %15
  %17 = udiv i64 %16, 2
  store i64 %17, ptr @s, align 8, !tbaa !9
  %18 = load i64, ptr @k, align 8, !tbaa !9
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %20, label %31

20:                                               ; preds = %10
  %21 = load i64, ptr @s, align 8, !tbaa !9
  %22 = urem i64 %21, 2
  %23 = icmp eq i64 %22, 1
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %30

27:                                               ; preds = %20
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %30

30:                                               ; preds = %27, %24
  br label %6, !llvm.loop !11

31:                                               ; preds = %10
  store i32 0, ptr @flag, align 4, !tbaa !5
  store i64 0, ptr @tot, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %67, %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = load i64, ptr @k, align 8, !tbaa !9
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %70

38:                                               ; preds = %32
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %40
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %41)
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = load i64, ptr @tot, align 8, !tbaa !9
  %48 = add i64 %47, %46
  store i64 %48, ptr @tot, align 8, !tbaa !9
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp eq i64 %52, 1
  br i1 %53, label %54, label %55

54:                                               ; preds = %38
  store i32 1, ptr @flag, align 4, !tbaa !5
  br label %66

55:                                               ; preds = %38
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = icmp eq i64 %59, 2
  br i1 %60, label %61, label %65

61:                                               ; preds = %55
  %62 = load i32, ptr @flag, align 4, !tbaa !5
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %61
  store i32 2, ptr @flag, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %64, %61, %55
  br label %66

66:                                               ; preds = %65, %54
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %2, align 4, !tbaa !5
  br label %32, !llvm.loop !13

70:                                               ; preds = %37
  %71 = load i32, ptr @flag, align 4, !tbaa !5
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %166

73:                                               ; preds = %70
  %74 = load i64, ptr @k, align 8, !tbaa !9
  %75 = getelementptr inbounds i64, ptr @b, i64 %74
  call void @_ZSt4sortIPyEvT_S1_(ptr noundef @b, ptr noundef %75)
  %76 = load i64, ptr @b, align 16, !tbaa !9
  %77 = load i64, ptr @b, align 16, !tbaa !9
  %78 = sub i64 %77, 1
  %79 = mul i64 %76, %78
  %80 = udiv i64 %79, 2
  store i64 %80, ptr @cap, align 8, !tbaa !9
  %81 = load i64, ptr @b, align 16, !tbaa !9
  store i64 %81, ptr @sum, align 8, !tbaa !9
  store i32 0, ptr @flag, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %145, %73
  %83 = load i32, ptr %3, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = load i64, ptr @k, align 8, !tbaa !9
  %86 = icmp ult i64 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %148

88:                                               ; preds = %82
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !9
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !9
  %98 = add i64 %97, 1
  %99 = icmp eq i64 %92, %98
  br i1 %99, label %100, label %124

100:                                              ; preds = %88
  %101 = load i32, ptr %3, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = load i64, ptr @cap, align 8, !tbaa !9
  %106 = icmp ugt i64 %104, %105
  br i1 %106, label %107, label %123

107:                                              ; preds = %100
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !9
  %112 = urem i64 %111, 2
  %113 = icmp eq i64 %112, 0
  br i1 %113, label %114, label %117

114:                                              ; preds = %107
  %115 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %115, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %120

117:                                              ; preds = %107
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %118, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %120

120:                                              ; preds = %117, %114
  store i32 1, ptr @flag, align 4, !tbaa !5
  %121 = load i64, ptr @k, align 8, !tbaa !9
  %122 = trunc i64 %121 to i32
  store i32 %122, ptr %3, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %120, %100
  br label %138

124:                                              ; preds = %88
  %125 = load i32, ptr %3, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %126
  %128 = load i64, ptr %127, align 8, !tbaa !9
  %129 = load i32, ptr %3, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !9
  %133 = sub i64 %132, 1
  %134 = mul i64 %128, %133
  %135 = udiv i64 %134, 2
  %136 = load i64, ptr @sum, align 8, !tbaa !9
  %137 = sub i64 %135, %136
  store i64 %137, ptr @cap, align 8, !tbaa !9
  br label %138

138:                                              ; preds = %124, %123
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !9
  %143 = load i64, ptr @sum, align 8, !tbaa !9
  %144 = add i64 %143, %142
  store i64 %144, ptr @sum, align 8, !tbaa !9
  br label %145

145:                                              ; preds = %138
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %3, align 4, !tbaa !5
  br label %82, !llvm.loop !14

148:                                              ; preds = %87
  %149 = load i32, ptr @flag, align 4, !tbaa !5
  %150 = icmp eq i32 %149, 0
  br i1 %150, label %151, label %165

151:                                              ; preds = %148
  %152 = load i64, ptr @tot, align 8, !tbaa !9
  %153 = load i64, ptr @s, align 8, !tbaa !9
  %154 = sub i64 %153, %152
  store i64 %154, ptr @s, align 8, !tbaa !9
  %155 = load i64, ptr @s, align 8, !tbaa !9
  %156 = urem i64 %155, 2
  %157 = icmp eq i64 %156, 1
  br i1 %157, label %158, label %161

158:                                              ; preds = %151
  %159 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %160 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %159, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %164

161:                                              ; preds = %151
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %163 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %162, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %164

164:                                              ; preds = %161, %158
  br label %165

165:                                              ; preds = %164, %148
  br label %180

166:                                              ; preds = %70
  %167 = load i32, ptr @flag, align 4, !tbaa !5
  %168 = icmp eq i32 %167, 1
  br i1 %168, label %169, label %172

169:                                              ; preds = %166
  %170 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %171 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %170, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %179

172:                                              ; preds = %166
  %173 = load i32, ptr @flag, align 4, !tbaa !5
  %174 = icmp eq i32 %173, 2
  br i1 %174, label %175, label %178

175:                                              ; preds = %172
  %176 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %177 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %176, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %178

178:                                              ; preds = %175, %172
  br label %179

179:                                              ; preds = %178, %169
  br label %180

180:                                              ; preds = %179, %165
  br label %6, !llvm.loop !11

181:                                              ; preds = %6
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #2 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) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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

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

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 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

%"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" }

@t = external dso_local global i32, align 4
@flag = external dso_local local_unnamed_addr global i32, align 4
@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@s = external dso_local local_unnamed_addr global i64, align 8
@tot = external dso_local local_unnamed_addr global i64, align 8
@cap = external dso_local local_unnamed_addr global i64, align 8
@sum = external dso_local local_unnamed_addr global i64, align 8
@b = external dso_local global [100001 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = 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) @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr @t, align 4, !tbaa !5
  %.not30 = icmp eq i32 %3, 0
  br i1 %.not30, label %._crit_edge33, label %.lr.ph32

.lr.ph32:                                         ; preds = %0, %.backedge
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %7 = load i64, ptr @n, align 8, !tbaa !9
  %8 = add i64 %7, 1
  %9 = mul i64 %8, %7
  %10 = lshr i64 %9, 1
  store i64 %10, ptr @s, align 8, !tbaa !9
  %11 = load i64, ptr @k, align 8, !tbaa !9
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %13, label %.lr.ph.preheader

13:                                               ; preds = %.lr.ph32
  %14 = and i64 %9, 2
  %.not24 = icmp eq i64 %14, 0
  %.str.1..str40 = select i1 %.not24, ptr @.str.1, ptr @.str
  br label %.backedge.sink.split

.backedge.sink.split:                             ; preds = %13, %._crit_edge, %._crit_edge29.thread, %81
  %.str.sink = phi ptr [ @.str, %81 ], [ %.str.1..str, %._crit_edge29.thread ], [ @.str.1, %._crit_edge ], [ %.str.1..str40, %13 ]
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str.sink)
  %16 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %.backedge

.backedge:                                        ; preds = %.backedge.sink.split, %._crit_edge29, %._crit_edge
  %17 = load i32, ptr @t, align 4, !tbaa !5
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %._crit_edge33, label %.lr.ph32, !llvm.loop !11

.lr.ph.preheader:                                 ; preds = %.lr.ph32
  store i32 0, ptr @flag, align 4, !tbaa !5
  store i64 0, ptr @tot, align 8, !tbaa !9
  br label %.lr.ph

._crit_edge:                                      ; preds = %29
  switch i32 %30, label %.backedge [
    i32 0, label %33
    i32 1, label %.backedge.sink.split
    i32 2, label %81
  ]

.lr.ph:                                           ; preds = %.lr.ph.preheader, %29
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %29 ]
  %19 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %indvars.iv
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %21 = load i64, ptr %19, align 8, !tbaa !9
  %22 = load i64, ptr @tot, align 8, !tbaa !9
  %23 = add i64 %22, %21
  store i64 %23, ptr @tot, align 8, !tbaa !9
  %24 = icmp eq i64 %21, 1
  br i1 %24, label %.sink.split, label %25

25:                                               ; preds = %.lr.ph
  %26 = icmp eq i64 %21, 2
  %27 = load i32, ptr @flag, align 4
  %28 = icmp eq i32 %27, 0
  %or.cond = select i1 %26, i1 %28, i1 false
  br i1 %or.cond, label %.sink.split, label %29

.sink.split:                                      ; preds = %25, %.lr.ph
  %.sink = phi i32 [ 1, %.lr.ph ], [ 2, %25 ]
  store i32 %.sink, ptr @flag, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %.sink.split, %25
  %30 = phi i32 [ %27, %25 ], [ %.sink, %.sink.split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = load i64, ptr @k, align 8, !tbaa !9
  %32 = icmp ugt i64 %31, %indvars.iv.next
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !13

33:                                               ; preds = %._crit_edge
  %34 = getelementptr inbounds i64, ptr @b, i64 %31
  tail call void @_ZSt4sortIPyEvT_S1_(ptr noundef nonnull @b, ptr noundef nonnull %34)
  %35 = load i64, ptr @b, align 16, !tbaa !9
  %36 = add i64 %35, -1
  %37 = mul i64 %36, %35
  %38 = lshr i64 %37, 1
  store i64 %38, ptr @cap, align 8, !tbaa !9
  store i64 %35, ptr @sum, align 8, !tbaa !9
  store i32 0, ptr @flag, align 4, !tbaa !5
  %39 = load i64, ptr @k, align 8, !tbaa !9
  %40 = icmp ugt i64 %39, 1
  br i1 %40, label %.lr.ph28, label %._crit_edge29.thread

._crit_edge29:                                    ; preds = %66
  %41 = icmp eq i32 %67, 0
  br i1 %41, label %._crit_edge29.thread, label %.backedge

.lr.ph28:                                         ; preds = %33, %66
  %42 = phi i32 [ %67, %66 ], [ 0, %33 ]
  %43 = phi i64 [ %68, %66 ], [ %39, %33 ]
  %44 = phi i64 [ %73, %66 ], [ %35, %33 ]
  %45 = phi i64 [ %72, %66 ], [ %35, %33 ]
  %46 = phi i64 [ %75, %66 ], [ 1, %33 ]
  %.026 = phi i32 [ %74, %66 ], [ 1, %33 ]
  %47 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = add i64 %45, 1
  %50 = icmp eq i64 %48, %49
  br i1 %50, label %51, label %61

51:                                               ; preds = %.lr.ph28
  %52 = load i64, ptr @cap, align 8, !tbaa !9
  %53 = icmp ugt i64 %48, %52
  br i1 %53, label %54, label %66

54:                                               ; preds = %51
  %55 = and i64 %48, 1
  %56 = icmp eq i64 %55, 0
  %.str..str.1 = select i1 %56, ptr @.str, ptr @.str.1
  %57 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str..str.1)
  %58 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 1, ptr @flag, align 4, !tbaa !5
  %59 = load i64, ptr @k, align 8, !tbaa !9
  %60 = trunc i64 %59 to i32
  %.pre = load i64, ptr @sum, align 8, !tbaa !9
  br label %66

61:                                               ; preds = %.lr.ph28
  %62 = add i64 %48, -1
  %63 = mul i64 %62, %48
  %64 = lshr i64 %63, 1
  %65 = sub i64 %64, %44
  store i64 %65, ptr @cap, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %51, %54, %61
  %67 = phi i32 [ 1, %54 ], [ %42, %51 ], [ %42, %61 ]
  %68 = phi i64 [ %59, %54 ], [ %43, %51 ], [ %43, %61 ]
  %69 = phi i64 [ %.pre, %54 ], [ %44, %51 ], [ %44, %61 ]
  %.1 = phi i32 [ %60, %54 ], [ %.026, %51 ], [ %.026, %61 ]
  %70 = sext i32 %.1 to i64
  %71 = getelementptr inbounds [100001 x i64], ptr @b, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = add i64 %69, %72
  store i64 %73, ptr @sum, align 8, !tbaa !9
  %74 = add nsw i32 %.1, 1
  %75 = sext i32 %74 to i64
  %76 = icmp ugt i64 %68, %75
  br i1 %76, label %.lr.ph28, label %._crit_edge29, !llvm.loop !14

._crit_edge29.thread:                             ; preds = %33, %._crit_edge29
  %77 = load i64, ptr @tot, align 8, !tbaa !9
  %78 = load i64, ptr @s, align 8, !tbaa !9
  %79 = sub i64 %78, %77
  store i64 %79, ptr @s, align 8, !tbaa !9
  %80 = and i64 %79, 1
  %.not23 = icmp eq i64 %80, 0
  %.str.1..str = select i1 %.not23, ptr @.str.1, ptr @.str
  br label %.backedge.sink.split

81:                                               ; preds = %._crit_edge
  br label %.backedge.sink.split

._crit_edge33:                                    ; preds = %.backedge, %0
  ret i32 0
}

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

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 #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 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 #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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 = { 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 #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" }

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


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