; LLVM IR from ivan-pi/periodic-lbm :: third-party (dugks_cavity)

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

@ex = external dso_local global [3 x double], align 16
@ey = external dso_local global [3 x double], align 16
@tpx = external dso_local global [3 x double], align 16
@tpy = external dso_local global [3 x double], align 16
@RT = external dso_local global double, align 8

; 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 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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local double @feq(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store double %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [3 x double], ptr @ex, i64 0, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = load double, ptr %8, align 8, !tbaa !9
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [3 x double], ptr @ey, i64 0, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = load double, ptr %9, align 8, !tbaa !9
  %24 = fmul double %22, %23
  %25 = call double @llvm.fmuladd.f64(double %17, double %18, double %24)
  %26 = load double, ptr @RT, align 8, !tbaa !9
  %27 = fdiv double %25, %26
  store double %27, ptr %12, align 8, !tbaa !9
  %28 = load double, ptr %8, align 8, !tbaa !9
  %29 = load double, ptr %8, align 8, !tbaa !9
  %30 = load double, ptr %9, align 8, !tbaa !9
  %31 = load double, ptr %9, align 8, !tbaa !9
  %32 = fmul double %30, %31
  %33 = call double @llvm.fmuladd.f64(double %28, double %29, double %32)
  %34 = load double, ptr @RT, align 8, !tbaa !9
  %35 = fdiv double %33, %34
  store double %35, ptr %11, align 8, !tbaa !9
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [3 x double], ptr @tpx, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [3 x double], ptr @tpy, i64 0, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fmul double %39, %43
  %45 = load double, ptr %10, align 8, !tbaa !9
  %46 = fmul double %44, %45
  %47 = load double, ptr %12, align 8, !tbaa !9
  %48 = fadd double 1.000000e+00, %47
  %49 = load double, ptr %12, align 8, !tbaa !9
  %50 = load double, ptr %12, align 8, !tbaa !9
  %51 = load double, ptr %11, align 8, !tbaa !9
  %52 = fneg double %51
  %53 = call double @llvm.fmuladd.f64(double %49, double %50, double %52)
  %54 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %53, double %48)
  %55 = fmul double %46, %54
  store double %55, ptr %13, align 8, !tbaa !9
  %56 = load double, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret double %56
}

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

@ex = external dso_local local_unnamed_addr global [3 x double], align 16
@ey = external dso_local local_unnamed_addr global [3 x double], align 16
@tpx = external dso_local local_unnamed_addr global [3 x double], align 16
@tpy = external dso_local local_unnamed_addr global [3 x double], align 16
@RT = external dso_local local_unnamed_addr global double, align 8

; 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(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local double @feq(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #1 {
  %6 = sext i32 %0 to i64
  %7 = getelementptr inbounds [3 x double], ptr @ex, i64 0, i64 %6
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = sext i32 %1 to i64
  %10 = getelementptr inbounds [3 x double], ptr @ey, i64 0, i64 %9
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fmul double %11, %3
  %13 = tail call double @llvm.fmuladd.f64(double %8, double %2, double %12)
  %14 = load double, ptr @RT, align 8, !tbaa !5
  %15 = fdiv double %13, %14
  %16 = fmul double %3, %3
  %17 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %16)
  %18 = getelementptr inbounds [3 x double], ptr @tpx, i64 0, i64 %6
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds [3 x double], ptr @tpy, i64 0, i64 %9
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = fmul double %19, %21
  %23 = fmul double %22, %4
  %24 = fadd double %15, 1.000000e+00
  %25 = fneg double %17
  %26 = fdiv double %25, %14
  %27 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %26)
  %28 = tail call double @llvm.fmuladd.f64(double %27, double 5.000000e-01, double %24)
  %29 = fmul double %23, %28
  ret double %29
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass