; LLVM IR from ShahjalalShohag/code-library :: Math/Integration (Romberg).ll (Z1fe)

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

@z = external dso_local global i32, align 4
@d = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z1fe(x86_fp80 noundef %0) #0 {
  %2 = alloca x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  store x86_fp80 %0, ptr %2, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #4
  %7 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %8 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %9 = load i32, ptr @z, align 4, !tbaa !9
  %10 = load i32, ptr @z, align 4, !tbaa !9
  %11 = mul nsw i32 %9, %10
  %12 = sitofp i32 %11 to x86_fp80
  %13 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %7, x86_fp80 %8, x86_fp80 %12)
  %14 = call noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef %13)
  store x86_fp80 %14, ptr %3, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  %15 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %16 = load i32, ptr @d, align 4, !tbaa !9
  %17 = sitofp i32 %16 to x86_fp80
  %18 = fadd x86_fp80 %15, %17
  %19 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %20 = load i32, ptr @d, align 4, !tbaa !9
  %21 = sitofp i32 %20 to x86_fp80
  %22 = fadd x86_fp80 %19, %21
  %23 = load i32, ptr @z, align 4, !tbaa !9
  %24 = load i32, ptr @z, align 4, !tbaa !9
  %25 = mul nsw i32 %23, %24
  %26 = sitofp i32 %25 to x86_fp80
  %27 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 %22, x86_fp80 %26)
  %28 = call noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef %27)
  store x86_fp80 %28, ptr %4, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %29 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %30 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %31 = fsub x86_fp80 %29, %30
  %32 = load i32, ptr @d, align 4, !tbaa !9
  %33 = sitofp i32 %32 to x86_fp80
  %34 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %35 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %36 = fsub x86_fp80 %34, %35
  %37 = fsub x86_fp80 %33, %36
  %38 = fdiv x86_fp80 %37, 0xK40008000000000000000
  %39 = fadd x86_fp80 %31, %38
  store x86_fp80 %39, ptr %5, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  %40 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %41 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %42 = fmul x86_fp80 %40, %41
  %43 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %44 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %45 = fmul x86_fp80 %43, %44
  %46 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %42, x86_fp80 0xK3FFE8000000000000000, x86_fp80 %45)
  store x86_fp80 %46, ptr %6, align 16, !tbaa !5
  %47 = load i32, ptr @d, align 4, !tbaa !9
  %48 = sitofp i32 %47 to x86_fp80
  %49 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %50 = fsub x86_fp80 %48, %49
  %51 = load i32, ptr @d, align 4, !tbaa !9
  %52 = sitofp i32 %51 to x86_fp80
  %53 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %54 = fsub x86_fp80 %52, %53
  %55 = fmul x86_fp80 %50, %54
  %56 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %57 = load i32, ptr @d, align 4, !tbaa !9
  %58 = sitofp i32 %57 to x86_fp80
  %59 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %60 = fsub x86_fp80 %58, %59
  %61 = fmul x86_fp80 %56, %60
  %62 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %55, x86_fp80 0xK3FFE8000000000000000, x86_fp80 %61)
  %63 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %64 = fadd x86_fp80 %63, %62
  store x86_fp80 %64, ptr %6, align 16, !tbaa !5
  %65 = load i32, ptr @d, align 4, !tbaa !9
  %66 = sitofp i32 %65 to x86_fp80
  %67 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %68 = fdiv x86_fp80 %67, %66
  store x86_fp80 %68, ptr %6, align 16, !tbaa !5
  %69 = load x86_fp80, ptr %6, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  ret x86_fp80 %69
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef) #2

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

; 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 = { 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 = { 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 = !{!"long double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@z = external dso_local local_unnamed_addr global i32, align 4
@d = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef x86_fp80 @_Z1fe(x86_fp80 noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @z, align 4, !tbaa !5
  %3 = mul nsw i32 %2, %2
  %4 = uitofp nneg i32 %3 to x86_fp80
  %5 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %0, x86_fp80 %0, x86_fp80 %4)
  %6 = tail call noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef %5)
  %7 = load i32, ptr @d, align 4, !tbaa !5
  %8 = sitofp i32 %7 to x86_fp80
  %9 = fadd x86_fp80 %8, %0
  %10 = load i32, ptr @z, align 4, !tbaa !5
  %11 = mul nsw i32 %10, %10
  %12 = uitofp nneg i32 %11 to x86_fp80
  %13 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %9, x86_fp80 %9, x86_fp80 %12)
  %14 = tail call noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef %13)
  %15 = fsub x86_fp80 %14, %6
  %16 = load i32, ptr @d, align 4, !tbaa !5
  %17 = sitofp i32 %16 to x86_fp80
  %18 = fsub x86_fp80 %17, %15
  %19 = fmul x86_fp80 %18, 0xK3FFE8000000000000000
  %20 = fadd x86_fp80 %15, %19
  %21 = fmul x86_fp80 %20, %20
  %22 = fmul x86_fp80 %6, %20
  %23 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %21, x86_fp80 0xK3FFE8000000000000000, x86_fp80 %22)
  %24 = fsub x86_fp80 %17, %20
  %25 = fmul x86_fp80 %24, %24
  %26 = fmul x86_fp80 %14, %24
  %27 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %25, x86_fp80 0xK3FFE8000000000000000, x86_fp80 %26)
  %28 = fadd x86_fp80 %23, %27
  %29 = fdiv x86_fp80 %28, %17
  ret x86_fp80 %29
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt4sqrte(x86_fp80 noundef) local_unnamed_addr #1

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

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


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