; LLVM IR from henrywatkins/PARAMAGNET :: src/TransportCoeff.ll (Z10kappa_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"

@kappavalues = external dso_local constant [8 x [11 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z10kappa_perpdi(double noundef %0, i32 noundef %1) #2 {
  %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
  %9 = 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
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = sub nsw i32 %10, 1
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, i64 0, i64 %12
  %14 = getelementptr inbounds [11 x double], ptr %13, i64 0, i64 1
  %15 = load double, ptr %14, align 8, !tbaa !5
  store double %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sub nsw i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, i64 0, i64 %18
  %20 = getelementptr inbounds [11 x double], ptr %19, i64 0, i64 2
  %21 = load double, ptr %20, align 8, !tbaa !5
  store double %21, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, i64 0, i64 %24
  %26 = getelementptr inbounds [11 x double], ptr %25, i64 0, i64 3
  %27 = load double, ptr %26, align 8, !tbaa !5
  store double %27, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, i64 0, i64 %30
  %32 = getelementptr inbounds [11 x double], ptr %31, i64 0, i64 4
  %33 = load double, ptr %32, align 8, !tbaa !5
  store double %33, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, i64 0, i64 %36
  %38 = getelementptr inbounds [11 x double], ptr %37, i64 0, i64 5
  %39 = load double, ptr %38, align 8, !tbaa !5
  store double %39, ptr %9, align 8, !tbaa !5
  %40 = load double, ptr @brag, align 8, !tbaa !5
  %41 = load double, ptr %6, align 8, !tbaa !5
  %42 = load double, ptr %3, align 8, !tbaa !5
  %43 = load double, ptr %5, align 8, !tbaa !5
  %44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
  %45 = fmul double %40, %44
  %46 = load double, ptr %3, align 8, !tbaa !5
  %47 = load double, ptr %3, align 8, !tbaa !5
  %48 = fmul double %46, %47
  %49 = load double, ptr %3, align 8, !tbaa !5
  %50 = load double, ptr %9, align 8, !tbaa !5
  %51 = load double, ptr %3, align 8, !tbaa !5
  %52 = fmul double %50, %51
  %53 = load double, ptr %3, align 8, !tbaa !5
  %54 = fmul double %52, %53
  %55 = call double @llvm.fmuladd.f64(double %48, double %49, double %54)
  %56 = load double, ptr %8, align 8, !tbaa !5
  %57 = load double, ptr %3, align 8, !tbaa !5
  %58 = call double @llvm.fmuladd.f64(double %56, double %57, double %55)
  %59 = load double, ptr %7, align 8, !tbaa !5
  %60 = fadd double %58, %59
  %61 = fdiv double %45, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  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 %61
}

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

@kappavalues = external dso_local local_unnamed_addr constant [8 x [11 x double]], align 16
@brag = external local_unnamed_addr constant 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(none) uwtable
define dso_local noundef double @_Z10kappa_perpdi(double noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = add nsw i32 %1, -1
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [8 x [11 x double]], ptr @kappavalues, 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 8, !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 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %5, i64 40
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = load double, ptr @brag, align 8, !tbaa !5
  %17 = tail call double @llvm.fmuladd.f64(double %9, double %0, double %7)
  %18 = fmul double %17, %16
  %19 = fmul double %0, %0
  %20 = fmul double %15, %0
  %21 = fmul double %20, %0
  %22 = tail call double @llvm.fmuladd.f64(double %19, double %0, double %21)
  %23 = tail call double @llvm.fmuladd.f64(double %13, double %0, double %22)
  %24 = fadd double %11, %23
  %25 = fdiv double %18, %24
  ret double %25
}

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

!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