; LLVM IR from sp-nitech/SPTK :: src/compression/mu_law_expansion.ll (ZNK4sptk14MuLawExpansion3RunEdPd)

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

%"class.sptk::MuLawExpansion" = type <{ ptr, double, double, double, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK4sptk14MuLawExpansion3RunEdPd(ptr noundef nonnull align 8 dereferenceable(33) %0, double noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %"class.sptk::MuLawExpansion", ptr %9, i32 0, i32 4
  %11 = load i8, ptr %10, align 8, !tbaa !11, !range !14, !noundef !15
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %16

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %3
  store i1 false, ptr %4, align 1
  br label %37

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = call double @llvm.fabs.f64(double %18)
  %20 = getelementptr inbounds %"class.sptk::MuLawExpansion", ptr %9, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !16
  %22 = fdiv double %19, %21
  store double %22, ptr %8, align 8, !tbaa !9
  %23 = getelementptr inbounds %"class.sptk::MuLawExpansion", ptr %9, i32 0, i32 3
  %24 = load double, ptr %23, align 8, !tbaa !17
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = call noundef i32 @_ZN4sptk11ExtractSignEd(double noundef %25)
  %27 = sitofp i32 %26 to double
  %28 = fmul double %24, %27
  %29 = getelementptr inbounds %"class.sptk::MuLawExpansion", ptr %9, i32 0, i32 2
  %30 = load double, ptr %29, align 8, !tbaa !18
  %31 = fadd double 1.000000e+00, %30
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = call double @pow(double noundef %31, double noundef %32) #5
  %34 = fsub double %33, 1.000000e+00
  %35 = fmul double %28, %34
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  store double %35, ptr %36, align 8, !tbaa !9
  store i1 true, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %37

37:                                               ; preds = %17, %16
  %38 = load i1, ptr %4, align 1
  ret i1 %38
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

declare noundef i32 @_ZN4sptk11ExtractSignEd(double noundef) #3

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #4

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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 #4 = { nounwind "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 #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 32}
!12 = !{!"_ZTSN4sptk14MuLawExpansionE", !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !10, i64 8}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !10, i64 16}


; 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 uwtable
define dso_local noundef zeroext i1 @_ZNK4sptk14MuLawExpansion3RunEdPd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(33) %0, double noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load i8, ptr %4, align 8, !tbaa !5, !range !11, !noundef !12
  %6 = trunc nuw i8 %5 to i1
  %7 = icmp ne ptr %2, null
  %or.cond.not = and i1 %7, %6
  br i1 %or.cond.not, label %8, label %24

8:                                                ; preds = %3
  %9 = tail call double @llvm.fabs.f64(double %1)
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !13
  %12 = fdiv double %9, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load double, ptr %13, align 8, !tbaa !14
  %15 = tail call noundef i32 @_ZN4sptk11ExtractSignEd(double noundef %1)
  %16 = sitofp i32 %15 to double
  %17 = fmul double %14, %16
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load double, ptr %18, align 8, !tbaa !15
  %20 = fadd double %19, 1.000000e+00
  %21 = tail call double @pow(double noundef %20, double noundef %12) #4
  %22 = fadd double %21, -1.000000e+00
  %23 = fmul double %17, %22
  store double %23, ptr %2, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %3, %8
  ret i1 %or.cond.not
}

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

declare noundef i32 @_ZN4sptk11ExtractSignEd(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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) }
attributes #2 = { "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 = { mustprogress nofree nounwind willreturn memory(write) "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 #4 = { 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, !10, i64 32}
!6 = !{!"_ZTSN4sptk14MuLawExpansionE", !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !7, i64 16}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass