; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2013-14/Open 2014/14 Open G2.ll (Z2onSt4pairIiiES0_S0_)

; 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.std::pair.13" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2onSt4pairIiiES0_S0_(i64 %0, i64 %1, i64 %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca %"struct.std::pair.13", align 4
  %6 = alloca %"struct.std::pair.13", align 4
  %7 = alloca %"struct.std::pair.13", align 4
  store i64 %0, ptr %5, align 4
  store i64 %1, ptr %6, align 4
  store i64 %2, ptr %7, align 4
  %8 = call noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6)
  br i1 %8, label %9, label %10

9:                                                ; preds = %3
  call void @_ZSt4swapIiiENSt9enable_ifIXsr6__and_ISt14__is_swappableIT_ES1_IT0_EEE5valueEvE4typeERSt4pairIS2_S4_ESA_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6) #3
  br label %10

10:                                               ; preds = %9, %3
  %11 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds %"struct.std::pair.13", ptr %5, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp eq i32 %12, %14
  br i1 %15, label %16, label %35

16:                                               ; preds = %10
  %17 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds %"struct.std::pair.13", ptr %6, i32 0, i32 0
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp eq i32 %18, %20
  br i1 %21, label %22, label %35

22:                                               ; preds = %16
  %23 = getelementptr inbounds %"struct.std::pair.13", ptr %5, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !10
  %25 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !10
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %35

28:                                               ; preds = %22
  %29 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !10
  %31 = getelementptr inbounds %"struct.std::pair.13", ptr %6, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !10
  %33 = icmp slt i32 %30, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %28
  store i1 true, ptr %4, align 1
  br label %61

35:                                               ; preds = %28, %22, %16, %10
  %36 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !10
  %38 = getelementptr inbounds %"struct.std::pair.13", ptr %5, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !10
  %40 = icmp eq i32 %37, %39
  br i1 %40, label %41, label %60

41:                                               ; preds = %35
  %42 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !10
  %44 = getelementptr inbounds %"struct.std::pair.13", ptr %6, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !10
  %46 = icmp eq i32 %43, %45
  br i1 %46, label %47, label %60

47:                                               ; preds = %41
  %48 = getelementptr inbounds %"struct.std::pair.13", ptr %5, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp slt i32 %49, %51
  br i1 %52, label %53, label %60

53:                                               ; preds = %47
  %54 = getelementptr inbounds %"struct.std::pair.13", ptr %7, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = getelementptr inbounds %"struct.std::pair.13", ptr %6, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = icmp slt i32 %55, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %53
  store i1 true, ptr %4, align 1
  br label %61

60:                                               ; preds = %53, %47, %41, %35
  store i1 false, ptr %4, align 1
  br label %61

61:                                               ; preds = %60, %59, %34
  %62 = load i1, ptr %4, align 1
  ret i1 %62
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { 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 #3 = { 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, !7, i64 0}
!6 = !{!"_ZTSSt4pairIiiE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


; 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.std::pair.13" = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2onSt4pairIiiES0_S0_(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 {
  %4 = alloca %"struct.std::pair.13", align 8
  %5 = alloca %"struct.std::pair.13", align 8
  store i64 %0, ptr %4, align 8
  store i64 %1, ptr %5, align 8
  %.sroa.0.0.extract.trunc = trunc i64 %2 to i32
  %.sroa.5.0.extract.shift = lshr i64 %2, 32
  %.sroa.5.0.extract.trunc = trunc nuw i64 %.sroa.5.0.extract.shift to i32
  %6 = call noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5)
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  call void @_ZSt4swapIiiENSt9enable_ifIXsr6__and_ISt14__is_swappableIT_ES1_IT0_EEE5valueEvE4typeERSt4pairIS2_S4_ESA_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5) #3
  br label %8

8:                                                ; preds = %7, %3
  %9 = load i32, ptr %4, align 8
  %10 = icmp eq i32 %9, %.sroa.0.0.extract.trunc
  %11 = load i32, ptr %5, align 8
  %12 = icmp eq i32 %11, %.sroa.0.0.extract.trunc
  %or.cond = select i1 %10, i1 %12, i1 false
  %13 = getelementptr inbounds i8, ptr %4, i64 4
  %14 = load i32, ptr %13, align 4
  %15 = icmp slt i32 %14, %.sroa.5.0.extract.trunc
  %or.cond10 = select i1 %or.cond, i1 %15, i1 false
  %16 = getelementptr inbounds i8, ptr %5, i64 4
  %17 = load i32, ptr %16, align 4
  %18 = icmp sgt i32 %17, %.sroa.5.0.extract.trunc
  %or.cond13 = select i1 %or.cond10, i1 %18, i1 false
  br i1 %or.cond13, label %24, label %19

19:                                               ; preds = %8
  %20 = icmp eq i32 %14, %.sroa.5.0.extract.trunc
  %21 = icmp eq i32 %17, %.sroa.5.0.extract.trunc
  %or.cond16 = select i1 %20, i1 %21, i1 false
  %22 = icmp slt i32 %9, %.sroa.0.0.extract.trunc
  %or.cond18 = select i1 %or.cond16, i1 %22, i1 false
  %23 = icmp sgt i32 %11, %.sroa.0.0.extract.trunc
  %or.cond20 = select i1 %or.cond18, i1 %23, i1 false
  br label %24

24:                                               ; preds = %19, %8
  %.0 = phi i1 [ true, %8 ], [ %or.cond20, %19 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { 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 #3 = { 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InstCombinePass,SROAPass,SimplifyCFGPass