; LLVM IR from ahr9n/psolving-paradigms :: 4.dynamic-programming/06.probabilities (CodeForces 167B - Wizards and Huge Prize)

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

@n = external dso_local global i32, align 4
@memo = external dso_local global [201 x [201 x [201 x x86_fp80]]], align 16
@a = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z2dpiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca x86_fp80, align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %3
  store x86_fp80 0xK00000000000000000000, ptr %4, align 16
  br label %84

17:                                               ; preds = %3
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %17
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = icmp sle i32 %22, 0
  %24 = uitofp i1 %23 to x86_fp80
  store x86_fp80 %24, ptr %4, align 16
  br label %84

25:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [201 x [201 x [201 x x86_fp80]]], ptr @memo, i64 0, i64 %27
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [201 x [201 x x86_fp80]], ptr %28, i64 0, i64 %30
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [201 x x86_fp80], ptr %31, i64 0, i64 %33
  store ptr %34, ptr %8, align 8, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = load x86_fp80, ptr %35, align 16, !tbaa !11
  %37 = fcmp une x86_fp80 %36, 0xKBFFF8000000000000000
  br i1 %37, label %38, label %41

38:                                               ; preds = %25
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = load x86_fp80, ptr %39, align 16, !tbaa !11
  store x86_fp80 %40, ptr %4, align 16
  store i32 1, ptr %9, align 4
  br label %83

41:                                               ; preds = %25
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %43) #5
  %45 = getelementptr inbounds %"struct.std::pair", ptr %44, i32 0, i32 1
  %46 = load x86_fp80, ptr %45, align 16, !tbaa !13
  %47 = fdiv x86_fp80 %46, 0xK4005C800000000000000
  %48 = fsub x86_fp80 0xK3FFF8000000000000000, %47
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = call noundef x86_fp80 @_Z2dpiii(i32 noundef %50, i32 noundef %51, i32 noundef %52)
  %54 = fmul x86_fp80 %48, %53
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  store x86_fp80 %54, ptr %55, align 16, !tbaa !11
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %57) #5
  %59 = getelementptr inbounds %"struct.std::pair", ptr %58, i32 0, i32 1
  %60 = load x86_fp80, ptr %59, align 16, !tbaa !13
  %61 = fdiv x86_fp80 %60, 0xK4005C800000000000000
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 200, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %66) #5
  %68 = getelementptr inbounds %"struct.std::pair", ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 16, !tbaa !15
  %70 = add nsw i32 %64, %69
  store i32 %70, ptr %11, align 4, !tbaa !5
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %72 = load i32, ptr %71, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sub nsw i32 %73, 1
  store i32 %74, ptr %13, align 4, !tbaa !5
  %75 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = call noundef x86_fp80 @_Z2dpiii(i32 noundef %63, i32 noundef %72, i32 noundef %76)
  %78 = load ptr, ptr %8, align 8, !tbaa !9
  %79 = load x86_fp80, ptr %78, align 16, !tbaa !11
  %80 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %61, x86_fp80 %77, x86_fp80 %79)
  store x86_fp80 %80, ptr %78, align 16, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %81 = load ptr, ptr %8, align 8, !tbaa !9
  %82 = load x86_fp80, ptr %81, align 16, !tbaa !11
  store x86_fp80 %82, ptr %4, align 16
  store i32 1, ptr %9, align 4
  br label %83

83:                                               ; preds = %41, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %84

84:                                               ; preds = %83, %21, %16
  %85 = load x86_fp80, ptr %4, align 16
  ret x86_fp80 %85
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(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 @_ZSt3minIiERKT_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 @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #4

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

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"_ZTSSt4pairIieE", !6, i64 0, !12, i64 16}
!15 = !{!14, !6, i64 0}


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

@n = external dso_local local_unnamed_addr global i32, align 4
@memo = external dso_local local_unnamed_addr global [201 x [201 x [201 x x86_fp80]]], align 16
@a = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef x86_fp80 @_Z2dpiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = icmp slt i32 %1, 0
  br i1 %8, label %46, label %9

9:                                                ; preds = %3
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp eq i32 %10, %0
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  %13 = icmp slt i32 %2, 1
  %14 = uitofp i1 %13 to x86_fp80
  br label %46

15:                                               ; preds = %9
  %16 = sext i32 %0 to i64
  %17 = zext nneg i32 %1 to i64
  %18 = sext i32 %2 to i64
  %19 = getelementptr inbounds [201 x [201 x [201 x x86_fp80]]], ptr @memo, i64 0, i64 %16, i64 %17, i64 %18
  %20 = load x86_fp80, ptr %19, align 16, !tbaa !9
  %21 = fcmp une x86_fp80 %20, 0xKBFFF8000000000000000
  br i1 %21, label %46, label %22

22:                                               ; preds = %15
  %23 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %16) #4
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %25 = load x86_fp80, ptr %24, align 16, !tbaa !11
  %26 = fdiv x86_fp80 %25, 0xK4005C800000000000000
  %27 = fsub x86_fp80 0xK3FFF8000000000000000, %26
  %28 = add nsw i32 %0, 1
  %29 = tail call noundef x86_fp80 @_Z2dpiii(i32 noundef %28, i32 noundef %1, i32 noundef %2)
  %30 = fmul x86_fp80 %29, %27
  store x86_fp80 %30, ptr %19, align 16, !tbaa !9
  %31 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %16) #4
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %33 = load x86_fp80, ptr %32, align 16, !tbaa !11
  %34 = fdiv x86_fp80 %33, 0xK4005C800000000000000
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 200, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %35 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @a, i64 noundef %16) #4
  %36 = load i32, ptr %35, align 16, !tbaa !13
  %37 = add nsw i32 %36, %1
  store i32 %37, ptr %5, align 4, !tbaa !5
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %39 = load i32, ptr %38, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %40 = add nsw i32 %2, -1
  store i32 %40, ptr %7, align 4, !tbaa !5
  %41 = 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)
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = call noundef x86_fp80 @_Z2dpiii(i32 noundef %28, i32 noundef %39, i32 noundef %42)
  %44 = load x86_fp80, ptr %19, align 16, !tbaa !9
  %45 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %34, x86_fp80 %43, x86_fp80 %44)
  store x86_fp80 %45, ptr %19, align 16, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %46

46:                                               ; preds = %22, %15, %3, %12
  %.1 = phi x86_fp80 [ %14, %12 ], [ 0xK00000000000000000000, %3 ], [ %45, %22 ], [ %20, %15 ]
  ret x86_fp80 %.1
}

; 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 nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(32) ptr @_ZNSt6vectorISt4pairIieESaIS1_EEixEm(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 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

; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSSt4pairIieE", !6, i64 0, !10, i64 16}
!13 = !{!12, !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass