; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2013-14/Jan 2014/14 Jan G1.ll (Z5aboveSt4pairIxxES0_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" = type { i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5aboveSt4pairIxxES0_S0_(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) #0 {
  %7 = alloca i1, align 1
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca %"struct.std::pair", align 8
  %11 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  store i64 %0, ptr %11, align 8
  %12 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  store i64 %1, ptr %12, align 8
  %13 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  store i64 %2, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  store i64 %3, ptr %14, align 8
  %15 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  store i64 %4, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  store i64 %5, ptr %16, align 8
  %17 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = icmp eq i64 %18, %20
  br i1 %21, label %22, label %32

22:                                               ; preds = %6
  %23 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !10
  %25 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %26 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull align 8 dereferenceable(8) %26)
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = icmp sge i64 %24, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  store i1 true, ptr %7, align 1
  br label %61

31:                                               ; preds = %22
  store i1 false, ptr %7, align 1
  br label %61

32:                                               ; preds = %6
  %33 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = sub nsw i64 %34, %36
  %38 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !10
  %40 = mul nsw i64 %37, %39
  %41 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !5
  %45 = sub nsw i64 %42, %44
  %46 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !10
  %48 = mul nsw i64 %45, %47
  %49 = add nsw i64 %40, %48
  %50 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = sub nsw i64 %51, %53
  %55 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !10
  %57 = mul nsw i64 %54, %56
  %58 = icmp sle i64 %49, %57
  br i1 %58, label %59, label %60

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

60:                                               ; preds = %32
  store i1 false, ptr %7, align 1
  br label %61

61:                                               ; preds = %60, %59, %31, %30
  %62 = load i1, ptr %7, align 1
  ret i1 %62
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(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" }

!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 = !{!"_ZTSSt4pairIxxE", !7, i64 0, !7, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !7, i64 0}


; 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" = type { i64, i64 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5aboveSt4pairIxxES0_S0_(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) local_unnamed_addr #0 {
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"struct.std::pair", align 8
  store i64 %2, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 %3, ptr %9, align 8
  store i64 %4, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 %5, ptr %10, align 8
  %11 = icmp eq i64 %2, %4
  br i1 %11, label %12, label %15

12:                                               ; preds = %6
  %13 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %.not5 = icmp sle i64 %14, %1
  br label %23

15:                                               ; preds = %6
  %16 = sub nsw i64 %0, %2
  %17 = mul nsw i64 %16, %5
  %18 = sub nsw i64 %4, %0
  %19 = mul nsw i64 %18, %3
  %20 = add nsw i64 %17, %19
  %21 = sub nsw i64 %4, %2
  %22 = mul nsw i64 %21, %1
  %.not = icmp sle i64 %20, %22
  br label %23

23:                                               ; preds = %15, %12
  %.0 = phi i1 [ %.not5, %12 ], [ %.not, %15 ]
  ret i1 %.0
}

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

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

!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: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass