; LLVM IR from kazunetakahashi/atcoder :: 2018/0211_rco-contest-2018-qual/B.ll (Z9make_swap5pointS_)

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

%"class.std::vector.2" = type { %"struct.std::_Vector_base.3" }
%"struct.std::_Vector_base.3" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { %struct.point }
%struct.point = type { i32, i32 }
%"struct.std::_Head_base.1" = type { %struct.point }

@V = external dso_local global %"class.std::vector.2", align 8
@field = external dso_local global [200 x [200 x i32]], align 16

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

; 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) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9make_swap5pointS_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4 %0, i64 %1, i64 %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca %struct.point, align 4
  %6 = alloca %struct.point, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store i64 %1, ptr %5, align 4
  store i64 %2, ptr %6, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %9 = getelementptr inbounds %struct.point, ptr %5, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %11
  %13 = getelementptr inbounds %struct.point, ptr %5, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !10
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [200 x i32], ptr %12, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %17, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %18 = getelementptr inbounds %struct.point, ptr %6, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.point, ptr %6, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !10
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200 x i32], ptr %21, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %26, ptr %8, align 4, !tbaa !11
  %27 = load i32, ptr %7, align 4, !tbaa !11
  %28 = icmp sge i32 %27, 0
  br i1 %28, label %29, label %39

29:                                               ; preds = %3
  %30 = load i32, ptr %8, align 4, !tbaa !11
  %31 = icmp sge i32 %30, 0
  br i1 %31, label %32, label %39

32:                                               ; preds = %29
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %34) #5
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %37) #5
  call void @_ZSt4swapI5pointENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(8) %35, ptr noundef nonnull align 4 dereferenceable(8) %38) #5
  br label %55

39:                                               ; preds = %29, %3
  %40 = load i32, ptr %7, align 4, !tbaa !11
  %41 = icmp sge i32 %40, 0
  br i1 %41, label %42, label %46

42:                                               ; preds = %39
  %43 = load i32, ptr %7, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %44) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %45, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !12
  br label %54

46:                                               ; preds = %39
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = icmp sge i32 %47, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = load i32, ptr %8, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %51) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %52, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  br label %53

53:                                               ; preds = %49, %46
  br label %54

54:                                               ; preds = %53, %42
  br label %55

55:                                               ; preds = %54, %32
  %56 = load i32, ptr %8, align 4, !tbaa !11
  %57 = getelementptr inbounds %struct.point, ptr %5, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.point, ptr %5, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !10
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200 x i32], ptr %60, i64 0, i64 %63
  store i32 %56, ptr %64, align 4, !tbaa !11
  %65 = load i32, ptr %7, align 4, !tbaa !11
  %66 = getelementptr inbounds %struct.point, ptr %6, i32 0, i32 0
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.point, ptr %6, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !10
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [200 x i32], ptr %69, i64 0, i64 %72
  store i32 %65, ptr %73, align 4, !tbaa !11
  call void @_ZSt10make_tupleIJR5pointS1_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind writable sret(%"class.std::tuple") align 4 %0, ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJR5pointS1_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTS5point", !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}
!12 = !{i64 0, i64 4, !11, i64 4, i64 4, !11}


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

%"class.std::vector.2" = type { %"struct.std::_Vector_base.3" }
%"struct.std::_Vector_base.3" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl" = type { %"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" }
%"struct.std::_Vector_base<point, std::allocator<point>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { %struct.point }
%struct.point = type { i32, i32 }
%"struct.std::_Head_base.1" = type { %struct.point }

@V = external dso_local global %"class.std::vector.2", align 8
@field = external dso_local local_unnamed_addr global [200 x [200 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z9make_swap5pointS_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4 %0, i64 %1, i64 %2) local_unnamed_addr #0 {
  %4 = alloca %struct.point, align 8
  %5 = alloca %struct.point, align 8
  store i64 %1, ptr %4, align 8
  store i64 %2, ptr %5, align 8
  %sext = shl i64 %1, 32
  %6 = ashr exact i64 %sext, 32
  %7 = ashr i64 %1, 32
  %8 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %6, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %sext14 = shl i64 %2, 32
  %10 = ashr exact i64 %sext14, 32
  %11 = ashr i64 %2, 32
  %12 = getelementptr inbounds [200 x [200 x i32]], ptr @field, i64 0, i64 %10, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp sgt i32 %9, -1
  %15 = icmp sgt i32 %13, -1
  %or.cond = select i1 %14, i1 %15, i1 false
  br i1 %or.cond, label %16, label %21

16:                                               ; preds = %3
  %17 = zext nneg i32 %9 to i64
  %18 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %17) #2
  %19 = zext nneg i32 %13 to i64
  %20 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %19) #2
  tail call void @_ZSt4swapI5pointENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(8) %20) #2
  br label %29

21:                                               ; preds = %3
  br i1 %14, label %22, label %25

22:                                               ; preds = %21
  %23 = zext nneg i32 %9 to i64
  %24 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %23) #2
  store i64 %2, ptr %24, align 4
  br label %29

25:                                               ; preds = %21
  br i1 %15, label %26, label %29

26:                                               ; preds = %25
  %27 = zext nneg i32 %13 to i64
  %28 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %27) #2
  store i64 %1, ptr %28, align 4
  br label %29

29:                                               ; preds = %22, %26, %25, %16
  store i32 %13, ptr %8, align 4, !tbaa !5
  store i32 %9, ptr %12, align 4, !tbaa !5
  call void @_ZSt10make_tupleIJR5pointS1_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind writable sret(%"class.std::tuple") align 4 %0, ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5)
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5pointSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt10make_tupleIJR5pointS1_EESt5tupleIJDpNSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeEEEDpOS5_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0

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" }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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