; 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.ThreeStruct = type { %struct.SimpleArray2D, %struct.SimpleArray2D, %struct.SimpleArray2D }
%struct.SimpleArray2D = type { ptr, i64, i64 }
%struct.RawResult = type { ptr, ptr, ptr, 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 @rawresult_to_simplearray(ptr dead_on_unwind noalias writable sret(%struct.ThreeStruct) align 8 %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.SimpleArray2D, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.SimpleArray2D, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.SimpleArray2D, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.RawResult, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.RawResult, ptr %12, i32 0, i32 3
  %14 = load i64, ptr %13, align 8, !tbaa !12
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.RawResult, ptr %15, i32 0, i32 4
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = call ptr @copy_u16_to_f64(ptr noundef %11, i64 noundef %14, i64 noundef %17)
  store ptr %18, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 0
  store ptr %19, ptr %20, align 8, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.RawResult, ptr %21, i32 0, i32 3
  %23 = load i64, ptr %22, align 8, !tbaa !12
  %24 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 1
  store i64 %23, ptr %24, align 8, !tbaa !16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.RawResult, ptr %25, i32 0, i32 4
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds %struct.SimpleArray2D, ptr %4, i32 0, i32 2
  store i64 %27, ptr %28, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.RawResult, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.RawResult, ptr %32, i32 0, i32 3
  %34 = load i64, ptr %33, align 8, !tbaa !12
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.RawResult, ptr %35, i32 0, i32 4
  %37 = load i64, ptr %36, align 8, !tbaa !13
  %38 = call ptr @copy_u16_to_f64(ptr noundef %31, i64 noundef %34, i64 noundef %37)
  store ptr %38, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SimpleArray2D, ptr %6, i32 0, i32 0
  store ptr %39, ptr %40, align 8, !tbaa !14
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.RawResult, ptr %41, i32 0, i32 3
  %43 = load i64, ptr %42, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.SimpleArray2D, ptr %6, i32 0, i32 1
  store i64 %43, ptr %44, align 8, !tbaa !16
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.RawResult, ptr %45, i32 0, i32 4
  %47 = load i64, ptr %46, align 8, !tbaa !13
  %48 = getelementptr inbounds %struct.SimpleArray2D, ptr %6, i32 0, i32 2
  store i64 %47, ptr %48, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.RawResult, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  %52 = getelementptr inbounds %struct.SimpleArray2D, ptr %8, i32 0, i32 0
  store ptr %51, ptr %52, align 8, !tbaa !14
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.RawResult, ptr %53, i32 0, i32 3
  %55 = load i64, ptr %54, align 8, !tbaa !12
  %56 = getelementptr inbounds %struct.SimpleArray2D, ptr %8, i32 0, i32 1
  store i64 %55, ptr %56, align 8, !tbaa !16
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.RawResult, ptr %57, i32 0, i32 4
  %59 = load i64, ptr %58, align 8, !tbaa !13
  %60 = getelementptr inbounds %struct.SimpleArray2D, ptr %8, i32 0, i32 2
  store i64 %59, ptr %60, align 8, !tbaa !17
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.RawResult, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  call void @free(ptr noundef %63) #4
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.RawResult, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  call void @free(ptr noundef %66) #4
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.RawResult, ptr %67, i32 0, i32 0
  store ptr null, ptr %68, align 8, !tbaa !9
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.RawResult, ptr %69, i32 0, i32 1
  store ptr null, ptr %70, align 8, !tbaa !18
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.RawResult, ptr %71, i32 0, i32 2
  store ptr null, ptr %72, align 8, !tbaa !19
  %73 = getelementptr inbounds %struct.ThreeStruct, ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %73, ptr align 8 %4, i64 24, i1 false), !tbaa.struct !20
  %74 = getelementptr inbounds %struct.ThreeStruct, ptr %0, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %74, ptr align 8 %6, i64 24, i1 false), !tbaa.struct !20
  %75 = getelementptr inbounds %struct.ThreeStruct, ptr %0, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %75, ptr align 8 %8, i64 24, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, 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, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 24}
!13 = !{!10, !11, i64 32}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!15, !11, i64 8}
!17 = !{!15, !11, i64 16}
!18 = !{!10, !6, i64 8}
!19 = !{!10, !6, i64 16}
!20 = !{i64 0, i64 8, !5, i64 8, i64 8, !21, i64 16, i64 8, !21}
!21 = !{!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.ThreeStruct = type { %struct.SimpleArray2D, %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 @rawresult_to_simplearray(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.ThreeStruct) 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 24
  %5 = load i64, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = tail call ptr @copy_u16_to_f64(ptr noundef %3, i64 noundef %5, i64 noundef %7)
  %9 = load i64, ptr %4, align 8, !tbaa !11
  %10 = load i64, ptr %6, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = tail call ptr @copy_u16_to_f64(ptr noundef %12, i64 noundef %9, i64 noundef %10)
  %14 = load i64, ptr %4, align 8, !tbaa !11
  %15 = load i64, ptr %6, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @free(ptr noundef %18) #3
  %19 = load ptr, ptr %11, align 8, !tbaa !13
  tail call void @free(ptr noundef %19) #3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %1, i8 0, i64 24, i1 false)
  store ptr %8, ptr %0, align 8, !tbaa !15
  %.sroa.46.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %9, ptr %.sroa.46.0..sroa_idx, align 8, !tbaa !16
  %.sroa.57.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %10, ptr %.sroa.57.0..sroa_idx, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %13, ptr %20, align 8, !tbaa !15
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %14, ptr %.sroa.42.0..sroa_idx, align 8, !tbaa !16
  %.sroa.53.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %15, ptr %.sroa.53.0..sroa_idx, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %17, ptr %21, align 8, !tbaa !15
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %14, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !16
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %15, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !16
  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, !10, i64 24, !10, i64 32}
!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 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 16}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !10, i64 0}


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