; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数学算法/多项式拟合（辛普森积分）.ll (Z5solveeeee)

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

; 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
declare dso_local noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef, x86_fp80 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, x86_fp80 noundef %3) #1 {
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca x86_fp80, align 16
  %10 = alloca x86_fp80, align 16
  %11 = alloca x86_fp80, align 16
  %12 = alloca x86_fp80, align 16
  %13 = alloca i32, align 4
  store x86_fp80 %0, ptr %6, align 16, !tbaa !5
  store x86_fp80 %1, ptr %7, align 16, !tbaa !5
  store x86_fp80 %2, ptr %8, align 16, !tbaa !5
  store x86_fp80 %3, ptr %9, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #3
  %14 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %15 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %16 = fadd x86_fp80 %14, %15
  %17 = fdiv x86_fp80 %16, 0xK40008000000000000000
  store x86_fp80 %17, ptr %10, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #3
  %18 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %19 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %20 = call noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef %18, x86_fp80 noundef %19)
  store x86_fp80 %20, ptr %11, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %21 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %22 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %23 = call noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef %21, x86_fp80 noundef %22)
  store x86_fp80 %23, ptr %12, align 16, !tbaa !5
  %24 = load x86_fp80, ptr %11, align 16, !tbaa !5
  %25 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %26 = fadd x86_fp80 %24, %25
  %27 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %28 = fsub x86_fp80 %26, %27
  %29 = call noundef x86_fp80 @_ZSt4fabse(x86_fp80 noundef %28)
  %30 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %31 = fmul x86_fp80 0xK4002F000000000000000, %30
  %32 = fcmp ole x86_fp80 %29, %31
  br i1 %32, label %33, label %44

33:                                               ; preds = %4
  %34 = load x86_fp80, ptr %11, align 16, !tbaa !5
  %35 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %36 = fadd x86_fp80 %34, %35
  %37 = load x86_fp80, ptr %11, align 16, !tbaa !5
  %38 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %39 = fadd x86_fp80 %37, %38
  %40 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %41 = fsub x86_fp80 %39, %40
  %42 = fdiv x86_fp80 %41, 0xK4002F000000000000000
  %43 = fadd x86_fp80 %36, %42
  store x86_fp80 %43, ptr %5, align 16
  store i32 1, ptr %13, align 4
  br label %58

44:                                               ; preds = %4
  %45 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %46 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %47 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %48 = fdiv x86_fp80 %47, 0xK40008000000000000000
  %49 = load x86_fp80, ptr %11, align 16, !tbaa !5
  %50 = call noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %45, x86_fp80 noundef %46, x86_fp80 noundef %48, x86_fp80 noundef %49)
  %51 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %52 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %53 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %54 = fdiv x86_fp80 %53, 0xK40008000000000000000
  %55 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %56 = call noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %51, x86_fp80 noundef %52, x86_fp80 noundef %54, x86_fp80 noundef %55)
  %57 = fadd x86_fp80 %50, %56
  store x86_fp80 %57, ptr %5, align 16
  store i32 1, ptr %13, align 4
  br label %58

58:                                               ; preds = %44, %33
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #3
  %59 = load x86_fp80, ptr %5, align 16
  ret x86_fp80 %59
}

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

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


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

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef, x86_fp80 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, x86_fp80 noundef %3) local_unnamed_addr #0 {
  %5 = fadd x86_fp80 %0, %1
  %6 = fmul x86_fp80 %5, 0xK3FFE8000000000000000
  %7 = tail call noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef %0, x86_fp80 noundef %6)
  %8 = tail call noundef x86_fp80 @_Z7simpsonee(x86_fp80 noundef %6, x86_fp80 noundef %1)
  %9 = fadd x86_fp80 %7, %8
  %10 = fsub x86_fp80 %9, %3
  %11 = tail call noundef x86_fp80 @_ZSt4fabse(x86_fp80 noundef %10)
  %12 = fmul x86_fp80 %2, 0xK4002F000000000000000
  %13 = fcmp ugt x86_fp80 %11, %12
  br i1 %13, label %16, label %common.ret

common.ret:                                       ; preds = %4
  %14 = fdiv x86_fp80 %10, 0xK4002F000000000000000
  %15 = fadd x86_fp80 %9, %14
  br label %common.ret26

common.ret26:                                     ; preds = %16, %common.ret
  %common.ret26.op = phi x86_fp80 [ %15, %common.ret ], [ %20, %16 ]
  ret x86_fp80 %common.ret26.op

16:                                               ; preds = %4
  %17 = fmul x86_fp80 %2, 0xK3FFE8000000000000000
  %18 = tail call noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %0, x86_fp80 noundef %6, x86_fp80 noundef %17, x86_fp80 noundef %7)
  %19 = tail call noundef x86_fp80 @_Z5solveeeee(x86_fp80 noundef %6, x86_fp80 noundef %1, x86_fp80 noundef %17, x86_fp80 noundef %8)
  %20 = fadd x86_fp80 %18, %19
  br label %common.ret26
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt4fabse(x86_fp80 noundef) local_unnamed_addr #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 = { 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" }

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


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