; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2015-16/Jan 2016/Gold/16 Jan G3.ll (Z2isi)

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

@points = external dso_local global [200 x %"struct.std::pair"], align 16
@N = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2isi(i32 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"struct.std::pair", align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"struct.std::pair", align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr @N, align 4, !tbaa !5
  %18 = add nsw i32 %16, %17
  %19 = sub nsw i32 %18, 1
  %20 = load i32, ptr @N, align 4, !tbaa !5
  %21 = srem i32 %19, %20
  store i32 %21, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr @N, align 4, !tbaa !5
  %24 = srem i32 %22, %23
  store i32 %24, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  %27 = load i32, ptr @N, align 4, !tbaa !5
  %28 = srem i32 %26, %27
  store i32 %28, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %30
  %32 = getelementptr inbounds %"struct.std::pair", ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %35
  %37 = getelementptr inbounds %"struct.std::pair", ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !9
  %39 = sub nsw i32 %33, %38
  store i32 %39, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %41
  %43 = getelementptr inbounds %"struct.std::pair", ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %46
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !11
  %50 = sub nsw i32 %44, %49
  store i32 %50, ptr %9, align 4, !tbaa !5
  %51 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store i64 %51, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %53
  %55 = getelementptr inbounds %"struct.std::pair", ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %58
  %60 = getelementptr inbounds %"struct.std::pair", ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !9
  %62 = sub nsw i32 %56, %61
  store i32 %62, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %64
  %66 = getelementptr inbounds %"struct.std::pair", ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %69
  %71 = getelementptr inbounds %"struct.std::pair", ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = sub nsw i32 %67, %72
  store i32 %73, ptr %12, align 4, !tbaa !5
  %74 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  store i64 %74, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %75 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = sub nsw i32 0, %76
  store i32 %77, ptr %14, align 4, !tbaa !5
  %78 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %79 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %78)
  store i64 %79, ptr %13, align 4
  %80 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(8) %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %81 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = mul nsw i64 %83, %86
  %88 = icmp slt i64 %87, 0
  br i1 %88, label %98, label %89

89:                                               ; preds = %1
  %90 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = sext i32 %94 to i64
  %96 = mul nsw i64 %92, %95
  %97 = icmp slt i64 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %89, %1
  store i1 true, ptr %2, align 1
  store i32 1, ptr %15, align 4
  br label %100

99:                                               ; preds = %89
  store i1 false, ptr %2, align 1
  store i32 1, ptr %15, align 4
  br label %100

100:                                              ; preds = %99, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %101 = load i1, ptr %2, align 1
  ret i1 %101
}

; 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 dso_local i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

; 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)) #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, 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" = type { i32, i32 }

@points = external dso_local local_unnamed_addr global [200 x %"struct.std::pair"], align 16
@N = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z2isi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %"struct.std::pair", align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca i32, align 4
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %10 = add i32 %0, -1
  %11 = add i32 %10, %9
  %12 = srem i32 %11, %9
  %13 = srem i32 %0, %9
  %14 = add nsw i32 %0, 1
  %15 = srem i32 %14, %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %16 = sext i32 %12 to i64
  %17 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %16
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = sext i32 %13 to i64
  %20 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %19
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = sub nsw i32 %18, %21
  store i32 %22, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %23 = getelementptr inbounds i8, ptr %17, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %20, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = sub nsw i32 %24, %26
  store i32 %27, ptr %4, align 4, !tbaa !5
  %28 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i64 %28, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %29 = sext i32 %15 to i64
  %30 = getelementptr inbounds [200 x %"struct.std::pair"], ptr @points, i64 0, i64 %29
  %31 = load i32, ptr %30, align 8, !tbaa !9
  %32 = load i32, ptr %20, align 8, !tbaa !9
  %33 = sub nsw i32 %31, %32
  store i32 %33, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %34 = getelementptr inbounds i8, ptr %30, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = load i32, ptr %25, align 4, !tbaa !11
  %37 = sub nsw i32 %35, %36
  store i32 %37, ptr %6, align 4, !tbaa !5
  %38 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %39 = lshr i64 %28, 32
  %40 = trunc nuw i64 %39 to i32
  %41 = sub nsw i32 0, %40
  store i32 %41, ptr %8, align 4, !tbaa !5
  %42 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 %42, ptr %7, align 8
  %43 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  %44 = load i32, ptr %2, align 8, !tbaa !9
  %45 = sext i32 %44 to i64
  %sext = shl i64 %38, 32
  %46 = ashr exact i64 %sext, 32
  %47 = mul nsw i64 %46, %45
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %56, label %49

49:                                               ; preds = %1
  %50 = getelementptr inbounds i8, ptr %2, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = ashr i64 %38, 32
  %54 = mul nsw i64 %53, %52
  %55 = icmp slt i64 %54, 0
  br label %56

56:                                               ; preds = %49, %1
  %.0 = phi i1 [ true, %1 ], [ %55, %49 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i1 %.0
}

; 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 dso_local i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; 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 uwtable
declare dso_local i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; 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 #2 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass