; LLVM IR from kazunetakahashi/atcoder :: 201510_201609/0320_chokudai001/A.ll (Z5solvev)

; 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" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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 }
%struct.point = type { i32, i32 }

@A = external dso_local global [30 x [30 x i32]], align 16
@ans = external dso_local global %"class.std::vector", align 8

; 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 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 @_Z5solvev() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.point, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %38, %0
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 30
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %41

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %34, %10
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 30
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %37

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %30, %15
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [30 x [30 x i32]], ptr @A, i64 0, i64 %19
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [30 x i32], ptr %20, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp slt i32 %17, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %16
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %33

27:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  call void @_ZN5pointC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %5, i32 noundef %28, i32 noundef %29)
  call void @_ZNSt6vectorI5pointSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) @ans, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %30

30:                                               ; preds = %27
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !9

33:                                               ; preds = %26
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !11

37:                                               ; preds = %14
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %1, align 4, !tbaa !5
  br label %6, !llvm.loop !12

41:                                               ; preds = %9
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI5pointSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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 }
%struct.point = type { i32, i32 }

@A = external dso_local local_unnamed_addr global [30 x [30 x i32]], align 16
@ans = external dso_local global %"class.std::vector", align 8

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

; Function Attrs: mustprogress 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 @_Z5solvev() local_unnamed_addr #1 {
  %1 = alloca %struct.point, align 4
  br label %.preheader12

.preheader12:                                     ; preds = %0, %8
  %indvars.iv17 = phi i64 [ 0, %0 ], [ %indvars.iv.next18, %8 ]
  %2 = trunc nuw nsw i64 %indvars.iv17 to i32
  br label %.preheader

3:                                                ; preds = %8
  ret void

.preheader:                                       ; preds = %.preheader12, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.preheader12 ], [ %indvars.iv.next, %._crit_edge ]
  %4 = getelementptr inbounds [30 x [30 x i32]], ptr @A, i64 0, i64 %indvars.iv17, i64 %indvars.iv
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %7 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.lr.ph

8:                                                ; preds = %._crit_edge
  %indvars.iv.next18 = add nuw nsw i64 %indvars.iv17, 1
  %exitcond20.not = icmp eq i64 %indvars.iv.next18, 30
  br i1 %exitcond20.not, label %3, label %.preheader12, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 30
  br i1 %exitcond.not, label %8, label %.preheader, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.013 = phi i32 [ %9, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  call void @_ZN5pointC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %1, i32 noundef %2, i32 noundef %7)
  call void @_ZNSt6vectorI5pointSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) @ans, ptr noundef nonnull align 4 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  %9 = add nuw nsw i32 %.013, 1
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.lr.ph, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI5pointSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass