; LLVM IR from chromia/lichtenberg :: src/util/noise.ll (ZN11lichtenberg4util6smoothEii)

; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11lichtenberg4util4randEii(i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN11lichtenberg4util6smoothEii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sub nsw i32 %8, 1
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = sub nsw i32 %10, 1
  %12 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %9, i32 noundef %11)
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sub nsw i32 %15, 1
  %17 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %14, i32 noundef %16)
  %18 = fadd double %12, %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %20, i32 noundef %22)
  %24 = fadd double %18, %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  %29 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %26, i32 noundef %28)
  %30 = fadd double %24, %29
  %31 = fdiv double %30, 1.600000e+01
  store double %31, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %33, i32 noundef %34)
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %37, i32 noundef %38)
  %40 = fadd double %35, %39
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sub nsw i32 %42, 1
  %44 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %41, i32 noundef %43)
  %45 = fadd double %40, %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  %49 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %46, i32 noundef %48)
  %50 = fadd double %45, %49
  %51 = fdiv double %50, 8.000000e+00
  store double %51, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %52, i32 noundef %53)
  %55 = fdiv double %54, 4.000000e+00
  store double %55, ptr %7, align 8, !tbaa !9
  %56 = load double, ptr %5, align 8, !tbaa !9
  %57 = load double, ptr %6, align 8, !tbaa !9
  %58 = fadd double %56, %57
  %59 = load double, ptr %7, align 8, !tbaa !9
  %60 = fadd double %58, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret double %60
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN11lichtenberg4util4randEii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN11lichtenberg4util6smoothEii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = add nsw i32 %0, -1
  %4 = add nsw i32 %1, -1
  %5 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %3, i32 noundef %4)
  %6 = add nsw i32 %0, 1
  %7 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %6, i32 noundef %4)
  %8 = add nsw i32 %1, 1
  %9 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %3, i32 noundef %8)
  %10 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %6, i32 noundef %8)
  %11 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %3, i32 noundef %1)
  %12 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %6, i32 noundef %1)
  %13 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %0, i32 noundef %4)
  %14 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %0, i32 noundef %8)
  %15 = insertelement <2 x double> poison, double %5, i64 0
  %16 = insertelement <2 x double> %15, double %11, i64 1
  %17 = insertelement <2 x double> poison, double %7, i64 0
  %18 = insertelement <2 x double> %17, double %12, i64 1
  %19 = fadd <2 x double> %16, %18
  %20 = insertelement <2 x double> poison, double %9, i64 0
  %21 = insertelement <2 x double> %20, double %13, i64 1
  %22 = fadd <2 x double> %19, %21
  %23 = insertelement <2 x double> poison, double %10, i64 0
  %24 = insertelement <2 x double> %23, double %14, i64 1
  %25 = fadd <2 x double> %22, %24
  %26 = fmul <2 x double> %25, <double 6.250000e-02, double 1.250000e-01>
  %27 = tail call noundef double @_ZN11lichtenberg4util4randEii(i32 noundef %0, i32 noundef %1)
  %28 = fmul double %27, 2.500000e-01
  %shift = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %29 = fadd <2 x double> %26, %shift
  %30 = extractelement <2 x double> %29, i64 0
  %31 = fadd double %28, %30
  ret double %31
}

attributes #0 = { 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" }

!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)"}


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