; 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.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] }
%"class.std::allocator.0" = type { i8 }
%struct.AVPacket = type { ptr, i64, i64, ptr, i32, i32, i32, ptr, i32, i64, i64, ptr, ptr, %struct.AVRational }
%struct.AVRational = type { i32, i32 }
%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 }
%struct.AVFrame = type { [8 x ptr], [8 x i32], ptr, i32, i32, i32, i32, i32, i32, %struct.AVRational, i64, i64, %struct.AVRational, i32, ptr, i32, i32, i32, i32, i32, [8 x ptr], ptr, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i64, i64, ptr, i32, i32, ptr, ptr, i64, i64, i64, i64, ptr, %struct.AVChannelLayout, i64 }
%struct.AVChannelLayout = type { i32, i32, %union.anon.6, ptr }
%union.anon.6 = type { i64 }

@.str.32 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [23 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN13FfmpegEncoder24SendReceiveAndWriteFrameEP7AVFrame(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.std::__cxx11::basic_string", align 8
  %7 = alloca %"class.std::allocator.0", align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.AVPacket, align 8
  %11 = alloca %"class.std::__cxx11::basic_string", align 8
  %12 = alloca %"class.std::allocator.0", align 1
  %13 = alloca %"class.std::__cxx11::basic_string", align 8
  %14 = alloca %"class.std::allocator.0", align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %30

18:                                               ; preds = %2
  %19 = getelementptr inbounds %class.FfmpegEncoder, ptr %15, i32 0, i32 13
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.AVFrame, ptr %21, i32 0, i32 10
  store i64 %20, ptr %22, align 8, !tbaa !18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.AVFrame, ptr %23, i32 0, i32 5
  %25 = load i32, ptr %24, align 8, !tbaa !29
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %class.FfmpegEncoder, ptr %15, i32 0, i32 13
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = add nsw i64 %28, %26
  store i64 %29, ptr %27, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %18, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %31 = getelementptr inbounds %class.FfmpegEncoder, ptr %15, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !30
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @avcodec_send_frame(ptr noundef %32, ptr noundef %33)
  store i32 %34, ptr %5, align 4, !tbaa !31
  %35 = load i32, ptr %5, align 4, !tbaa !31
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %50

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef @.str.32, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %38 unwind label %41

38:                                               ; preds = %37
  %39 = load i32, ptr %5, align 4, !tbaa !31
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %39)
          to label %40 unwind label %45

40:                                               ; preds = %38
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  br label %106

41:                                               ; preds = %37
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %8, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %9, align 4
  br label %49

45:                                               ; preds = %38
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %8, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %9, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  br label %49

49:                                               ; preds = %45, %41
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  br label %108

50:                                               ; preds = %30
  store i32 0, ptr %5, align 4, !tbaa !31
  br label %51

51:                                               ; preds = %103, %50
  %52 = load i32, ptr %5, align 4, !tbaa !31
  %53 = icmp sge i32 %52, 0
  br i1 %53, label %54, label %105

54:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 104, ptr %10) #5
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 104, i1 false)
  %55 = getelementptr inbounds %struct.AVPacket, ptr %10, i32 0, i32 1
  store i64 -9223372036854775808, ptr %55, align 8, !tbaa !32
  %56 = getelementptr inbounds %struct.AVPacket, ptr %10, i32 0, i32 2
  store i64 -9223372036854775808, ptr %56, align 8, !tbaa !34
  %57 = getelementptr inbounds %struct.AVPacket, ptr %10, i32 0, i32 10
  store i64 -1, ptr %57, align 8, !tbaa !35
  %58 = getelementptr inbounds %class.FfmpegEncoder, ptr %15, i32 0, i32 6
  %59 = load ptr, ptr %58, align 8, !tbaa !30
  %60 = call i32 @avcodec_receive_packet(ptr noundef %59, ptr noundef %10)
  store i32 %60, ptr %5, align 4, !tbaa !31
  %61 = load i32, ptr %5, align 4, !tbaa !31
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %83

63:                                               ; preds = %54
  %64 = getelementptr inbounds %class.FfmpegEncoder, ptr %15, i32 0, i32 7
  %65 = load ptr, ptr %64, align 8, !tbaa !36
  %66 = call i32 @av_write_frame(ptr noundef %65, ptr noundef %10)
  store i32 %66, ptr %5, align 4, !tbaa !31
  %67 = load i32, ptr %5, align 4, !tbaa !31
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %69, label %82

69:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %11, ptr noundef @.str.33, ptr noundef nonnull align 1 dereferenceable(1) %12)
          to label %70 unwind label %73

70:                                               ; preds = %69
  %71 = load i32, ptr %5, align 4, !tbaa !31
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %11, i32 noundef %71)
          to label %72 unwind label %77

72:                                               ; preds = %70
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #5
  br label %82

73:                                               ; preds = %69
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %8, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %9, align 4
  br label %81

77:                                               ; preds = %70
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %8, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %9, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #5
  br label %81

81:                                               ; preds = %77, %73
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #5
  br label %104

82:                                               ; preds = %72, %63
  br label %103

83:                                               ; preds = %54
  %84 = load i32, ptr %5, align 4, !tbaa !31
  %85 = icmp slt i32 %84, 0
  br i1 %85, label %86, label %102

86:                                               ; preds = %83
  %87 = load i32, ptr %5, align 4, !tbaa !31
  %88 = icmp ne i32 %87, -11
  br i1 %88, label %89, label %102

89:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef @.str.34, ptr noundef nonnull align 1 dereferenceable(1) %14)
          to label %90 unwind label %93

90:                                               ; preds = %89
  %91 = load i32, ptr %5, align 4, !tbaa !31
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %13, i32 noundef %91)
          to label %92 unwind label %97

92:                                               ; preds = %90
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  br label %102

93:                                               ; preds = %89
  %94 = landingpad { ptr, i32 }
          cleanup
  %95 = extractvalue { ptr, i32 } %94, 0
  store ptr %95, ptr %8, align 8
  %96 = extractvalue { ptr, i32 } %94, 1
  store i32 %96, ptr %9, align 4
  br label %101

97:                                               ; preds = %90
  %98 = landingpad { ptr, i32 }
          cleanup
  %99 = extractvalue { ptr, i32 } %98, 0
  store ptr %99, ptr %8, align 8
  %100 = extractvalue { ptr, i32 } %98, 1
  store i32 %100, ptr %9, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #5
  br label %101

101:                                              ; preds = %97, %93
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  br label %104

102:                                              ; preds = %92, %86, %83
  br label %103

103:                                              ; preds = %102, %82
  call void @av_packet_unref(ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 104, ptr %10) #5
  br label %51, !llvm.loop !37

104:                                              ; preds = %101, %81
  call void @llvm.lifetime.end.p0(i64 104, ptr %10) #5
  br label %108

105:                                              ; preds = %51
  br label %106

106:                                              ; preds = %105, %40
  %107 = load i32, ptr %5, align 4, !tbaa !31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 %107

108:                                              ; preds = %104, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %109

109:                                              ; preds = %108
  %110 = load ptr, ptr %8, align 8
  %111 = load i32, ptr %9, align 4
  %112 = insertvalue { ptr, i32 } poison, ptr %110, 0
  %113 = insertvalue { ptr, i32 } %112, i32 %111, 1
  resume { ptr, i32 } %113
}

declare i32 @avcodec_send_frame(ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i32 @avcodec_receive_packet(ptr noundef, ptr noundef) #3

declare i32 @av_write_frame(ptr noundef, ptr noundef) #3

declare void @av_packet_unref(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !15, i64 104}
!10 = !{!"_ZTS13FfmpegEncoder", !11, i64 0, !13, i64 8, !6, i64 16, !14, 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, !15, i64 104, !16, i64 112, !14, i64 144, !14, i64 148}
!11 = !{!"_ZTSN5musik4core3sdk16IBlockingEncoderE", !12, i64 0}
!12 = !{!"_ZTSN5musik4core3sdk8IEncoderE"}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !15, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!19, !15, i64 136}
!19 = !{!"_ZTS7AVFrame", !7, i64 0, !7, i64 64, !6, i64 96, !14, i64 104, !14, i64 108, !14, i64 112, !14, i64 116, !14, i64 120, !20, i64 124, !21, i64 128, !15, i64 136, !15, i64 144, !21, i64 152, !14, i64 160, !6, i64 168, !14, i64 176, !14, i64 180, !14, i64 184, !14, i64 188, !14, i64 192, !7, i64 200, !6, i64 264, !14, i64 272, !6, i64 280, !14, i64 288, !14, i64 292, !22, i64 296, !23, i64 300, !24, i64 304, !25, i64 308, !26, i64 312, !15, i64 320, !15, i64 328, !6, i64 336, !14, i64 344, !14, i64 348, !6, i64 352, !6, i64 360, !15, i64 368, !15, i64 376, !15, i64 384, !15, i64 392, !6, i64 400, !27, i64 408, !15, i64 432}
!20 = !{!"_ZTS13AVPictureType", !7, i64 0}
!21 = !{!"_ZTS10AVRational", !14, i64 0, !14, i64 4}
!22 = !{!"_ZTS12AVColorRange", !7, i64 0}
!23 = !{!"_ZTS16AVColorPrimaries", !7, i64 0}
!24 = !{!"_ZTS29AVColorTransferCharacteristic", !7, i64 0}
!25 = !{!"_ZTS12AVColorSpace", !7, i64 0}
!26 = !{!"_ZTS16AVChromaLocation", !7, i64 0}
!27 = !{!"_ZTS15AVChannelLayout", !28, i64 0, !14, i64 4, !7, i64 8, !6, i64 16}
!28 = !{!"_ZTS14AVChannelOrder", !7, i64 0}
!29 = !{!19, !14, i64 112}
!30 = !{!10, !6, i64 48}
!31 = !{!14, !14, i64 0}
!32 = !{!33, !15, i64 8}
!33 = !{!"_ZTS8AVPacket", !6, i64 0, !15, i64 8, !15, i64 16, !6, i64 24, !14, i64 32, !14, i64 36, !14, i64 40, !6, i64 48, !14, i64 56, !15, i64 64, !15, i64 72, !6, i64 80, !6, i64 88, !21, i64 96}
!34 = !{!33, !15, i64 16}
!35 = !{!33, !15, i64 72}
!36 = !{!10, !6, i64 56}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


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

%"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] }
%"class.std::allocator.0" = type { i8 }
%struct.AVPacket = type { ptr, i64, i64, ptr, i32, i32, i32, ptr, i32, i64, i64, ptr, ptr, %struct.AVRational }
%struct.AVRational = type { i32, i32 }

@.str.32 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [23 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -2147483648, 0) i32 @_ZN13FfmpegEncoder24SendReceiveAndWriteFrameEP7AVFrame(ptr nocapture noundef nonnull align 8 dereferenceable(152) %0, ptr noundef %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = alloca %"class.std::allocator.0", align 1
  %5 = alloca %struct.AVPacket, align 8
  %6 = alloca %"class.std::__cxx11::basic_string", align 8
  %7 = alloca %"class.std::allocator.0", align 1
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca %"class.std::allocator.0", align 1
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %18, label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds i8, ptr %0, i64 104
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 136
  store i64 %12, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %1, i64 112
  %15 = load i32, ptr %14, align 8, !tbaa !28
  %16 = sext i32 %15 to i64
  %17 = add nsw i64 %12, %16
  store i64 %17, ptr %11, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %10, %2
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  %20 = load ptr, ptr %19, align 8, !tbaa !29
  %21 = tail call i32 @avcodec_send_frame(ptr noundef %20, ptr noundef %1)
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %30, label %.preheader

.preheader:                                       ; preds = %18
  %23 = getelementptr inbounds i8, ptr %5, i64 8
  %24 = getelementptr inbounds i8, ptr %5, i64 16
  %25 = getelementptr inbounds i8, ptr %5, i64 72
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %5, i8 0, i64 104, i1 false)
  store i64 -9223372036854775808, ptr %23, align 8, !tbaa !30
  store i64 -9223372036854775808, ptr %24, align 8, !tbaa !32
  store i64 -1, ptr %25, align 8, !tbaa !33
  %27 = load ptr, ptr %19, align 8, !tbaa !29
  %28 = call i32 @avcodec_receive_packet(ptr noundef %27, ptr noundef nonnull %5)
  %29 = icmp sgt i32 %28, -1
  br i1 %29, label %.lr.ph, label %._crit_edge

30:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull @.str.32, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %31 unwind label %33

31:                                               ; preds = %30
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %3, i32 noundef %21)
          to label %32 unwind label %35

32:                                               ; preds = %31
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  br label %.loopexit

33:                                               ; preds = %30
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %37

35:                                               ; preds = %31
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  br label %37

37:                                               ; preds = %35, %33
  %.pn35 = phi { ptr, i32 } [ %36, %35 ], [ %34, %33 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  br label %62

.lr.ph:                                           ; preds = %.preheader, %57
  %38 = load ptr, ptr %26, align 8, !tbaa !34
  %39 = call i32 @av_write_frame(ptr noundef %38, ptr noundef nonnull %5)
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %57

41:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull @.str.33, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %42 unwind label %44

42:                                               ; preds = %41
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %6, i32 noundef %39)
          to label %43 unwind label %46

43:                                               ; preds = %42
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #5
  br label %.loopexit.loopexit

44:                                               ; preds = %41
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %48

46:                                               ; preds = %42
  %47 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #5
  br label %48

48:                                               ; preds = %46, %44
  %.pn32 = phi { ptr, i32 } [ %47, %46 ], [ %45, %44 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #5
  br label %61

._crit_edge:                                      ; preds = %57, %.preheader
  %.lcssa = phi i32 [ %28, %.preheader ], [ %59, %57 ]
  %.not30 = icmp eq i32 %.lcssa, -11
  br i1 %.not30, label %.loopexit.loopexit, label %49

49:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull @.str.34, ptr noundef nonnull align 1 dereferenceable(1) %9)
          to label %50 unwind label %52

50:                                               ; preds = %49
  invoke void @_ZL10logAvErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef %.lcssa)
          to label %51 unwind label %54

51:                                               ; preds = %50
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  br label %.loopexit.loopexit

52:                                               ; preds = %49
  %53 = landingpad { ptr, i32 }
          cleanup
  br label %56

54:                                               ; preds = %50
  %55 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #5
  br label %56

56:                                               ; preds = %54, %52
  %.pn = phi { ptr, i32 } [ %55, %54 ], [ %53, %52 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  br label %61

57:                                               ; preds = %.lr.ph
  call void @av_packet_unref(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %5, i8 0, i64 104, i1 false)
  store i64 -9223372036854775808, ptr %23, align 8, !tbaa !30
  store i64 -9223372036854775808, ptr %24, align 8, !tbaa !32
  store i64 -1, ptr %25, align 8, !tbaa !33
  %58 = load ptr, ptr %19, align 8, !tbaa !29
  %59 = call i32 @avcodec_receive_packet(ptr noundef %58, ptr noundef nonnull %5)
  %60 = icmp sgt i32 %59, -1
  br i1 %60, label %.lr.ph, label %._crit_edge, !llvm.loop !35

61:                                               ; preds = %56, %48
  %.pn32.pn = phi { ptr, i32 } [ %.pn32, %48 ], [ %.pn, %56 ]
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #5
  br label %62

.loopexit.loopexit:                               ; preds = %43, %51, %._crit_edge
  %.123.ph = phi i32 [ -11, %._crit_edge ], [ %.lcssa, %51 ], [ %39, %43 ]
  call void @av_packet_unref(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %5) #5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %32
  %.224 = phi i32 [ %21, %32 ], [ %.123.ph, %.loopexit.loopexit ]
  ret i32 %.224

62:                                               ; preds = %61, %37
  %.pn35.pn = phi { ptr, i32 } [ %.pn35, %37 ], [ %.pn32.pn, %61 ]
  resume { ptr, i32 } %.pn35.pn
}

declare i32 @avcodec_send_frame(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i32 @avcodec_receive_packet(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @av_write_frame(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @av_packet_unref(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !14, i64 104}
!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 = !{!18, !14, i64 136}
!18 = !{!"_ZTS7AVFrame", !10, i64 0, !10, i64 64, !12, i64 96, !13, i64 104, !13, i64 108, !13, i64 112, !13, i64 116, !13, i64 120, !19, i64 124, !20, i64 128, !14, i64 136, !14, i64 144, !20, i64 152, !13, i64 160, !12, i64 168, !13, i64 176, !13, i64 180, !13, i64 184, !13, i64 188, !13, i64 192, !10, i64 200, !12, i64 264, !13, i64 272, !12, i64 280, !13, i64 288, !13, i64 292, !21, i64 296, !22, i64 300, !23, i64 304, !24, i64 308, !25, i64 312, !14, i64 320, !14, i64 328, !12, i64 336, !13, i64 344, !13, i64 348, !12, i64 352, !12, i64 360, !14, i64 368, !14, i64 376, !14, i64 384, !14, i64 392, !12, i64 400, !26, i64 408, !14, i64 432}
!19 = !{!"_ZTS13AVPictureType", !10, i64 0}
!20 = !{!"_ZTS10AVRational", !13, i64 0, !13, i64 4}
!21 = !{!"_ZTS12AVColorRange", !10, i64 0}
!22 = !{!"_ZTS16AVColorPrimaries", !10, i64 0}
!23 = !{!"_ZTS29AVColorTransferCharacteristic", !10, i64 0}
!24 = !{!"_ZTS12AVColorSpace", !10, i64 0}
!25 = !{!"_ZTS16AVChromaLocation", !10, i64 0}
!26 = !{!"_ZTS15AVChannelLayout", !27, i64 0, !13, i64 4, !10, i64 8, !12, i64 16}
!27 = !{!"_ZTS14AVChannelOrder", !10, i64 0}
!28 = !{!18, !13, i64 112}
!29 = !{!6, !12, i64 48}
!30 = !{!31, !14, i64 8}
!31 = !{!"_ZTS8AVPacket", !12, i64 0, !14, i64 8, !14, i64 16, !12, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !12, i64 48, !13, i64 56, !14, i64 64, !14, i64 72, !12, i64 80, !12, i64 88, !20, i64 96}
!32 = !{!31, !14, i64 16}
!33 = !{!31, !14, i64 72}
!34 = !{!6, !12, i64 56}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass