; LLVM IR from romerojosh/zefr :: src/polynomials.ll (Z10Legendre3Djdddj)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::__cxx11::basic_stringstream" = type { %"class.std::basic_iostream.base", %"class.std::__cxx11::basic_stringbuf", %"class.std::basic_ios" }
%"class.std::basic_iostream.base" = type { %"class.std::basic_istream.base", %"class.std::basic_ostream.base" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@__func__._Z10Legendre3Djdddj = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z8Legendrejd(i32 noundef, double noundef) #0

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

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

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

declare i32 @__gxx_personality_v0(...)

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress uwtable
declare void @_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(128)) #0 align 2

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #5

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

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #6 align 2

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z10Legendre3Djdddj(i32 noundef %0, double noundef %1, double noundef %2, double noundef %3, i32 noundef %4) #0 personality ptr @__gxx_personality_v0 {
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.std::__cxx11::basic_stringstream", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca %"class.std::__cxx11::basic_string", align 8
  %17 = alloca i1, align 1
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = add i32 %27, 1
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = add i32 %29, 1
  %31 = mul i32 %28, %30
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = add i32 %32, 1
  %34 = mul i32 %31, %33
  store i32 %34, ptr %12, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = load i32, ptr %12, align 4, !tbaa !5
  %37 = icmp uge i32 %35, %36
  br i1 %37, label %38, label %74

38:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 392, ptr %13) #7
  call void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(128) %13)
  %39 = getelementptr inbounds i8, ptr %13, i64 16
  %40 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef @.str)
          to label %41 unwind label %57

41:                                               ; preds = %38
  %42 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %40, ptr noundef @.str.1)
          to label %43 unwind label %57

43:                                               ; preds = %41
  %44 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %42, i32 noundef 569)
          to label %45 unwind label %57

45:                                               ; preds = %43
  %46 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef @.str.1)
          to label %47 unwind label %57

47:                                               ; preds = %45
  %48 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %46, ptr noundef @__func__._Z10Legendre3Djdddj)
          to label %49 unwind label %57

49:                                               ; preds = %47
  %50 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef @.str.2)
          to label %51 unwind label %57

51:                                               ; preds = %49
  %52 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %50, ptr noundef @.str.3)
          to label %53 unwind label %57

53:                                               ; preds = %51
  store i1 true, ptr %17, align 1
  %54 = call ptr @__cxa_allocate_exception(i64 16) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %16) #7
  invoke void @_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %16, ptr noundef nonnull align 8 dereferenceable(128) %13)
          to label %55 unwind label %61

55:                                               ; preds = %53
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %54, ptr noundef nonnull align 8 dereferenceable(32) %16)
          to label %56 unwind label %65

56:                                               ; preds = %55
  store i1 false, ptr %17, align 1
  invoke void @__cxa_throw(ptr %54, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
          to label %171 unwind label %65

57:                                               ; preds = %51, %49, %47, %45, %43, %41, %38
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %14, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %15, align 4
  br label %73

61:                                               ; preds = %53
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %14, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %15, align 4
  br label %69

65:                                               ; preds = %56, %55
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %14, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %15, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %16) #7
  br label %69

69:                                               ; preds = %65, %61
  call void @llvm.lifetime.end.p0(i64 32, ptr %16) #7
  %70 = load i1, ptr %17, align 1
  br i1 %70, label %71, label %72

71:                                               ; preds = %69
  call void @__cxa_free_exception(ptr %54) #7
  br label %72

72:                                               ; preds = %71, %69
  br label %73

73:                                               ; preds = %72, %57
  call void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(128) %13) #7
  call void @llvm.lifetime.end.p0(i64 392, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %166

74:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %161, %74
  %76 = load i32, ptr %22, align 4, !tbaa !5
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = mul i32 3, %77
  %79 = icmp ule i32 %76, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %75
  store i32 2, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %164

81:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %157, %81
  %83 = load i32, ptr %24, align 4, !tbaa !5
  %84 = load i32, ptr %22, align 4, !tbaa !5
  %85 = icmp ule i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 5, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %160

87:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  store i32 0, ptr %25, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %153, %87
  %89 = load i32, ptr %25, align 4, !tbaa !5
  %90 = load i32, ptr %22, align 4, !tbaa !5
  %91 = load i32, ptr %24, align 4, !tbaa !5
  %92 = sub i32 %90, %91
  %93 = icmp ule i32 %89, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %88
  store i32 8, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  br label %156

95:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %96 = load i32, ptr %22, align 4, !tbaa !5
  %97 = load i32, ptr %24, align 4, !tbaa !5
  %98 = sub i32 %96, %97
  %99 = load i32, ptr %25, align 4, !tbaa !5
  %100 = sub i32 %98, %99
  store i32 %100, ptr %26, align 4, !tbaa !5
  %101 = load i32, ptr %26, align 4, !tbaa !5
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = icmp ule i32 %101, %102
  br i1 %103, label %104, label %152

104:                                              ; preds = %95
  %105 = load i32, ptr %25, align 4, !tbaa !5
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = icmp ule i32 %105, %106
  br i1 %107, label %108, label %152

108:                                              ; preds = %104
  %109 = load i32, ptr %24, align 4, !tbaa !5
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = icmp ule i32 %109, %110
  br i1 %111, label %112, label %152

112:                                              ; preds = %108
  %113 = load i32, ptr %21, align 4, !tbaa !5
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %116, label %149

116:                                              ; preds = %112
  %117 = load i32, ptr %26, align 4, !tbaa !5
  %118 = uitofp i32 %117 to double
  %119 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %118, double 1.000000e+00)
  %120 = fdiv double 2.000000e+00, %119
  %121 = call double @sqrt(double noundef %120) #7
  store double %121, ptr %18, align 8, !tbaa !9
  %122 = load i32, ptr %25, align 4, !tbaa !5
  %123 = uitofp i32 %122 to double
  %124 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %123, double 1.000000e+00)
  %125 = fdiv double 2.000000e+00, %124
  %126 = call double @sqrt(double noundef %125) #7
  store double %126, ptr %19, align 8, !tbaa !9
  %127 = load i32, ptr %24, align 4, !tbaa !5
  %128 = uitofp i32 %127 to double
  %129 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %128, double 1.000000e+00)
  %130 = fdiv double 2.000000e+00, %129
  %131 = call double @sqrt(double noundef %130) #7
  store double %131, ptr %20, align 8, !tbaa !9
  %132 = load i32, ptr %26, align 4, !tbaa !5
  %133 = load double, ptr %7, align 8, !tbaa !9
  %134 = call noundef double @_Z8Legendrejd(i32 noundef %132, double noundef %133)
  %135 = load i32, ptr %25, align 4, !tbaa !5
  %136 = load double, ptr %8, align 8, !tbaa !9
  %137 = call noundef double @_Z8Legendrejd(i32 noundef %135, double noundef %136)
  %138 = fmul double %134, %137
  %139 = load i32, ptr %24, align 4, !tbaa !5
  %140 = load double, ptr %9, align 8, !tbaa !9
  %141 = call noundef double @_Z8Legendrejd(i32 noundef %139, double noundef %140)
  %142 = fmul double %138, %141
  %143 = load double, ptr %18, align 8, !tbaa !9
  %144 = load double, ptr %19, align 8, !tbaa !9
  %145 = fmul double %143, %144
  %146 = load double, ptr %20, align 8, !tbaa !9
  %147 = fmul double %145, %146
  %148 = fdiv double %142, %147
  store double %148, ptr %11, align 8, !tbaa !9
  br label %149

149:                                              ; preds = %116, %112
  %150 = load i32, ptr %21, align 4, !tbaa !5
  %151 = add i32 %150, 1
  store i32 %151, ptr %21, align 4, !tbaa !5
  br label %152

152:                                              ; preds = %149, %108, %104, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %25, align 4, !tbaa !5
  %155 = add i32 %154, 1
  store i32 %155, ptr %25, align 4, !tbaa !5
  br label %88, !llvm.loop !11

156:                                              ; preds = %94
  br label %157

157:                                              ; preds = %156
  %158 = load i32, ptr %24, align 4, !tbaa !5
  %159 = add i32 %158, 1
  store i32 %159, ptr %24, align 4, !tbaa !5
  br label %82, !llvm.loop !13

160:                                              ; preds = %86
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %22, align 4, !tbaa !5
  %163 = add i32 %162, 1
  store i32 %163, ptr %22, align 4, !tbaa !5
  br label %75, !llvm.loop !14

164:                                              ; preds = %80
  %165 = load double, ptr %11, align 8, !tbaa !9
  store i32 1, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  ret double %165

166:                                              ; preds = %73
  %167 = load ptr, ptr %14, align 8
  %168 = load i32, ptr %15, align 4
  %169 = insertvalue { ptr, i32 } poison, ptr %167, 0
  %170 = insertvalue { ptr, i32 } %169, i32 %168, 1
  resume { ptr, i32 } %170

171:                                              ; preds = %56
  unreachable
}

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 speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::__cxx11::basic_stringstream" = type { %"class.std::basic_iostream.base", %"class.std::__cxx11::basic_stringbuf", %"class.std::basic_ios" }
%"class.std::basic_iostream.base" = type { %"class.std::basic_istream.base", %"class.std::basic_ostream.base" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@__func__._Z10Legendre3Djdddj = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z8Legendrejd(i32 noundef, double noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4

declare i32 @__gxx_personality_v0(...)

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #5

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare void @_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #0 align 2

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #5

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

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #7 align 2

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #7 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z10Legendre3Djdddj(i32 noundef %0, double noundef %1, double noundef %2, double noundef %3, i32 noundef %4) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.std::__cxx11::basic_stringstream", align 8
  %7 = alloca %"class.std::__cxx11::basic_string", align 8
  %8 = add i32 %0, 1
  %9 = mul i32 %8, %8
  %10 = mul i32 %9, %8
  %.not = icmp ugt i32 %10, %4
  br i1 %.not, label %.preheader74, label %12

.preheader74:                                     ; preds = %5
  %11 = mul i32 %0, 3
  br label %.preheader73

12:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 392, ptr nonnull %6) #8
  call void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(128) %6)
  %13 = getelementptr inbounds i8, ptr %6, i64 16
  %14 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull @.str)
          to label %15 unwind label %32

15:                                               ; preds = %12
  %16 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull @.str.1)
          to label %17 unwind label %32

17:                                               ; preds = %15
  %18 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %16, i32 noundef 569)
          to label %19 unwind label %32

19:                                               ; preds = %17
  %20 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull @.str.1)
          to label %21 unwind label %32

21:                                               ; preds = %19
  %22 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull @__func__._Z10Legendre3Djdddj)
          to label %23 unwind label %32

23:                                               ; preds = %21
  %24 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull @.str.2)
          to label %25 unwind label %32

25:                                               ; preds = %23
  %26 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull @.str.3)
          to label %27 unwind label %32

27:                                               ; preds = %25
  %28 = call ptr @__cxa_allocate_exception(i64 16) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #8
  invoke void @_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %7, ptr noundef nonnull align 8 dereferenceable(128) %6)
          to label %29 unwind label %.thread

29:                                               ; preds = %27
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 8 dereferenceable(32) %7)
          to label %31 unwind label %.thread71

.thread71:                                        ; preds = %29
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  br label %37

31:                                               ; preds = %29
  invoke void @__cxa_throw(ptr nonnull %28, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #9
          to label %72 unwind label %35

32:                                               ; preds = %25, %23, %21, %19, %17, %15, %12
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %38

.thread:                                          ; preds = %27
  %34 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  br label %37

35:                                               ; preds = %31
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  br label %38

37:                                               ; preds = %.thread71, %.thread
  %.pn70 = phi { ptr, i32 } [ %34, %.thread ], [ %30, %.thread71 ]
  call void @__cxa_free_exception(ptr %28) #8
  br label %38

38:                                               ; preds = %35, %37, %32
  %.pn.pn = phi { ptr, i32 } [ %.pn70, %37 ], [ %36, %35 ], [ %33, %32 ]
  call void @_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(128) %6) #8
  call void @llvm.lifetime.end.p0(i64 392, ptr nonnull %6) #8
  resume { ptr, i32 } %.pn.pn

.preheader73:                                     ; preds = %.preheader74, %44
  %.085 = phi double [ undef, %.preheader74 ], [ %.us-phi79, %44 ]
  %.04484 = phi i32 [ 0, %.preheader74 ], [ %45, %44 ]
  %.04583 = phi i32 [ 0, %.preheader74 ], [ %.us-phi, %44 ]
  br label %.preheader

39:                                               ; preds = %44
  ret double %.us-phi79

.preheader:                                       ; preds = %.preheader73, %.split.us
  %.182 = phi double [ %.085, %.preheader73 ], [ %.us-phi79, %.split.us ]
  %.04381 = phi i32 [ 0, %.preheader73 ], [ %46, %.split.us ]
  %.14680 = phi i32 [ %.04583, %.preheader73 ], [ %.us-phi, %.split.us ]
  %40 = sub i32 %.04484, %.04381
  %.not64 = icmp ugt i32 %.04381, %0
  %41 = uitofp i32 %.04381 to double
  %42 = tail call double @llvm.fmuladd.f64(double %41, double 2.000000e+00, double 1.000000e+00)
  %43 = fdiv double 2.000000e+00, %42
  br i1 %.not64, label %.split.us, label %.preheader.split

44:                                               ; preds = %.split.us
  %45 = add nuw i32 %.04484, 1
  %exitcond.not = icmp eq i32 %.04484, %11
  br i1 %exitcond.not, label %39, label %.preheader73, !llvm.loop !5

.split.us:                                        ; preds = %70, %.preheader
  %.us-phi = phi i32 [ %.14680, %.preheader ], [ %.348, %70 ]
  %.us-phi79 = phi double [ %.182, %.preheader ], [ %.4, %70 ]
  %46 = add i32 %.04381, 1
  %.not60 = icmp ugt i32 %46, %.04484
  br i1 %.not60, label %44, label %.preheader, !llvm.loop !7

.preheader.split:                                 ; preds = %.preheader, %70
  %.278 = phi double [ %.4, %70 ], [ %.182, %.preheader ]
  %.04276 = phi i32 [ %71, %70 ], [ 0, %.preheader ]
  %.24775 = phi i32 [ %.348, %70 ], [ %.14680, %.preheader ]
  %47 = sub i32 %40, %.04276
  %.not62 = icmp ugt i32 %47, %0
  %.not63 = icmp ugt i32 %.04276, %0
  %or.cond = or i1 %.not63, %.not62
  br i1 %or.cond, label %70, label %48

48:                                               ; preds = %.preheader.split
  %49 = icmp eq i32 %.24775, %4
  br i1 %49, label %50, label %68

50:                                               ; preds = %48
  %51 = uitofp i32 %47 to double
  %52 = tail call double @llvm.fmuladd.f64(double %51, double 2.000000e+00, double 1.000000e+00)
  %53 = fdiv double 2.000000e+00, %52
  %54 = tail call double @sqrt(double noundef %53) #8
  %55 = uitofp i32 %.04276 to double
  %56 = tail call double @llvm.fmuladd.f64(double %55, double 2.000000e+00, double 1.000000e+00)
  %57 = fdiv double 2.000000e+00, %56
  %58 = tail call double @sqrt(double noundef %57) #8
  %59 = tail call double @sqrt(double noundef %43) #8
  %60 = tail call noundef double @_Z8Legendrejd(i32 noundef %47, double noundef %1)
  %61 = tail call noundef double @_Z8Legendrejd(i32 noundef %.04276, double noundef %2)
  %62 = fmul double %60, %61
  %63 = tail call noundef double @_Z8Legendrejd(i32 noundef %.04381, double noundef %3)
  %64 = fmul double %62, %63
  %65 = fmul double %54, %58
  %66 = fmul double %65, %59
  %67 = fdiv double %64, %66
  br label %68

68:                                               ; preds = %50, %48
  %.3 = phi double [ %67, %50 ], [ %.278, %48 ]
  %69 = add i32 %.24775, 1
  br label %70

70:                                               ; preds = %68, %.preheader.split
  %.348 = phi i32 [ %69, %68 ], [ %.24775, %.preheader.split ]
  %.4 = phi double [ %.3, %68 ], [ %.278, %.preheader.split ]
  %71 = add i32 %.04276, 1
  %.not61 = icmp ugt i32 %71, %40
  br i1 %.not61, label %.split.us, label %.preheader.split, !llvm.loop !8

72:                                               ; preds = %31
  unreachable
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "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 = { inlinehint 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 #5 = { "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 #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


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