; LLVM IR from quantumlib/Stim :: src/stim/util_bot (error_decomp)

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

@.str = external hidden unnamed_addr constant [51 x i8], align 1
@_ZTISt16invalid_argument = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4stim34independent_to_disjoint_xyz_errorsEdddPdS0_S0_(double noundef %0, double noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 personality ptr @__gxx_personality_v0 {
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  store double %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  %24 = load double, ptr %7, align 8, !tbaa !5
  %25 = fcmp olt double %24, 0.000000e+00
  br i1 %25, label %41, label %26

26:                                               ; preds = %6
  %27 = load double, ptr %8, align 8, !tbaa !5
  %28 = fcmp olt double %27, 0.000000e+00
  br i1 %28, label %41, label %29

29:                                               ; preds = %26
  %30 = load double, ptr %9, align 8, !tbaa !5
  %31 = fcmp olt double %30, 0.000000e+00
  br i1 %31, label %41, label %32

32:                                               ; preds = %29
  %33 = load double, ptr %7, align 8, !tbaa !5
  %34 = fcmp ogt double %33, 1.000000e+00
  br i1 %34, label %41, label %35

35:                                               ; preds = %32
  %36 = load double, ptr %8, align 8, !tbaa !5
  %37 = fcmp ogt double %36, 1.000000e+00
  br i1 %37, label %41, label %38

38:                                               ; preds = %35
  %39 = load double, ptr %9, align 8, !tbaa !5
  %40 = fcmp ogt double %39, 1.000000e+00
  br i1 %40, label %41, label %48

41:                                               ; preds = %38, %35, %32, %29, %26, %6
  %42 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef @.str)
          to label %43 unwind label %44

43:                                               ; preds = %41
  call void @__cxa_throw(ptr %42, ptr @_ZTISt16invalid_argument, ptr @_ZNSt16invalid_argumentD1Ev) #6
  unreachable

44:                                               ; preds = %41
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %13, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %14, align 4
  call void @__cxa_free_exception(ptr %42) #5
  br label %94

48:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %49 = load double, ptr %7, align 8, !tbaa !5
  %50 = load double, ptr %8, align 8, !tbaa !5
  %51 = fmul double %49, %50
  store double %51, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %52 = load double, ptr %7, align 8, !tbaa !5
  %53 = load double, ptr %9, align 8, !tbaa !5
  %54 = fmul double %52, %53
  store double %54, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %55 = load double, ptr %8, align 8, !tbaa !5
  %56 = load double, ptr %9, align 8, !tbaa !5
  %57 = fmul double %55, %56
  store double %57, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %58 = load double, ptr %7, align 8, !tbaa !5
  %59 = fsub double 1.000000e+00, %58
  store double %59, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %60 = load double, ptr %8, align 8, !tbaa !5
  %61 = fsub double 1.000000e+00, %60
  store double %61, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %62 = load double, ptr %9, align 8, !tbaa !5
  %63 = fsub double 1.000000e+00, %62
  store double %63, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %64 = load double, ptr %18, align 8, !tbaa !5
  %65 = load double, ptr %19, align 8, !tbaa !5
  %66 = fmul double %64, %65
  store double %66, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %67 = load double, ptr %18, align 8, !tbaa !5
  %68 = load double, ptr %20, align 8, !tbaa !5
  %69 = fmul double %67, %68
  store double %69, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %70 = load double, ptr %19, align 8, !tbaa !5
  %71 = load double, ptr %20, align 8, !tbaa !5
  %72 = fmul double %70, %71
  store double %72, ptr %23, align 8, !tbaa !5
  %73 = load double, ptr %7, align 8, !tbaa !5
  %74 = load double, ptr %23, align 8, !tbaa !5
  %75 = load double, ptr %18, align 8, !tbaa !5
  %76 = load double, ptr %17, align 8, !tbaa !5
  %77 = fmul double %75, %76
  %78 = call double @llvm.fmuladd.f64(double %73, double %74, double %77)
  %79 = load ptr, ptr %10, align 8, !tbaa !9
  store double %78, ptr %79, align 8, !tbaa !5
  %80 = load double, ptr %8, align 8, !tbaa !5
  %81 = load double, ptr %22, align 8, !tbaa !5
  %82 = load double, ptr %19, align 8, !tbaa !5
  %83 = load double, ptr %16, align 8, !tbaa !5
  %84 = fmul double %82, %83
  %85 = call double @llvm.fmuladd.f64(double %80, double %81, double %84)
  %86 = load ptr, ptr %11, align 8, !tbaa !9
  store double %85, ptr %86, align 8, !tbaa !5
  %87 = load double, ptr %9, align 8, !tbaa !5
  %88 = load double, ptr %21, align 8, !tbaa !5
  %89 = load double, ptr %20, align 8, !tbaa !5
  %90 = load double, ptr %15, align 8, !tbaa !5
  %91 = fmul double %89, %90
  %92 = call double @llvm.fmuladd.f64(double %87, double %88, double %91)
  %93 = load ptr, ptr %12, align 8, !tbaa !9
  store double %92, ptr %93, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret void

94:                                               ; preds = %44
  %95 = load ptr, ptr %13, align 8
  %96 = load i32, ptr %14, align 4
  %97 = insertvalue { ptr, i32 } poison, ptr %95, 0
  %98 = insertvalue { ptr, i32 } %97, i32 %96, 1
  resume { ptr, i32 } %98
}

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt16invalid_argumentD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

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

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 = { "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 "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }

!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 = !{!"any pointer", !7, 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"

@.str = external hidden unnamed_addr constant [51 x i8], align 1
@_ZTISt16invalid_argument = external constant ptr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4stim34independent_to_disjoint_xyz_errorsEdddPdS0_S0_(double noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %7 = fcmp olt double %0, 0.000000e+00
  %8 = fcmp olt double %1, 0.000000e+00
  %or.cond = or i1 %7, %8
  %9 = fcmp olt double %2, 0.000000e+00
  %or.cond3 = or i1 %or.cond, %9
  %10 = fcmp ogt double %0, 1.000000e+00
  %or.cond5 = or i1 %10, %or.cond3
  %11 = fcmp ogt double %1, 1.000000e+00
  %or.cond7 = or i1 %11, %or.cond5
  %12 = fcmp ogt double %2, 1.000000e+00
  %or.cond9 = or i1 %12, %or.cond7
  br i1 %or.cond9, label %13, label %18

13:                                               ; preds = %6
  %14 = tail call ptr @__cxa_allocate_exception(i64 16) #4
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull @.str)
          to label %15 unwind label %16

15:                                               ; preds = %13
  tail call void @__cxa_throw(ptr nonnull %14, ptr nonnull @_ZTISt16invalid_argument, ptr nonnull @_ZNSt16invalid_argumentD1Ev) #5
  unreachable

16:                                               ; preds = %13
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %14) #4
  resume { ptr, i32 } %17

18:                                               ; preds = %6
  %19 = fmul double %0, %1
  %20 = fmul double %0, %2
  %21 = fmul double %1, %2
  %22 = fsub double 1.000000e+00, %0
  %23 = fsub double 1.000000e+00, %1
  %24 = fsub double 1.000000e+00, %2
  %25 = fmul double %22, %23
  %26 = fmul double %22, %24
  %27 = fmul double %23, %24
  %28 = fmul double %22, %21
  %29 = tail call double @llvm.fmuladd.f64(double %0, double %27, double %28)
  store double %29, ptr %3, align 8, !tbaa !5
  %30 = fmul double %23, %20
  %31 = tail call double @llvm.fmuladd.f64(double %1, double %26, double %30)
  store double %31, ptr %4, align 8, !tbaa !5
  %32 = fmul double %19, %24
  %33 = tail call double @llvm.fmuladd.f64(double %2, double %25, double %32)
  store double %33, ptr %5, align 8, !tbaa !5
  ret void
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt16invalid_argumentD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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 = { "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 "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 }
attributes #5 = { noreturn }

!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"}


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