; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/DP/dp.ll (Z8minimizeii)

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

@ND = external dso_local global i32, align 4
@times = external dso_local global %"class.std::vector.0", 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 noundef i32 @_Z8minimizeii(i32 noundef %0, i32 noundef %1) #1 {
  %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
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = load i32, ptr @ND, align 4, !tbaa !5
  %15 = icmp eq i32 %13, %14
  br i1 %15, label %16, label %73

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 -1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %47, %16
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = load i32, ptr @ND, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %50

22:                                               ; preds = %17
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = shl i32 1, %24
  %26 = and i32 %23, %25
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %37

28:                                               ; preds = %22
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %30) #4
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = mul nsw i32 %32, 2
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %36, ptr %8, align 4, !tbaa !5
  br label %46

37:                                               ; preds = %22
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %39) #4
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = mul nsw i32 %41, 2
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = add nsw i32 %43, %42
  store i32 %44, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %45, ptr %9, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %37, %28
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %10, align 4, !tbaa !5
  br label %17, !llvm.loop !9

50:                                               ; preds = %21
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = icmp ne i32 %51, -1
  br i1 %52, label %53, label %60

53:                                               ; preds = %50
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %55) #4
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = sub nsw i32 %58, %57
  store i32 %59, ptr %6, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %53, %50
  %61 = load i32, ptr %9, align 4, !tbaa !5
  %62 = icmp ne i32 %61, -1
  br i1 %62, label %63, label %70

63:                                               ; preds = %60
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %65) #4
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = sub nsw i32 %68, %67
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %63, %60
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %72 = load i32, ptr %71, align 4, !tbaa !5
  store i32 %72, ptr %3, align 4
  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
  br label %87

73:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = shl i32 1, %77
  %79 = or i32 %76, %78
  %80 = call noundef i32 @_Z8minimizeii(i32 noundef %75, i32 noundef %79)
  store i32 %80, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = call noundef i32 @_Z8minimizeii(i32 noundef %82, i32 noundef %83)
  store i32 %84, ptr %12, align 4, !tbaa !5
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %86 = load i32, ptr %85, align 4, !tbaa !5
  store i32 %86, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %87

87:                                               ; preds = %73, %70
  %88 = load i32, ptr %3, align 4
  ret i32 %88
}

; 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) #2 align 2

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

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

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = 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 }

@ND = external dso_local local_unnamed_addr global i32, align 4
@times = external dso_local global %"class.std::vector.0", 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 nounwind uwtable
define dso_local noundef i32 @_Z8minimizeii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = load i32, ptr @ND, align 4, !tbaa !5
  %8 = icmp eq i32 %7, %0
  br i1 %8, label %9, label %42

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  %10 = icmp sgt i32 %0, 0
  br i1 %10, label %.lr.ph, label %.thread

._crit_edge:                                      ; preds = %23
  %.not = icmp eq i32 %.121, -1
  br i1 %.not, label %34, label %29

.lr.ph:                                           ; preds = %9, %23
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ 0, %9 ]
  %.01928 = phi i32 [ %.1, %23 ], [ -1, %9 ]
  %.02027 = phi i32 [ %.121, %23 ], [ -1, %9 ]
  %11 = phi i32 [ %25, %23 ], [ 0, %9 ]
  %12 = phi i32 [ %24, %23 ], [ 0, %9 ]
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  %14 = shl nuw i32 1, %13
  %15 = and i32 %14, %1
  %.not25 = icmp eq i32 %15, 0
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %indvars.iv) #3
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = shl nsw i32 %17, 1
  br i1 %.not25, label %21, label %19

19:                                               ; preds = %.lr.ph
  %20 = add nsw i32 %11, %18
  store i32 %20, ptr %3, align 4, !tbaa !5
  br label %23

21:                                               ; preds = %.lr.ph
  %22 = add nsw i32 %12, %18
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %19, %21
  %24 = phi i32 [ %12, %19 ], [ %22, %21 ]
  %25 = phi i32 [ %20, %19 ], [ %11, %21 ]
  %.121 = phi i32 [ %13, %19 ], [ %.02027, %21 ]
  %.1 = phi i32 [ %.01928, %19 ], [ %13, %21 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @ND, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !9

29:                                               ; preds = %._crit_edge
  %30 = sext i32 %.121 to i64
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %30) #3
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sub nsw i32 %25, %32
  store i32 %33, ptr %3, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %29, %._crit_edge
  %.not24 = icmp eq i32 %.1, -1
  br i1 %.not24, label %.thread, label %35

35:                                               ; preds = %34
  %36 = sext i32 %.1 to i64
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @times, i64 noundef %36) #3
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sub nsw i32 %24, %38
  store i32 %39, ptr %4, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %9, %35, %34
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %41 = load i32, ptr %40, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %common.ret42

common.ret42:                                     ; preds = %42, %.thread
  %common.ret42.op = phi i32 [ %41, %.thread ], [ %49, %42 ]
  ret i32 %common.ret42.op

42:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %43 = add nsw i32 %0, 1
  %44 = shl nuw i32 1, %0
  %45 = or i32 %44, %1
  %46 = tail call noundef i32 @_Z8minimizeii(i32 noundef %43, i32 noundef %45)
  store i32 %46, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %47 = tail call noundef i32 @_Z8minimizeii(i32 noundef %43, i32 noundef %1)
  store i32 %47, ptr %6, align 4, !tbaa !5
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %49 = load i32, ptr %48, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br label %common.ret42
}

; 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 #1 align 2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #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"}


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