; LLVM IR from tfhe/spqlios-arithmetic :: spqlios/reim4 (reim4_arithmetic_ref)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @reim4_add_mul(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %59, %3
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 4
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %62

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = getelementptr inbounds double, ptr %17, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !11
  store double %20, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = getelementptr inbounds double, ptr %21, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !11
  store double %24, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = add i64 %26, 4
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !11
  store double %29, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = add i64 %31, 4
  %33 = getelementptr inbounds double, ptr %30, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  store double %34, ptr %11, align 8, !tbaa !11
  %35 = load double, ptr %8, align 8, !tbaa !11
  %36 = load double, ptr %9, align 8, !tbaa !11
  %37 = load double, ptr %10, align 8, !tbaa !11
  %38 = load double, ptr %11, align 8, !tbaa !11
  %39 = fmul double %37, %38
  %40 = fneg double %39
  %41 = call double @llvm.fmuladd.f64(double %35, double %36, double %40)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %42, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = fadd double %45, %41
  store double %46, ptr %44, align 8, !tbaa !11
  %47 = load double, ptr %8, align 8, !tbaa !11
  %48 = load double, ptr %11, align 8, !tbaa !11
  %49 = load double, ptr %10, align 8, !tbaa !11
  %50 = load double, ptr %9, align 8, !tbaa !11
  %51 = fmul double %49, %50
  %52 = call double @llvm.fmuladd.f64(double %47, double %48, double %51)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load i64, ptr %7, align 8, !tbaa !9
  %55 = add i64 %54, 4
  %56 = getelementptr inbounds double, ptr %53, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = fadd double %57, %52
  store double %58, ptr %56, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %59

59:                                               ; preds = %16
  %60 = load i64, ptr %7, align 8, !tbaa !9
  %61 = add i64 %60, 1
  store i64 %61, ptr %7, align 8, !tbaa !9
  br label %12, !llvm.loop !13

62:                                               ; preds = %15
  ret void
}

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


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @reim4_add_mul(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 32
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fneg double %7
  %11 = fmul double %9, %10
  %12 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %11)
  %13 = load double, ptr %0, align 8, !tbaa !5
  %14 = fadd double %13, %12
  store double %14, ptr %0, align 8, !tbaa !5
  %15 = fmul double %5, %7
  %16 = tail call double @llvm.fmuladd.f64(double %4, double %9, double %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fadd double %16, %18
  store double %19, ptr %17, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %1, i64 40
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 40
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fneg double %25
  %29 = fmul double %27, %28
  %30 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %29)
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fadd double %32, %30
  store double %33, ptr %31, align 8, !tbaa !5
  %34 = fmul double %23, %25
  %35 = tail call double @llvm.fmuladd.f64(double %21, double %27, double %34)
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fadd double %35, %37
  store double %38, ptr %36, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %1, i64 16
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %2, i64 16
  %42 = load double, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 48
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %2, i64 48
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = fneg double %44
  %48 = fmul double %46, %47
  %49 = tail call double @llvm.fmuladd.f64(double %40, double %42, double %48)
  %50 = getelementptr inbounds i8, ptr %0, i64 16
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = fadd double %51, %49
  store double %52, ptr %50, align 8, !tbaa !5
  %53 = fmul double %42, %44
  %54 = tail call double @llvm.fmuladd.f64(double %40, double %46, double %53)
  %55 = getelementptr inbounds i8, ptr %0, i64 48
  %56 = load double, ptr %55, align 8, !tbaa !5
  %57 = fadd double %54, %56
  store double %57, ptr %55, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %1, i64 24
  %59 = load double, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %2, i64 24
  %61 = load double, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %1, i64 56
  %63 = load double, ptr %62, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %2, i64 56
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = fneg double %63
  %67 = fmul double %65, %66
  %68 = tail call double @llvm.fmuladd.f64(double %59, double %61, double %67)
  %69 = getelementptr inbounds i8, ptr %0, i64 24
  %70 = load double, ptr %69, align 8, !tbaa !5
  %71 = fadd double %70, %68
  store double %71, ptr %69, align 8, !tbaa !5
  %72 = fmul double %61, %63
  %73 = tail call double @llvm.fmuladd.f64(double %59, double %65, double %72)
  %74 = getelementptr inbounds i8, ptr %0, i64 56
  %75 = load double, ptr %74, align 8, !tbaa !5
  %76 = fadd double %73, %75
  store double %76, ptr %74, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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