; LLVM IR from manishbisht/Competitive-Programming :: Google/Code Jam/Round 1A 2008/Minimum Scalar Product (Minimum Scalar Product)

; 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_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@t = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@a = external dso_local global [1000 x i64], align 16
@b = external dso_local global [1000 x i64], align 16
@i = external dso_local global i64, align 8
@j = external dso_local global i64, align 8
@sum = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::basic_ifstream", align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::basic_ofstream", align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 520, ptr %2) #5
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2)
  invoke void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256) %2, ptr noundef @.str, i32 noundef 8)
          to label %6 unwind label %30

6:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 512, ptr %5) #5
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(248) %5)
          to label %7 unwind label %34

7:                                                ; preds = %6
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %5, ptr noundef @.str.1, i32 noundef 16)
          to label %8 unwind label %38

8:                                                ; preds = %7
  %9 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @t)
          to label %10 unwind label %38

10:                                               ; preds = %8
  store i64 0, ptr @i, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %96, %10
  %12 = load i64, ptr @i, align 8, !tbaa !5
  %13 = load i64, ptr @t, align 8, !tbaa !5
  %14 = icmp slt i64 %12, %13
  br i1 %14, label %15, label %99

15:                                               ; preds = %11
  %16 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @n)
          to label %17 unwind label %38

17:                                               ; preds = %15
  store i64 0, ptr @j, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %27, %17
  %19 = load i64, ptr @j, align 8, !tbaa !5
  %20 = load i64, ptr @n, align 8, !tbaa !5
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %22, label %42

22:                                               ; preds = %18
  %23 = load i64, ptr @j, align 8, !tbaa !5
  %24 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %23
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) %24)
          to label %26 unwind label %38

26:                                               ; preds = %22
  br label %27

27:                                               ; preds = %26
  %28 = load i64, ptr @j, align 8, !tbaa !5
  %29 = add nsw i64 %28, 1
  store i64 %29, ptr @j, align 8, !tbaa !5
  br label %18, !llvm.loop !9

30:                                               ; preds = %0
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %3, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %4, align 4
  br label %102

34:                                               ; preds = %6
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %3, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %4, align 4
  br label %101

38:                                               ; preds = %93, %90, %88, %84, %82, %61, %58, %55, %47, %22, %15, %8, %7
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %3, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %4, align 4
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %5) #5
  br label %101

42:                                               ; preds = %18
  store i64 0, ptr @j, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %52, %42
  %44 = load i64, ptr @j, align 8, !tbaa !5
  %45 = load i64, ptr @n, align 8, !tbaa !5
  %46 = icmp slt i64 %44, %45
  br i1 %46, label %47, label %55

47:                                               ; preds = %43
  %48 = load i64, ptr @j, align 8, !tbaa !5
  %49 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %48
  %50 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) %49)
          to label %51 unwind label %38

51:                                               ; preds = %47
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr @j, align 8, !tbaa !5
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr @j, align 8, !tbaa !5
  br label %43, !llvm.loop !11

55:                                               ; preds = %43
  %56 = load i64, ptr @n, align 8, !tbaa !5
  %57 = getelementptr inbounds i64, ptr @a, i64 %56
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef @a, ptr noundef %57)
          to label %58 unwind label %38

58:                                               ; preds = %55
  %59 = load i64, ptr @n, align 8, !tbaa !5
  %60 = getelementptr inbounds i64, ptr @b, i64 %59
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef @b, ptr noundef %60)
          to label %61 unwind label %38

61:                                               ; preds = %58
  %62 = load i64, ptr @n, align 8, !tbaa !5
  %63 = getelementptr inbounds i64, ptr @b, i64 %62
  invoke void @_ZSt7reverseIPxEvT_S1_(ptr noundef @b, ptr noundef %63)
          to label %64 unwind label %38

64:                                               ; preds = %61
  store i64 0, ptr @sum, align 8, !tbaa !5
  store i64 0, ptr @j, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %79, %64
  %66 = load i64, ptr @j, align 8, !tbaa !5
  %67 = load i64, ptr @n, align 8, !tbaa !5
  %68 = icmp slt i64 %66, %67
  br i1 %68, label %69, label %82

69:                                               ; preds = %65
  %70 = load i64, ptr @sum, align 8, !tbaa !5
  %71 = load i64, ptr @j, align 8, !tbaa !5
  %72 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !5
  %74 = load i64, ptr @j, align 8, !tbaa !5
  %75 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = mul nsw i64 %73, %76
  %78 = add nsw i64 %70, %77
  store i64 %78, ptr @sum, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %69
  %80 = load i64, ptr @j, align 8, !tbaa !5
  %81 = add nsw i64 %80, 1
  store i64 %81, ptr @j, align 8, !tbaa !5
  br label %65, !llvm.loop !12

82:                                               ; preds = %65
  %83 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef @.str.2)
          to label %84 unwind label %38

84:                                               ; preds = %82
  %85 = load i64, ptr @i, align 8, !tbaa !5
  %86 = add nsw i64 %85, 1
  %87 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %83, i64 noundef %86)
          to label %88 unwind label %38

88:                                               ; preds = %84
  %89 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %87, ptr noundef @.str.3)
          to label %90 unwind label %38

90:                                               ; preds = %88
  %91 = load i64, ptr @sum, align 8, !tbaa !5
  %92 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %89, i64 noundef %91)
          to label %93 unwind label %38

93:                                               ; preds = %90
  %94 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %92, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %95 unwind label %38

95:                                               ; preds = %93
  br label %96

96:                                               ; preds = %95
  %97 = load i64, ptr @i, align 8, !tbaa !5
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr @i, align 8, !tbaa !5
  br label %11, !llvm.loop !13

99:                                               ; preds = %11
  store i32 0, ptr %1, align 4
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %5) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr %5) #5
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 520, ptr %2) #5
  %100 = load i32, ptr %1, align 4
  ret i32 %100

101:                                              ; preds = %38, %34
  call void @llvm.lifetime.end.p0(i64 512, ptr %5) #5
  br label %102

102:                                              ; preds = %101, %30
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 520, ptr %2) #5
  br label %103

103:                                              ; preds = %102
  %104 = load ptr, ptr %3, align 8
  %105 = load i32, ptr %4, align 4
  %106 = insertvalue { ptr, i32 } poison, ptr %104, 0
  %107 = insertvalue { ptr, i32 } %106, i32 %105, 1
  resume { ptr, i32 } %107
}

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

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256), ptr noundef, i32 noundef) #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) #2 align 2

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

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

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

; 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 @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2 align 2

; 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: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #4 align 2

; 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 void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #4 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"long long", !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"

%"class.std::basic_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@t = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@a = external dso_local global [1000 x i64], align 16
@b = external dso_local global [1000 x i64], align 16
@i = external dso_local local_unnamed_addr global i64, align 8
@j = external dso_local local_unnamed_addr global i64, align 8
@sum = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::basic_ifstream", align 8
  %2 = alloca %"class.std::basic_ofstream", align 8
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %1) #6
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(256) %1)
  invoke void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(256) %1, ptr noundef nonnull @.str, i32 noundef 8)
          to label %3 unwind label %20

3:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %2) #6
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2)
          to label %4 unwind label %22

4:                                                ; preds = %3
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %2, ptr noundef nonnull @.str.1, i32 noundef 16)
          to label %5 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

5:                                                ; preds = %4
  %6 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) @t)
          to label %.preheader17 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

.preheader17:                                     ; preds = %5
  store i64 0, ptr @i, align 8, !tbaa !5
  %7 = load i64, ptr @t, align 8, !tbaa !5
  %8 = icmp sgt i64 %7, 0
  br i1 %8, label %.lr.ph30, label %._crit_edge31

.lr.ph30:                                         ; preds = %.preheader17, %72
  %9 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) @n)
          to label %.preheader13 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

.preheader13:                                     ; preds = %.lr.ph30
  store i64 0, ptr @j, align 8, !tbaa !5
  %10 = load i64, ptr @n, align 8, !tbaa !5
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %15
  store i64 0, ptr @j, align 8, !tbaa !5
  %12 = icmp sgt i64 %18, 0
  br i1 %12, label %.lr.ph23, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader13, %15
  %storemerge821 = phi i64 [ %17, %15 ], [ 0, %.preheader13 ]
  %13 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %storemerge821
  %14 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %15 unwind label %.loopexit.split-lp.loopexit

15:                                               ; preds = %.lr.ph
  %16 = load i64, ptr @j, align 8, !tbaa !5
  %17 = add nsw i64 %16, 1
  store i64 %17, ptr @j, align 8, !tbaa !5
  %18 = load i64, ptr @n, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %.lr.ph, label %.preheader, !llvm.loop !9

20:                                               ; preds = %0
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %78

22:                                               ; preds = %3
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %77

.loopexit:                                        ; preds = %.lr.ph23
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %.lr.ph
  %lpad.loopexit14 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp.loopexit:    ; preds = %.lr.ph30, %._crit_edge, %32, %35, %59, %61, %65, %67, %70
  %lpad.loopexit18 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp: ; preds = %4, %5
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp:                               ; preds = %.loopexit.split-lp.loopexit, %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp, %.loopexit.split-lp.loopexit.split-lp.loopexit, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit14, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit18, %.loopexit.split-lp.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp ]
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  br label %77

.lr.ph23:                                         ; preds = %.preheader, %26
  %storemerge922 = phi i64 [ %28, %26 ], [ 0, %.preheader ]
  %24 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %storemerge922
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) %24)
          to label %26 unwind label %.loopexit

26:                                               ; preds = %.lr.ph23
  %27 = load i64, ptr @j, align 8, !tbaa !5
  %28 = add nsw i64 %27, 1
  store i64 %28, ptr @j, align 8, !tbaa !5
  %29 = load i64, ptr @n, align 8, !tbaa !5
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph23, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %26, %.preheader13, %.preheader
  %.lcssa = phi i64 [ %18, %.preheader ], [ %10, %.preheader13 ], [ %29, %26 ]
  %31 = getelementptr inbounds i64, ptr @a, i64 %.lcssa
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %31)
          to label %32 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

32:                                               ; preds = %._crit_edge
  %33 = load i64, ptr @n, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr @b, i64 %33
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @b, ptr noundef nonnull %34)
          to label %35 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

35:                                               ; preds = %32
  %36 = load i64, ptr @n, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr @b, i64 %36
  invoke void @_ZSt7reverseIPxEvT_S1_(ptr noundef nonnull @b, ptr noundef nonnull %37)
          to label %38 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

38:                                               ; preds = %35
  store i64 0, ptr @sum, align 8, !tbaa !5
  %39 = load i64, ptr @n, align 8, !tbaa !5
  %40 = icmp sgt i64 %39, 0
  br i1 %40, label %.lr.ph26.preheader, label %59

.lr.ph26.preheader:                               ; preds = %38
  %min.iters.check = icmp ult i64 %39, 4
  br i1 %min.iters.check, label %.lr.ph26.preheader45, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph26.preheader
  %n.vec = and i64 %39, 9223372036854775804
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %47, %vector.body ]
  %vec.phi41 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %48, %vector.body ]
  %41 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %index
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %wide.load = load <2 x i64>, ptr %41, align 16, !tbaa !5
  %wide.load42 = load <2 x i64>, ptr %42, align 16, !tbaa !5
  %43 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %index
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  %wide.load43 = load <2 x i64>, ptr %43, align 16, !tbaa !5
  %wide.load44 = load <2 x i64>, ptr %44, align 16, !tbaa !5
  %45 = mul nsw <2 x i64> %wide.load43, %wide.load
  %46 = mul nsw <2 x i64> %wide.load44, %wide.load42
  %47 = add <2 x i64> %45, %vec.phi
  %48 = add <2 x i64> %46, %vec.phi41
  %index.next = add nuw i64 %index, 4
  %49 = icmp eq i64 %index.next, %n.vec
  br i1 %49, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %48, %47
  %50 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %39, %n.vec
  br i1 %cmp.n, label %._crit_edge27, label %.lr.ph26.preheader45

.lr.ph26.preheader45:                             ; preds = %middle.block, %.lr.ph26.preheader
  %storemerge1024.ph = phi i64 [ 0, %.lr.ph26.preheader ], [ %n.vec, %middle.block ]
  %.ph = phi i64 [ 0, %.lr.ph26.preheader ], [ %50, %middle.block ]
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader45, %.lr.ph26
  %storemerge1024 = phi i64 [ %58, %.lr.ph26 ], [ %storemerge1024.ph, %.lr.ph26.preheader45 ]
  %51 = phi i64 [ %57, %.lr.ph26 ], [ %.ph, %.lr.ph26.preheader45 ]
  %52 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %storemerge1024
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = getelementptr inbounds [1000 x i64], ptr @b, i64 0, i64 %storemerge1024
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = mul nsw i64 %55, %53
  %57 = add nsw i64 %56, %51
  %58 = add nuw nsw i64 %storemerge1024, 1
  %exitcond.not = icmp eq i64 %58, %39
  br i1 %exitcond.not, label %._crit_edge27, label %.lr.ph26, !llvm.loop !15

._crit_edge27:                                    ; preds = %.lr.ph26, %middle.block
  %.lcssa40 = phi i64 [ %50, %middle.block ], [ %57, %.lr.ph26 ]
  store i64 %.lcssa40, ptr @sum, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %._crit_edge27, %38
  %storemerge10.lcssa = phi i64 [ %39, %._crit_edge27 ], [ 0, %38 ]
  store i64 %storemerge10.lcssa, ptr @j, align 8, !tbaa !5
  %60 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull @.str.2)
          to label %61 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

61:                                               ; preds = %59
  %62 = load i64, ptr @i, align 8, !tbaa !5
  %63 = add nsw i64 %62, 1
  %64 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %60, i64 noundef %63)
          to label %65 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

65:                                               ; preds = %61
  %66 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %64, ptr noundef nonnull @.str.3)
          to label %67 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

67:                                               ; preds = %65
  %68 = load i64, ptr @sum, align 8, !tbaa !5
  %69 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %66, i64 noundef %68)
          to label %70 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

70:                                               ; preds = %67
  %71 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %69, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %72 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

72:                                               ; preds = %70
  %73 = load i64, ptr @i, align 8, !tbaa !5
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr @i, align 8, !tbaa !5
  %75 = load i64, ptr @t, align 8, !tbaa !5
  %76 = icmp slt i64 %74, %75
  br i1 %76, label %.lr.ph30, label %._crit_edge31, !llvm.loop !16

._crit_edge31:                                    ; preds = %72, %.preheader17
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #6
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %1) #6
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %1) #6
  ret i32 0

77:                                               ; preds = %.loopexit.split-lp, %22
  %.pn = phi { ptr, i32 } [ %lpad.phi, %.loopexit.split-lp ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #6
  br label %78

78:                                               ; preds = %77, %20
  %.pn.pn = phi { ptr, i32 } [ %.pn, %77 ], [ %21, %20 ]
  call void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256) %1) #6
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn.pn
}

; 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 uwtable
declare void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #2 align 2

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

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

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

; 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 @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2 align 2

; 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: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #4 align 2

; 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 void @_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(256)) unnamed_addr #4 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !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, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !10, !14, !13}
!16 = distinct !{!16, !10}


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