; LLVM IR from eyangch/competitive-programming :: Codeforces/1156/d.ll (Z2unxxx)

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

@par = external dso_local global [2 x [200000 x i64]], align 16
@sz = external dso_local global [2 x [200000 x i64]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4findxx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2unxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !5
  %7 = load i64, ptr %4, align 8, !tbaa !5
  %8 = load i64, ptr %6, align 8, !tbaa !5
  %9 = call noundef i64 @_Z4findxx(i64 noundef %7, i64 noundef %8)
  store i64 %9, ptr %4, align 8, !tbaa !5
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = load i64, ptr %6, align 8, !tbaa !5
  %12 = call noundef i64 @_Z4findxx(i64 noundef %10, i64 noundef %11)
  store i64 %12, ptr %5, align 8, !tbaa !5
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = load i64, ptr %5, align 8, !tbaa !5
  %15 = icmp eq i64 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %3
  br label %51

17:                                               ; preds = %3
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %18
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds [200000 x i64], ptr %19, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %23
  %25 = load i64, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds [200000 x i64], ptr %24, i64 0, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = icmp slt i64 %22, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %17
  call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #2
  br label %30

30:                                               ; preds = %29, %17
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %31
  %33 = load i64, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds [200000 x i64], ptr %32, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = load i64, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %36
  %38 = load i64, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds [200000 x i64], ptr %37, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = add nsw i64 %40, %35
  store i64 %41, ptr %39, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds [2 x [200000 x i64]], ptr @par, i64 0, i64 %42
  %44 = load i64, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds [200000 x i64], ptr %43, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = load i64, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds [2 x [200000 x i64]], ptr @par, i64 0, i64 %47
  %49 = load i64, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds [200000 x i64], ptr %48, i64 0, i64 %49
  store i64 %46, ptr %50, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %30, %16
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

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


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

@par = external dso_local local_unnamed_addr global [2 x [200000 x i64]], align 16
@sz = external dso_local local_unnamed_addr global [2 x [200000 x i64]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4findxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2unxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = tail call noundef i64 @_Z4findxx(i64 noundef %0, i64 noundef %2)
  store i64 %6, ptr %4, align 8, !tbaa !5
  %7 = tail call noundef i64 @_Z4findxx(i64 noundef %1, i64 noundef %2)
  store i64 %7, ptr %5, align 8, !tbaa !5
  %8 = icmp eq i64 %6, %7
  br i1 %8, label %26, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %2, i64 %6
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %2, i64 %7
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = icmp slt i64 %11, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #2
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %2, i64 %.pre
  %.pre9 = load i64, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.pre10 = load i64, ptr %4, align 8, !tbaa !5
  %.phi.trans.insert11 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %2, i64 %.pre10
  %.pre12 = load i64, ptr %.phi.trans.insert11, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %9
  %17 = phi i64 [ %.pre12, %15 ], [ %11, %9 ]
  %18 = phi i64 [ %.pre10, %15 ], [ %6, %9 ]
  %19 = phi i64 [ %.pre9, %15 ], [ %13, %9 ]
  %20 = phi i64 [ %.pre, %15 ], [ %7, %9 ]
  %21 = getelementptr inbounds [2 x [200000 x i64]], ptr @sz, i64 0, i64 %2, i64 %18
  %22 = add nsw i64 %17, %19
  store i64 %22, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds [2 x [200000 x i64]], ptr @par, i64 0, i64 %2, i64 %18
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds [2 x [200000 x i64]], ptr @par, i64 0, i64 %2, i64 %20
  store i64 %24, ptr %25, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %3, %16
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass