; LLVM IR from PeterQLee/sentinel1_denoise_rs :: tests (test_clib)

; 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.TwoStruct = type { %struct.SimpleArray2D, %struct.SimpleArray2D }
%struct.SimpleArray2D = type { ptr, i64, i64 }
%struct.LPResult = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64 }

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @copy_u16_to_f64(ptr noundef, i64 noundef, i64 noundef) #1

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

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

; 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) #3

; Function Attrs: nounwind uwtable
define dso_local void @lpresult_to_simplearray(ptr dead_on_unwind noalias writable sret(%struct.TwoStruct) align 8 %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.SimpleArray2D, align 8
  %5 = alloca %struct.SimpleArray2D, align 8
  %6 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.LPResult, ptr %7, i32 0, i32 0
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 0
  store ptr %9, ptr %10, align 8, !tbaa !12
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.LPResult, ptr %11, i32 0, i32 5
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 1
  store i64 %13, ptr %14, align 8, !tbaa !15
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.LPResult, ptr %15, i32 0, i32 6
  %17 = load i64, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 2
  store i64 %17, ptr %18, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.LPResult, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.LPResult, ptr %22, i32 0, i32 5
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.LPResult, ptr %25, i32 0, i32 6
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = call ptr @copy_u16_to_f64(ptr noundef %21, i64 noundef %24, i64 noundef %27)
  store ptr %28, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SimpleArray2D, ptr %5, i32 0, i32 0
  store ptr %29, ptr %30, align 8, !tbaa !12
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.LPResult, ptr %31, i32 0, i32 5
  %33 = load i64, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds %struct.SimpleArray2D, ptr %5, i32 0, i32 1
  store i64 %33, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LPResult, ptr %35, i32 0, i32 6
  %37 = load i64, ptr %36, align 8, !tbaa !16
  %38 = getelementptr inbounds %struct.SimpleArray2D, ptr %5, i32 0, i32 2
  store i64 %37, ptr %38, align 8, !tbaa !17
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LPResult, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  call void @free(ptr noundef %41) #4
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.LPResult, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  call void @free(ptr noundef %44) #4
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.LPResult, ptr %45, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  call void @free(ptr noundef %47) #4
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.LPResult, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  call void @free(ptr noundef %50) #4
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.LPResult, ptr %51, i32 0, i32 0
  store ptr null, ptr %52, align 8, !tbaa !9
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.LPResult, ptr %53, i32 0, i32 1
  store ptr null, ptr %54, align 8, !tbaa !18
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.LPResult, ptr %55, i32 0, i32 2
  store ptr null, ptr %56, align 8, !tbaa !19
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.LPResult, ptr %57, i32 0, i32 3
  store ptr null, ptr %58, align 8, !tbaa !20
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.LPResult, ptr %59, i32 0, i32 4
  store ptr null, ptr %60, align 8, !tbaa !21
  %61 = getelementptr inbounds %struct.TwoStruct, ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 8 %4, i64 24, i1 false), !tbaa.struct !22
  %62 = getelementptr inbounds %struct.TwoStruct, ptr %0, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %62, ptr align 8 %5, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #4
  ret void
}

attributes #0 = { nounwind "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 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 willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16}
!14 = !{!10, !11, i64 40}
!15 = !{!13, !11, i64 8}
!16 = !{!10, !11, i64 48}
!17 = !{!13, !11, i64 16}
!18 = !{!10, !6, i64 8}
!19 = !{!10, !6, i64 16}
!20 = !{!10, !6, i64 24}
!21 = !{!10, !6, i64 32}
!22 = !{i64 0, i64 8, !5, i64 8, i64 8, !23, i64 16, i64 8, !23}
!23 = !{!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"

%struct.TwoStruct = type { %struct.SimpleArray2D, %struct.SimpleArray2D }
%struct.SimpleArray2D = type { ptr, i64, i64 }

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @copy_u16_to_f64(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @lpresult_to_simplearray(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.TwoStruct) align 8 %0, ptr nocapture noundef %1) local_unnamed_addr #1 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = tail call ptr @copy_u16_to_f64(ptr noundef %9, i64 noundef %5, i64 noundef %7)
  %11 = load ptr, ptr %8, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = getelementptr inbounds i8, ptr %1, i64 32
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.53.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 16
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load <2 x i64>, ptr %4, align 8, !tbaa !14
  tail call void @free(ptr noundef %11) #3
  %17 = load ptr, ptr %12, align 8, !tbaa !15
  tail call void @free(ptr noundef %17) #3
  %18 = load ptr, ptr %13, align 8, !tbaa !16
  tail call void @free(ptr noundef %18) #3
  %19 = load ptr, ptr %14, align 8, !tbaa !17
  tail call void @free(ptr noundef %19) #3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %1, i8 0, i64 40, i1 false)
  store ptr %3, ptr %0, align 8, !tbaa !18
  store i64 %5, ptr %.sroa.42.0..sroa_idx, align 8, !tbaa !14
  store i64 %7, ptr %.sroa.53.0..sroa_idx, align 8, !tbaa !14
  store ptr %10, ptr %15, align 8, !tbaa !18
  store <2 x i64> %16, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !14
  ret void
}

; 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 willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 40}
!12 = !{!6, !10, i64 48}
!13 = !{!6, !7, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 24}
!17 = !{!6, !7, i64 32}
!18 = !{!7, !7, i64 0}


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