; LLVM IR from PaulBatchelor/sndkit :: graforge (graforge)

; 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.gf_subpatch = type { ptr, ptr, i32, ptr, %struct.gf_pointerlist }
%struct.gf_pointerlist = type { ptr, ptr, i32 }
%struct.gf_patch = type { ptr, ptr, i32, i32, i32, i32, %struct.gf_pointerlist, %struct.gf_bufferpool, %struct.gf_stack, i32, ptr, i32, ptr, ptr, ptr }
%struct.gf_bufferpool = type { ptr, i32, i32, i32, i32 }
%struct.gf_stack = type { i32, i32, ptr, ptr }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local void @gf_subpatch_restore(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.gf_subpatch, ptr %5, i32 0, i32 0
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.gf_patch, ptr %8, i32 0, i32 0
  store ptr %7, ptr %9, align 8, !tbaa !13
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.gf_subpatch, ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !17
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.gf_patch, ptr %13, i32 0, i32 1
  store ptr %12, ptr %14, align 8, !tbaa !18
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.gf_subpatch, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !19
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.gf_patch, ptr %18, i32 0, i32 2
  store i32 %17, ptr %19, align 8, !tbaa !20
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.gf_patch, ptr %20, i32 0, i32 6
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.gf_subpatch, ptr %22, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %23, i64 24, i1 false), !tbaa.struct !21
  ret void
}

attributes #0 = { nocallback nofree 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" }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16}
!13 = !{!14, !6, i64 0}
!14 = !{!"gf_patch", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32, !15, i64 56, !16, i64 80, !11, i64 104, !6, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!15 = !{!"gf_bufferpool", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!16 = !{!"gf_stack", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!17 = !{!10, !6, i64 8}
!18 = !{!14, !6, i64 8}
!19 = !{!10, !11, i64 16}
!20 = !{!14, !11, i64 16}
!21 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 4, !22}
!22 = !{!11, !11, i64 0}


; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @gf_subpatch_restore(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = load <2 x ptr>, ptr %1, align 8, !tbaa !5
  store <2 x ptr> %3, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %5, ptr %6, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %1, i64 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !17
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16}
!13 = !{!14, !11, i64 16}
!14 = !{!"gf_patch", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32, !15, i64 56, !16, i64 80, !11, i64 104, !6, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!15 = !{!"gf_bufferpool", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!16 = !{!"gf_stack", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!17 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 4, !18}
!18 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass