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

; 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_wedgdi(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 6
  %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 7
  %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 8
  %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 9
  %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 10
  %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 %3, align 8, !tbaa !5
  %42 = fmul double %40, %41
  %43 = load double, ptr %6, align 8, !tbaa !5
  %44 = load double, ptr %3, align 8, !tbaa !5
  %45 = load double, ptr %5, align 8, !tbaa !5
  %46 = call double @llvm.fmuladd.f64(double %43, double %44, double %45)
  %47 = fmul double %42, %46
  %48 = load double, ptr %3, align 8, !tbaa !5
  %49 = load double, ptr %3, align 8, !tbaa !5
  %50 = fmul double %48, %49
  %51 = load double, ptr %3, align 8, !tbaa !5
  %52 = load double, ptr %9, align 8, !tbaa !5
  %53 = load double, ptr %3, align 8, !tbaa !5
  %54 = fmul double %52, %53
  %55 = load double, ptr %3, align 8, !tbaa !5
  %56 = fmul double %54, %55
  %57 = call double @llvm.fmuladd.f64(double %50, double %51, double %56)
  %58 = load double, ptr %8, align 8, !tbaa !5
  %59 = load double, ptr %3, align 8, !tbaa !5
  %60 = call double @llvm.fmuladd.f64(double %58, double %59, double %57)
  %61 = load double, ptr %7, align 8, !tbaa !5
  %62 = fadd double %60, %61
  %63 = fdiv double %47, %62
  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 %63
}

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_wedgdi(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 48
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 56
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 64
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %5, i64 72
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %5, i64 80
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = load double, ptr @brag, align 8, !tbaa !5
  %17 = fmul double %16, %0
  %18 = tail call double @llvm.fmuladd.f64(double %9, double %0, double %7)
  %19 = fmul double %18, %17
  %20 = fmul double %0, %0
  %21 = fmul double %15, %0
  %22 = fmul double %21, %0
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %0, double %22)
  %24 = tail call double @llvm.fmuladd.f64(double %13, double %0, double %23)
  %25 = fadd double %11, %24
  %26 = fdiv double %19, %25
  ret double %26
}

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