; LLVM IR from eyangch/competitive-programming :: USACOcontests/silver/2013.02/tractor.ll (Z2unSt4pairIiiES0_RA500_A500_S0_RA500_A500_i)

; 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 { i32, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64, ptr noundef nonnull align 4 dereferenceable(2000000)) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2unSt4pairIiiES0_RA500_A500_S0_RA500_A500_i(i64 %0, i64 %1, ptr noundef nonnull align 4 dereferenceable(2000000) %2, ptr noundef nonnull align 4 dereferenceable(1000000) %3) #0 {
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca %"struct.std::pair", align 4
  %12 = alloca %"struct.std::pair", align 4
  store i64 %0, ptr %5, align 4
  store i64 %1, ptr %6, align 4
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %5, i64 8, i1 false)
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = load i64, ptr %10, align 4
  %15 = call i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64 %14, ptr noundef nonnull align 4 dereferenceable(2000000) %13)
  store i64 %15, ptr %9, align 4
  %16 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %6, i64 8, i1 false)
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i64, ptr %12, align 4
  %19 = call i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64 %18, ptr noundef nonnull align 4 dereferenceable(2000000) %17)
  store i64 %19, ptr %11, align 4
  %20 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %21 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6)
  br i1 %21, label %22, label %23

22:                                               ; preds = %4
  br label %109

23:                                               ; preds = %4
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [500 x [500 x i32]], ptr %24, i64 0, i64 %27
  %29 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [500 x i32], ptr %28, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [500 x [500 x i32]], ptr %34, i64 0, i64 %37
  %39 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [500 x i32], ptr %38, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !13
  %44 = icmp slt i32 %33, %43
  br i1 %44, label %45, label %77

45:                                               ; preds = %23
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [500 x [500 x %"struct.std::pair"]], ptr %46, i64 0, i64 %49
  %51 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !12
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [500 x %"struct.std::pair"], ptr %50, i64 0, i64 %53
  %55 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %54, ptr noundef nonnull align 4 dereferenceable(8) %6)
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [500 x [500 x i32]], ptr %56, i64 0, i64 %59
  %61 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !12
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [500 x i32], ptr %60, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !13
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [500 x [500 x i32]], ptr %66, i64 0, i64 %69
  %71 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !12
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [500 x i32], ptr %70, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !13
  %76 = add nsw i32 %75, %65
  store i32 %76, ptr %74, align 4, !tbaa !13
  br label %109

77:                                               ; preds = %23
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [500 x [500 x %"struct.std::pair"]], ptr %78, i64 0, i64 %81
  %83 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %84 = load i32, ptr %83, align 4, !tbaa !12
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [500 x %"struct.std::pair"], ptr %82, i64 0, i64 %85
  %87 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %86, ptr noundef nonnull align 4 dereferenceable(8) %5)
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [500 x [500 x i32]], ptr %88, i64 0, i64 %91
  %93 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !12
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [500 x i32], ptr %92, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !13
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [500 x [500 x i32]], ptr %98, i64 0, i64 %101
  %103 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !12
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [500 x i32], ptr %102, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !13
  %108 = add nsw i32 %107, %97
  store i32 %108, ptr %106, align 4, !tbaa !13
  br label %109

109:                                              ; preds = %77, %45, %22
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #4 align 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, 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 { i32, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64, ptr noundef nonnull align 4 dereferenceable(2000000)) local_unnamed_addr #0

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2unSt4pairIiiES0_RA500_A500_S0_RA500_A500_i(i64 %0, i64 %1, ptr noundef nonnull align 4 dereferenceable(2000000) %2, ptr nocapture noundef nonnull align 4 dereferenceable(1000000) %3) local_unnamed_addr #0 {
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"struct.std::pair", align 8
  store i64 %0, ptr %5, align 8
  store i64 %1, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %9 = tail call i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64 %0, ptr noundef nonnull align 4 dereferenceable(2000000) %2)
  store i64 %9, ptr %7, align 8
  %10 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %11 = call i64 @_Z4findSt4pairIiiERA500_A500_S0_(i64 %1, ptr noundef nonnull align 4 dereferenceable(2000000) %2)
  store i64 %11, ptr %8, align 8
  %12 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  %13 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6)
  br i1 %13, label %46, label %14

14:                                               ; preds = %4
  %15 = load i32, ptr %5, align 8, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %5, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !10
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [500 x [500 x i32]], ptr %3, i64 0, i64 %16, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = load i32, ptr %6, align 8, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %6, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [500 x [500 x i32]], ptr %3, i64 0, i64 %23, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = icmp slt i32 %21, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %14
  %31 = getelementptr inbounds [500 x [500 x %"struct.std::pair"]], ptr %2, i64 0, i64 %16, i64 %19
  %32 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %31, ptr noundef nonnull align 4 dereferenceable(8) %6)
  br label %.sink.split

33:                                               ; preds = %14
  %34 = getelementptr inbounds [500 x [500 x %"struct.std::pair"]], ptr %2, i64 0, i64 %23, i64 %26
  %35 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %34, ptr noundef nonnull align 4 dereferenceable(8) %5)
  br label %.sink.split

.sink.split:                                      ; preds = %30, %33
  %.sink21.in = phi ptr [ %5, %30 ], [ %6, %33 ]
  %.sink20 = phi ptr [ %17, %30 ], [ %24, %33 ]
  %.sink.in = phi ptr [ %6, %30 ], [ %5, %33 ]
  %.sink16 = phi ptr [ %24, %30 ], [ %17, %33 ]
  %.sink21 = load i32, ptr %.sink21.in, align 8, !tbaa !5
  %36 = sext i32 %.sink21 to i64
  %37 = load i32, ptr %.sink20, align 4, !tbaa !10
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [500 x [500 x i32]], ptr %3, i64 0, i64 %36, i64 %38
  %.sink13 = load i32, ptr %39, align 4, !tbaa !11
  %.sink = load i32, ptr %.sink.in, align 8, !tbaa !5
  %40 = sext i32 %.sink to i64
  %41 = load i32, ptr %.sink16, align 4, !tbaa !10
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [500 x [500 x i32]], ptr %3, i64 0, i64 %40, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = add nsw i32 %44, %.sink13
  store i32 %45, ptr %43, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %.sink.split, %4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass