; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/tiny_audio/RtAudio.ll (ZN5RtApiC2Ev)

; 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.RtApi = type <{ ptr, %"class.std::__cxx11::basic_ostringstream", %"class.std::__cxx11::basic_string", i8, [7 x i8], %"struct.RtApi::RtApiStream", i8, [7 x i8] }>
%"class.std::__cxx11::basic_ostringstream" = type { %"class.std::basic_ostream.base", %"class.std::__cxx11::basic_stringbuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"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] }
%"struct.RtApi::RtApiStream" = type { [2 x i32], ptr, i32, i32, [2 x ptr], ptr, [2 x i8], i8, [2 x i8], [2 x i8], i32, i32, i32, [2 x i32], [2 x i32], [2 x i32], [2 x i64], i64, [2 x i64], i32, %struct.CallbackInfo, [2 x %"struct.RtApi::ConvertInfo"], double }
%struct.CallbackInfo = type { ptr, i32, ptr, ptr, ptr, ptr, i8, i8, i32 }
%"struct.RtApi::ConvertInfo" = type { i32, i32, i32, i64, i64, %"class.std::vector.3", %"class.std::vector.3" }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTV5RtApi = external dso_local unnamed_addr constant { [16 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5RtApiC2Ev(ptr noundef nonnull align 8 dereferenceable(793) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 112) ({ [16 x ptr] }, ptr @_ZTV5RtApi, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 1
  call void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(112) %6)
  %7 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 2
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #3
  %8 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  invoke void @_ZN5RtApi11RtApiStreamC2Ev(ptr noundef nonnull align 8 dereferenceable(368) %8)
          to label %9 unwind label %28

9:                                                ; preds = %1
  %10 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %11 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %10, i32 0, i32 3
  store i32 -50, ptr %11, align 4, !tbaa !11
  %12 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %13 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %12, i32 0, i32 2
  store i32 -75, ptr %13, align 8, !tbaa !29
  %14 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %15 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %14, i32 0, i32 1
  store ptr null, ptr %15, align 8, !tbaa !30
  %16 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %17 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %16, i32 0, i32 4
  %18 = getelementptr inbounds [2 x ptr], ptr %17, i64 0, i64 0
  store ptr null, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %20 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %19, i32 0, i32 4
  %21 = getelementptr inbounds [2 x ptr], ptr %20, i64 0, i64 1
  store ptr null, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 5
  %23 = getelementptr inbounds %"struct.RtApi::RtApiStream", ptr %22, i32 0, i32 19
  %24 = load i32, ptr %23, align 8, !tbaa !31
  %25 = call i32 @llvm.abs.i32(i32 %24, i1 true)
  %26 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 3
  store i8 1, ptr %26, align 8, !tbaa !32
  %27 = getelementptr inbounds %class.RtApi, ptr %5, i32 0, i32 6
  store i8 0, ptr %27, align 8, !tbaa !33
  ret void

28:                                               ; preds = %1
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %3, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %4, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #3
  call void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(112) %6) #3
  br label %32

32:                                               ; preds = %28
  %33 = load ptr, ptr %3, align 8
  %34 = load i32, ptr %4, align 4
  %35 = insertvalue { ptr, i32 } poison, ptr %33, 0
  %36 = insertvalue { ptr, i32 } %35, i32 %34, 1
  resume { ptr, i32 } %36
}

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !25, i64 444}
!12 = !{!"_ZTS5RtApi", !13, i64 8, !19, i64 384, !22, i64 416, !23, i64 424, !22, i64 792}
!13 = !{!"_ZTSNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8}
!14 = !{!"_ZTSSo"}
!15 = !{!"_ZTSNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE", !16, i64 0, !18, i64 64, !19, i64 72}
!16 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !17, i64 56}
!17 = !{!"_ZTSSt6locale", !6, i64 0}
!18 = !{!"_ZTSSt13_Ios_Openmode", !7, i64 0}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!"_ZTSN5RtApi11RtApiStreamE", !7, i64 0, !6, i64 8, !24, i64 16, !25, i64 20, !7, i64 24, !6, i64 40, !7, i64 48, !22, i64 50, !7, i64 51, !7, i64 53, !26, i64 56, !26, i64 60, !26, i64 64, !7, i64 68, !7, i64 76, !7, i64 84, !7, i64 96, !21, i64 112, !7, i64 120, !26, i64 136, !27, i64 144, !7, i64 200, !28, i64 360}
!24 = !{!"_ZTSN5RtApi10StreamModeE", !7, i64 0}
!25 = !{!"_ZTSN5RtApi11StreamStateE", !7, i64 0}
!26 = !{!"int", !7, i64 0}
!27 = !{!"_ZTS12CallbackInfo", !6, i64 0, !26, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !22, i64 48, !22, i64 49, !26, i64 52}
!28 = !{!"double", !7, i64 0}
!29 = !{!12, !24, i64 440}
!30 = !{!12, !6, i64 432}
!31 = !{!12, !26, i64 560}
!32 = !{!12, !22, i64 416}
!33 = !{!12, !22, i64 792}


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

@_ZTV5RtApi = external dso_local unnamed_addr constant { [16 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5RtApiC2Ev(ptr noundef nonnull align 8 dereferenceable(793) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 112) (i8, ptr @_ZTV5RtApi, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev(ptr noundef nonnull align 8 dereferenceable(112) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 384
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 424
  invoke void @_ZN5RtApi11RtApiStreamC2Ev(ptr noundef nonnull align 8 dereferenceable(368) %4)
          to label %5 unwind label %12

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 444
  store i32 -50, ptr %6, align 4, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 440
  store i32 -75, ptr %7, align 8, !tbaa !28
  %8 = getelementptr inbounds i8, ptr %0, i64 432
  store ptr null, ptr %8, align 8, !tbaa !29
  %9 = getelementptr inbounds i8, ptr %0, i64 448
  %10 = getelementptr inbounds i8, ptr %0, i64 416
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  store i8 1, ptr %10, align 8, !tbaa !30
  %11 = getelementptr inbounds i8, ptr %0, i64 792
  store i8 0, ptr %11, align 8, !tbaa !31
  ret void

12:                                               ; preds = %1
  %13 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #3
  tail call void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(112) %2) #3
  resume { ptr, i32 } %13
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #0 align 2

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

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !24, i64 444}
!9 = !{!"_ZTS5RtApi", !10, i64 8, !18, i64 384, !21, i64 416, !22, i64 424, !21, i64 792}
!10 = !{!"_ZTSNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE", !11, i64 0, !12, i64 8}
!11 = !{!"_ZTSSo"}
!12 = !{!"_ZTSNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE", !13, i64 0, !17, i64 64, !18, i64 72}
!13 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !16, i64 56}
!14 = !{!"any pointer", !15, i64 0}
!15 = !{!"omnipotent char", !7, i64 0}
!16 = !{!"_ZTSSt6locale", !14, i64 0}
!17 = !{!"_ZTSSt13_Ios_Openmode", !15, i64 0}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !19, i64 0, !20, i64 8, !15, i64 16}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!20 = !{!"long", !15, i64 0}
!21 = !{!"bool", !15, i64 0}
!22 = !{!"_ZTSN5RtApi11RtApiStreamE", !15, i64 0, !14, i64 8, !23, i64 16, !24, i64 20, !15, i64 24, !14, i64 40, !15, i64 48, !21, i64 50, !15, i64 51, !15, i64 53, !25, i64 56, !25, i64 60, !25, i64 64, !15, i64 68, !15, i64 76, !15, i64 84, !15, i64 96, !20, i64 112, !15, i64 120, !25, i64 136, !26, i64 144, !15, i64 200, !27, i64 360}
!23 = !{!"_ZTSN5RtApi10StreamModeE", !15, i64 0}
!24 = !{!"_ZTSN5RtApi11StreamStateE", !15, i64 0}
!25 = !{!"int", !15, i64 0}
!26 = !{!"_ZTS12CallbackInfo", !14, i64 0, !25, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !21, i64 48, !21, i64 49, !25, i64 52}
!27 = !{!"double", !15, i64 0}
!28 = !{!9, !23, i64 440}
!29 = !{!9, !14, i64 432}
!30 = !{!9, !21, i64 416}
!31 = !{!9, !21, i64 792}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass