; LLVM IR from clangen/musikcube :: src/plugins/stockencoders/LameEncoder.ll (ZN11LameEncoder7ReleaseEv)

; 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.LameEncoder = type { %"class.musik::core::sdk::IStreamingEncoder", %struct.DataBuffer, %struct.DataBuffer.0, ptr }
%"class.musik::core::sdk::IStreamingEncoder" = type { %"class.musik::core::sdk::IEncoder" }
%"class.musik::core::sdk::IEncoder" = type { ptr }
%struct.DataBuffer = type { ptr, i64, i64, i64 }
%struct.DataBuffer.0 = type { ptr, i64, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11LameEncoder7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(80) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.LameEncoder, ptr %3, i32 0, i32 3
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = call i32 @lame_close(ptr noundef %5)
  %7 = getelementptr inbounds %class.LameEncoder, ptr %3, i32 0, i32 3
  store ptr null, ptr %7, align 8, !tbaa !9
  %8 = icmp eq ptr %3, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  call void @_ZN11LameEncoderD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #4
  call void @_ZdlPvm(ptr noundef %3, i64 noundef 80) #5
  br label %10

10:                                               ; preds = %9, %1
  ret void
}

declare i32 @lame_close(ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11LameEncoderD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #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 = { "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 #2 = { inlinehint 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 = { nobuiltin 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 = { nounwind }
attributes #5 = { builtin 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, !6, i64 72}
!10 = !{!"_ZTS11LameEncoder", !11, i64 0, !13, i64 8, !15, i64 40, !6, i64 72}
!11 = !{!"_ZTSN5musik4core3sdk17IStreamingEncoderE", !12, i64 0}
!12 = !{!"_ZTSN5musik4core3sdk8IEncoderE"}
!13 = !{!"_ZTS10DataBufferIhE", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS10DataBufferIfE", !6, i64 0, !14, i64 8, !14, i64 16, !14, 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 void @_ZN11LameEncoder7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(80) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call i32 @lame_close(ptr noundef %3)
  store ptr null, ptr %2, align 8, !tbaa !5
  tail call void @_ZN11LameEncoderD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %0, i64 noundef 80) #5
  ret void
}

declare i32 @lame_close(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11LameEncoderD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 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 = { "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 #2 = { inlinehint 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 = { nobuiltin 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 = { nounwind }
attributes #5 = { builtin 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 72}
!6 = !{!"_ZTS11LameEncoder", !7, i64 0, !9, i64 8, !14, i64 40, !10, i64 72}
!7 = !{!"_ZTSN5musik4core3sdk17IStreamingEncoderE", !8, i64 0}
!8 = !{!"_ZTSN5musik4core3sdk8IEncoderE"}
!9 = !{!"_ZTS10DataBufferIhE", !10, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTS10DataBufferIfE", !10, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass