; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

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

%struct.sig_Allocator = type { ptr, ptr }
%struct.sig_AllocatorImpl = type { ptr, ptr, ptr }
%struct.sig_Buffer = type { i64, ptr }

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sig_BufferView_new(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sig_Allocator, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.sig_AllocatorImpl, ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call ptr %14(ptr noundef %15, i64 noundef 16)
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = icmp ult i64 %17, 0
  br i1 %18, label %27, label %19

19:                                               ; preds = %4
  %20 = load i64, ptr %8, align 8, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sig_Buffer, ptr %21, i32 0, i32 0
  %23 = load i64, ptr %22, align 8, !tbaa !15
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = sub i64 %23, %24
  %26 = icmp ugt i64 %20, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %19, %4
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_Buffer, ptr %28, i32 0, i32 1
  store ptr null, ptr %29, align 8, !tbaa !17
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.sig_Buffer, ptr %30, i32 0, i32 0
  store i64 0, ptr %31, align 8, !tbaa !15
  br label %43

32:                                               ; preds = %19
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.sig_Buffer, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = getelementptr inbounds float, ptr %35, i64 %36
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.sig_Buffer, ptr %38, i32 0, i32 1
  store ptr %37, ptr %39, align 8, !tbaa !17
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.sig_Buffer, ptr %41, i32 0, i32 0
  store i64 %40, ptr %42, align 8, !tbaa !15
  br label %43

43:                                               ; preds = %32, %27
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret ptr %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"sig_Allocator", !6, i64 0, !6, i64 8}
!13 = !{!14, !6, i64 8}
!14 = !{!"sig_AllocatorImpl", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!16, !10, i64 0}
!16 = !{!"sig_Buffer", !10, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}


; 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: nounwind uwtable
define dso_local ptr @sig_BufferView_new(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !10
  %8 = tail call ptr %7(ptr noundef nonnull %0, i64 noundef 16) #1
  %9 = load i64, ptr %1, align 8, !tbaa !12
  %10 = sub i64 %9, %2
  %11 = icmp ult i64 %10, %3
  br i1 %11, label %16, label %12

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds float, ptr %14, i64 %2
  br label %16

16:                                               ; preds = %4, %12
  %.sink = phi ptr [ %15, %12 ], [ null, %4 ]
  %storemerge = phi i64 [ %3, %12 ], [ 0, %4 ]
  %17 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %.sink, ptr %17, align 8
  store i64 %storemerge, ptr %8, align 8, !tbaa !12
  ret ptr %8
}

attributes #0 = { 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 = { 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, !7, i64 0}
!6 = !{!"sig_Allocator", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"sig_AllocatorImpl", !7, i64 0, !7, i64 8, !7, i64 16}
!12 = !{!13, !14, i64 0}
!13 = !{!"sig_Buffer", !14, i64 0, !7, i64 8}
!14 = !{!"long", !8, i64 0}
!15 = !{!13, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass