; LLVM IR from henrywatkins/PARAMAGNET :: src/TransportCoeff.ll (Z10alpha_perpdi)

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

@alphavalues = external dso_local constant [8 x [10 x double]], align 16
@brag = external constant 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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"

@alphavalues = external dso_local local_unnamed_addr constant [8 x [10 x double]], align 16
@brag = external local_unnamed_addr constant double, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef double @_Z10alpha_perpdi(double noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = add nsw i32 %1, -1
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [8 x [10 x double]], ptr @alphavalues, i64 0, i64 %4
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 16
  %9 = load double, ptr %8, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %5, i64 32
  %13 = load double, ptr %12, align 16, !tbaa !5
  %14 = tail call double @llvm.fmuladd.f64(double %9, double %0, double %7)
  %15 = fmul double %13, %0
  %16 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %15)
  %17 = fadd double %11, %16
  %18 = fdiv double %14, %17
  %19 = fsub double 1.000000e+00, %18
  %20 = load double, ptr @brag, align 8, !tbaa !5
  %21 = fdiv double %19, %20
  ret double %21
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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" }
attributes #1 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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