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

; 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::ALawExpansion" = type <{ ptr, double, double, double, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK4sptk13ALawExpansion3RunEdPd(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
  %9 = alloca double, align 8
  %10 = 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
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %"class.sptk::ALawExpansion", ptr %11, i32 0, i32 4
  %13 = load i8, ptr %12, align 8, !tbaa !11, !range !14, !noundef !15
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %18

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

18:                                               ; preds = %15, %3
  store i1 false, ptr %4, align 1
  br label %50

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = load double, ptr %6, align 8, !tbaa !9
  %21 = call double @llvm.fabs.f64(double %20)
  %22 = getelementptr inbounds %"class.sptk::ALawExpansion", ptr %11, i32 0, i32 1
  %23 = load double, ptr %22, align 8, !tbaa !16
  %24 = fdiv double %21, %23
  store double %24, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %25 = getelementptr inbounds %"class.sptk::ALawExpansion", ptr %11, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !17
  %27 = call double @log(double noundef %26) #5
  %28 = fadd double 1.000000e+00, %27
  store double %28, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %29 = load double, ptr %9, align 8, !tbaa !9
  %30 = load double, ptr %8, align 8, !tbaa !9
  %31 = fmul double %29, %30
  store double %31, ptr %10, align 8, !tbaa !9
  %32 = load double, ptr %9, align 8, !tbaa !9
  %33 = fdiv double 1.000000e+00, %32
  %34 = load double, ptr %8, align 8, !tbaa !9
  %35 = fcmp ole double %33, %34
  br i1 %35, label %36, label %40

36:                                               ; preds = %19
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = fsub double %37, 1.000000e+00
  %39 = call double @exp(double noundef %38) #5
  store double %39, ptr %10, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %36, %19
  %41 = getelementptr inbounds %"class.sptk::ALawExpansion", ptr %11, i32 0, i32 3
  %42 = load double, ptr %41, align 8, !tbaa !18
  %43 = load double, ptr %6, align 8, !tbaa !9
  %44 = call noundef i32 @_ZN4sptk11ExtractSignEd(double noundef %43)
  %45 = sitofp i32 %44 to double
  %46 = fmul double %42, %45
  %47 = load double, ptr %10, align 8, !tbaa !9
  %48 = fmul double %46, %47
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  store double %48, ptr %49, align 8, !tbaa !9
  store i1 true, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %50

50:                                               ; preds = %40, %18
  %51 = load i1, ptr %4, align 1
  ret i1 %51
}

; 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

; Function Attrs: nounwind
declare double @log(double noundef) #3

; Function Attrs: nounwind
declare double @exp(double noundef) #3

declare noundef i32 @_ZN4sptk11ExtractSignEd(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 = { 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 #4 = { "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 = !{!"_ZTSN4sptk13ALawExpansionE", !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 16}
!18 = !{!12, !10, i64 24}


; 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 @_ZNK4sptk13ALawExpansion3RunEdPd(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 %34

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 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = tail call double @log(double noundef %13) #4
  %15 = fadd double %14, 1.000000e+00
  %16 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %9, i64 1
  %17 = insertelement <2 x double> poison, double %15, i64 0
  %18 = insertelement <2 x double> %17, double %11, i64 1
  %19 = fdiv <2 x double> %16, %18
  %20 = extractelement <2 x double> %19, i64 1
  %21 = fmul double %20, %15
  %22 = extractelement <2 x double> %19, i64 0
  %23 = fcmp ugt double %22, %20
  br i1 %23, label %27, label %24

24:                                               ; preds = %8
  %25 = fadd double %21, -1.000000e+00
  %26 = tail call double @exp(double noundef %25) #4
  br label %27

27:                                               ; preds = %24, %8
  %.0 = phi double [ %26, %24 ], [ %21, %8 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = tail call noundef i32 @_ZN4sptk11ExtractSignEd(double noundef %1)
  %31 = sitofp i32 %30 to double
  %32 = fmul double %29, %31
  %33 = fmul double %.0, %32
  store double %33, ptr %2, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %3, %27
  ret i1 %or.cond.not
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #2

declare noundef i32 @_ZN4sptk11ExtractSignEd(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 = { 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 #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 }

!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 = !{!"_ZTSN4sptk13ALawExpansionE", !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 16}
!15 = !{!6, !7, i64 24}
!16 = !{!7, !7, i64 0}


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