; LLVM IR from xirc/cp-algorithm :: atcoder/abc010/C/main.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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@sx = external dso_local global i32, align 4
@sy = external dso_local global i32, align 4
@tx = external dso_local global i32, align 4
@ty = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@V = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@xs = external dso_local global %"class.std::vector", align 8
@ys = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4pow2i(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5solvev() #1 {
  %1 = alloca i1, align 1
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store double 1.000000e-08, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %10 = load i32, ptr @T, align 4, !tbaa !9
  %11 = load i32, ptr @V, align 4, !tbaa !9
  %12 = mul nsw i32 %10, %11
  %13 = call noundef i32 @_Z4pow2i(i32 noundef %12)
  store i32 %13, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %61, %0
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = load i32, ptr @N, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store i32 2, ptr %5, align 4
  br label %64

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @xs, i64 noundef %21) #4
  %23 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %23, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @ys, i64 noundef %25) #4
  %27 = load i32, ptr %26, align 4, !tbaa !9
  store i32 %27, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr @sx, align 4, !tbaa !9
  %30 = sub nsw i32 %28, %29
  %31 = call noundef i32 @_Z4pow2i(i32 noundef %30)
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = load i32, ptr @sy, align 4, !tbaa !9
  %34 = sub nsw i32 %32, %33
  %35 = call noundef i32 @_Z4pow2i(i32 noundef %34)
  %36 = add nsw i32 %31, %35
  store i32 %36, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = load i32, ptr @tx, align 4, !tbaa !9
  %39 = sub nsw i32 %37, %38
  %40 = call noundef i32 @_Z4pow2i(i32 noundef %39)
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load i32, ptr @ty, align 4, !tbaa !9
  %43 = sub nsw i32 %41, %42
  %44 = call noundef i32 @_Z4pow2i(i32 noundef %43)
  %45 = add nsw i32 %40, %44
  store i32 %45, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %46)
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %48)
  %50 = fadd double %47, %49
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %51)
  %53 = load double, ptr %2, align 8, !tbaa !5
  %54 = fadd double %52, %53
  %55 = fcmp olt double %50, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %19
  store i1 true, ptr %1, align 1
  store i32 1, ptr %5, align 4
  br label %58

57:                                               ; preds = %19
  store i32 0, ptr %5, align 4
  br label %58

58:                                               ; preds = %57, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %59 = load i32, ptr %5, align 4
  switch i32 %59, label %64 [
    i32 0, label %60
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %4, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %4, align 4, !tbaa !9
  br label %14, !llvm.loop !11

64:                                               ; preds = %58, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %65 = load i32, ptr %5, align 4
  switch i32 %65, label %67 [
    i32 2, label %66
  ]

66:                                               ; preds = %64
  store i1 false, ptr %1, align 1
  store i32 1, ptr %5, align 4
  br label %67

67:                                               ; preds = %66, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %68 = load i1, ptr %1, align 1
  ret i1 %68
}

; Function Attrs: 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(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #3

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@sx = external dso_local local_unnamed_addr global i32, align 4
@sy = external dso_local local_unnamed_addr global i32, align 4
@tx = external dso_local local_unnamed_addr global i32, align 4
@ty = external dso_local local_unnamed_addr global i32, align 4
@T = external dso_local local_unnamed_addr global i32, align 4
@V = external dso_local local_unnamed_addr global i32, align 4
@N = external dso_local local_unnamed_addr global i32, align 4
@xs = external dso_local global %"class.std::vector", align 8
@ys = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4pow2i(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5solvev() local_unnamed_addr #0 {
  %1 = load i32, ptr @T, align 4, !tbaa !5
  %2 = load i32, ptr @V, align 4, !tbaa !5
  %3 = mul nsw i32 %2, %1
  %4 = tail call noundef i32 @_Z4pow2i(i32 noundef %3)
  %5 = load i32, ptr @N, align 4, !tbaa !5
  %.not18 = icmp sgt i32 %5, 0
  br i1 %.not18, label %.lr.ph, label %.critedge

6:                                                ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %.not = icmp slt i64 %indvars.iv.next, %8
  br i1 %.not, label %.lr.ph, label %.critedge, !llvm.loop !9

.lr.ph:                                           ; preds = %0, %6
  %indvars.iv = phi i64 [ %indvars.iv.next, %6 ], [ 0, %0 ]
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @xs, i64 noundef %indvars.iv) #2
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @ys, i64 noundef %indvars.iv) #2
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = load i32, ptr @sx, align 4, !tbaa !5
  %14 = sub nsw i32 %10, %13
  %15 = tail call noundef i32 @_Z4pow2i(i32 noundef %14)
  %16 = load i32, ptr @sy, align 4, !tbaa !5
  %17 = sub nsw i32 %12, %16
  %18 = tail call noundef i32 @_Z4pow2i(i32 noundef %17)
  %19 = add nsw i32 %18, %15
  %20 = load i32, ptr @tx, align 4, !tbaa !5
  %21 = sub nsw i32 %10, %20
  %22 = tail call noundef i32 @_Z4pow2i(i32 noundef %21)
  %23 = load i32, ptr @ty, align 4, !tbaa !5
  %24 = sub nsw i32 %12, %23
  %25 = tail call noundef i32 @_Z4pow2i(i32 noundef %24)
  %26 = add nsw i32 %25, %22
  %27 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %19)
  %28 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %26)
  %29 = fadd double %27, %28
  %30 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %4)
  %31 = fadd double %30, 1.000000e-08
  %32 = fcmp olt double %29, %31
  br i1 %32, label %.critedge, label %6

.critedge:                                        ; preds = %.lr.ph, %6, %0
  %.not.lcssa = phi i1 [ false, %0 ], [ %32, %6 ], [ %32, %.lr.ph ]
  ret i1 %.not.lcssa
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) 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" }
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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass