; LLVM IR from clangen/musikcube :: src/plugins/stockencoders (FfmpegEncoder)

; 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.FfmpegEncoder = type { %"class.musik::core::sdk::IBlockingEncoder", i8, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, %"class.std::__cxx11::basic_string", i32, i32 }
%"class.musik::core::sdk::IBlockingEncoder" = type { %"class.musik::core::sdk::IEncoder" }
%"class.musik::core::sdk::IEncoder" = type { ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder15OpenOutputCodecEmmm(ptr noundef nonnull align 8 dereferenceable(152), i64 noundef, i64 noundef, i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder17OpenOutputContextEv(ptr noundef nonnull align 8 dereferenceable(152)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13FfmpegEncoder10InitializeEPN5musik4core3sdk11IDataStreamEmmm(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  store i64 %4, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %6, align 8
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 2
  store ptr %12, ptr %13, align 8, !tbaa !11
  %14 = call noundef zeroext i1 @_ZN13FfmpegEncoder17OpenOutputContextEv(ptr noundef nonnull align 8 dereferenceable(152) %11)
  br i1 %14, label %15, label %32

15:                                               ; preds = %5
  %16 = load i64, ptr %8, align 8, !tbaa !9
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = load i64, ptr %10, align 8, !tbaa !9
  %19 = call noundef zeroext i1 @_ZN13FfmpegEncoder15OpenOutputCodecEmmm(ptr noundef nonnull align 8 dereferenceable(152) %11, i64 noundef %16, i64 noundef %17, i64 noundef %18)
  br i1 %19, label %20, label %31

20:                                               ; preds = %15
  %21 = call noundef zeroext i1 @_ZN13FfmpegEncoder17WriteOutputHeaderEv(ptr noundef nonnull align 8 dereferenceable(152) %11)
  br i1 %21, label %22, label %30

22:                                               ; preds = %20
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = trunc i64 %23 to i32
  %25 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 15
  store i32 %24, ptr %25, align 8, !tbaa !19
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = trunc i64 %26 to i32
  %28 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 16
  store i32 %27, ptr %28, align 4, !tbaa !20
  %29 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 1
  store i8 1, ptr %29, align 8, !tbaa !21
  br label %30

30:                                               ; preds = %22, %20
  br label %31

31:                                               ; preds = %30, %15
  br label %32

32:                                               ; preds = %31, %5
  %33 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 1
  %34 = load i8, ptr %33, align 8, !tbaa !21, !range !22, !noundef !23
  %35 = trunc i8 %34 to i1
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @_ZN13FfmpegEncoder7CleanupEv(ptr noundef nonnull align 8 dereferenceable(152) %11)
  br label %37

37:                                               ; preds = %36, %32
  %38 = getelementptr inbounds %class.FfmpegEncoder, ptr %11, i32 0, i32 1
  %39 = load i8, ptr %38, align 8, !tbaa !21, !range !22, !noundef !23
  %40 = trunc i8 %39 to i1
  ret i1 %40
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder17WriteOutputHeaderEv(ptr noundef nonnull align 8 dereferenceable(152)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13FfmpegEncoder7CleanupEv(ptr noundef nonnull align 8 dereferenceable(152)) #0 align 2

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS13FfmpegEncoder", !13, i64 0, !15, i64 8, !6, i64 16, !16, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !17, i64 112, !16, i64 144, !16, i64 148}
!13 = !{!"_ZTSN5musik4core3sdk16IBlockingEncoderE", !14, i64 0}
!14 = !{!"_ZTSN5musik4core3sdk8IEncoderE"}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !10, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!12, !16, i64 144}
!20 = !{!12, !16, i64 148}
!21 = !{!12, !15, i64 8}
!22 = !{i8 0, i8 2}
!23 = !{}


; 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
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder15OpenOutputCodecEmmm(ptr noundef nonnull align 8 dereferenceable(152), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder17OpenOutputContextEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13FfmpegEncoder10InitializeEPN5musik4core3sdk11IDataStreamEmmm(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4) unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %6, align 8, !tbaa !5
  %7 = tail call noundef zeroext i1 @_ZN13FfmpegEncoder17OpenOutputContextEv(ptr noundef nonnull align 8 dereferenceable(152) %0)
  br i1 %7, label %8, label %18

8:                                                ; preds = %5
  %9 = tail call noundef zeroext i1 @_ZN13FfmpegEncoder15OpenOutputCodecEmmm(ptr noundef nonnull align 8 dereferenceable(152) %0, i64 noundef %2, i64 noundef %3, i64 noundef %4)
  br i1 %9, label %10, label %18

10:                                               ; preds = %8
  %11 = tail call noundef zeroext i1 @_ZN13FfmpegEncoder17WriteOutputHeaderEv(ptr noundef nonnull align 8 dereferenceable(152) %0)
  br i1 %11, label %12, label %18

12:                                               ; preds = %10
  %13 = trunc i64 %3 to i32
  %14 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %13, ptr %14, align 8, !tbaa !17
  %15 = trunc i64 %2 to i32
  %16 = getelementptr inbounds i8, ptr %0, i64 148
  store i32 %15, ptr %16, align 4, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 1, ptr %17, align 8, !tbaa !19
  br label %18

18:                                               ; preds = %8, %12, %10, %5
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i8, ptr %19, align 8, !tbaa !19, !range !20, !noundef !21
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  tail call void @_ZN13FfmpegEncoder7CleanupEv(ptr noundef nonnull align 8 dereferenceable(152) %0)
  %.pre = load i8, ptr %19, align 8, !tbaa !19, !range !20
  %.pre6 = trunc nuw i8 %.pre to i1
  br label %23

23:                                               ; preds = %22, %18
  %.pre-phi = phi i1 [ %.pre6, %22 ], [ true, %18 ]
  ret i1 %.pre-phi
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13FfmpegEncoder17WriteOutputHeaderEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13FfmpegEncoder7CleanupEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #0 align 2

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

!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, !12, i64 16}
!6 = !{!"_ZTS13FfmpegEncoder", !7, i64 0, !9, i64 8, !12, i64 16, !13, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !14, i64 104, !15, i64 112, !13, i64 144, !13, i64 148}
!7 = !{!"_ZTSN5musik4core3sdk16IBlockingEncoderE", !8, i64 0}
!8 = !{!"_ZTSN5musik4core3sdk8IEncoderE"}
!9 = !{!"bool", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"long", !10, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !14, i64 8, !10, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!17 = !{!6, !13, i64 144}
!18 = !{!6, !13, i64 148}
!19 = !{!6, !9, i64 8}
!20 = !{i8 0, i8 2}
!21 = !{}


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