; LLVM IR from ljm941004/HYPERCV_PUBLIC :: modules/process/src/c_src (dwt)

; 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.waveletBase = type { i32, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@WAVEdb3 = external hidden global %struct.waveletBase, align 8
@WAVEbior3_7 = external hidden global %struct.waveletBase, align 8

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; 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 @set_wavelet_base(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp ne i32 %4, 1
  br i1 %5, label %9, label %6

6:                                                ; preds = %1
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp ne i32 %7, 2
  br i1 %8, label %9, label %10

9:                                                ; preds = %6, %1
  br label %14

10:                                               ; preds = %6
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #5
  unreachable

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %15 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 40) #7
  store ptr %15, ptr %3, align 8, !tbaa !9
  %16 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %16, label %65 [
    i32 1, label %17
    i32 2, label %41
  ]

17:                                               ; preds = %14
  %18 = load i32, ptr @WAVEdb3, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.waveletBase, ptr %19, i32 0, i32 0
  store i32 %18, ptr %20, align 8, !tbaa !11
  %21 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEdb3, i32 0, i32 1), align 8, !tbaa !13
  %22 = load i32, ptr @WAVEdb3, align 8, !tbaa !11
  %23 = call ptr @SerialReverse(ptr noundef %21, i32 noundef %22)
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.waveletBase, ptr %24, i32 0, i32 1
  store ptr %23, ptr %25, align 8, !tbaa !13
  %26 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEdb3, i32 0, i32 2), align 8, !tbaa !14
  %27 = load i32, ptr @WAVEdb3, align 8, !tbaa !11
  %28 = call ptr @SerialReverse(ptr noundef %26, i32 noundef %27)
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.waveletBase, ptr %29, i32 0, i32 2
  store ptr %28, ptr %30, align 8, !tbaa !14
  %31 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEdb3, i32 0, i32 3), align 8, !tbaa !15
  %32 = load i32, ptr @WAVEdb3, align 8, !tbaa !11
  %33 = call ptr @SerialReverse(ptr noundef %31, i32 noundef %32)
  %34 = load ptr, ptr %3, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.waveletBase, ptr %34, i32 0, i32 3
  store ptr %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEdb3, i32 0, i32 4), align 8, !tbaa !16
  %37 = load i32, ptr @WAVEdb3, align 8, !tbaa !11
  %38 = call ptr @SerialReverse(ptr noundef %36, i32 noundef %37)
  %39 = load ptr, ptr %3, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.waveletBase, ptr %39, i32 0, i32 4
  store ptr %38, ptr %40, align 8, !tbaa !16
  br label %65

41:                                               ; preds = %14
  %42 = load i32, ptr @WAVEbior3_7, align 8, !tbaa !11
  %43 = load ptr, ptr %3, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.waveletBase, ptr %43, i32 0, i32 0
  store i32 %42, ptr %44, align 8, !tbaa !11
  %45 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEbior3_7, i32 0, i32 1), align 8, !tbaa !13
  %46 = load i32, ptr @WAVEbior3_7, align 8, !tbaa !11
  %47 = call ptr @SerialReverse(ptr noundef %45, i32 noundef %46)
  %48 = load ptr, ptr %3, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.waveletBase, ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !13
  %50 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEbior3_7, i32 0, i32 2), align 8, !tbaa !14
  %51 = load i32, ptr @WAVEbior3_7, align 8, !tbaa !11
  %52 = call ptr @SerialReverse(ptr noundef %50, i32 noundef %51)
  %53 = load ptr, ptr %3, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.waveletBase, ptr %53, i32 0, i32 2
  store ptr %52, ptr %54, align 8, !tbaa !14
  %55 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEbior3_7, i32 0, i32 3), align 8, !tbaa !15
  %56 = load i32, ptr @WAVEbior3_7, align 8, !tbaa !11
  %57 = call ptr @SerialReverse(ptr noundef %55, i32 noundef %56)
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.waveletBase, ptr %58, i32 0, i32 3
  store ptr %57, ptr %59, align 8, !tbaa !15
  %60 = load ptr, ptr getelementptr inbounds (%struct.waveletBase, ptr @WAVEbior3_7, i32 0, i32 4), align 8, !tbaa !16
  %61 = load i32, ptr @WAVEbior3_7, align 8, !tbaa !11
  %62 = call ptr @SerialReverse(ptr noundef %60, i32 noundef %61)
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.waveletBase, ptr %63, i32 0, i32 4
  store ptr %62, ptr %64, align 8, !tbaa !16
  br label %65

65:                                               ; preds = %41, %17, %14
  %66 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret ptr %66
}

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden ptr @SerialReverse(ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,1) "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 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 #3 = { "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 #4 = { noreturn 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"waveletBase", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 32}


; 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.waveletBase = type { i32, ptr, ptr, ptr, ptr }

@WAVEdb3 = external hidden local_unnamed_addr global %struct.waveletBase, align 8
@WAVEbior3_7 = external hidden local_unnamed_addr global %struct.waveletBase, align 8

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @set_wavelet_base(i32 noundef %0) local_unnamed_addr #1 {
  %2 = tail call noalias dereferenceable_or_null(40) ptr @calloc(i64 noundef 1, i64 noundef 40) #2
  switch i32 %0, label %20 [
    i32 1, label %.sink.split
    i32 2, label %3
  ]

3:                                                ; preds = %1
  br label %.sink.split

.sink.split:                                      ; preds = %1, %3
  %WAVEbior3_7.sink35 = phi ptr [ @WAVEbior3_7, %3 ], [ @WAVEdb3, %1 ]
  %.sink33 = phi ptr [ getelementptr inbounds (i8, ptr @WAVEbior3_7, i64 8), %3 ], [ getelementptr inbounds (i8, ptr @WAVEdb3, i64 8), %1 ]
  %.sink28 = phi ptr [ getelementptr inbounds (i8, ptr @WAVEbior3_7, i64 16), %3 ], [ getelementptr inbounds (i8, ptr @WAVEdb3, i64 16), %1 ]
  %.sink22 = phi ptr [ getelementptr inbounds (i8, ptr @WAVEbior3_7, i64 24), %3 ], [ getelementptr inbounds (i8, ptr @WAVEdb3, i64 24), %1 ]
  %.sink = phi ptr [ getelementptr inbounds (i8, ptr @WAVEbior3_7, i64 32), %3 ], [ getelementptr inbounds (i8, ptr @WAVEdb3, i64 32), %1 ]
  %4 = load i32, ptr %WAVEbior3_7.sink35, align 8, !tbaa !5
  store i32 %4, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %.sink33, align 8, !tbaa !11
  %6 = tail call ptr @SerialReverse(ptr noundef %5, i32 noundef %4)
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %6, ptr %7, align 8, !tbaa !11
  %8 = load ptr, ptr %.sink28, align 8, !tbaa !12
  %9 = load i32, ptr %WAVEbior3_7.sink35, align 8, !tbaa !5
  %10 = tail call ptr @SerialReverse(ptr noundef %8, i32 noundef %9)
  %11 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !12
  %12 = load ptr, ptr %.sink22, align 8, !tbaa !13
  %13 = load i32, ptr %WAVEbior3_7.sink35, align 8, !tbaa !5
  %14 = tail call ptr @SerialReverse(ptr noundef %12, i32 noundef %13)
  %15 = getelementptr inbounds i8, ptr %2, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !13
  %16 = load ptr, ptr %.sink, align 8, !tbaa !14
  %17 = load i32, ptr %WAVEbior3_7.sink35, align 8, !tbaa !5
  %18 = tail call ptr @SerialReverse(ptr noundef %16, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %2, i64 32
  store ptr %18, ptr %19, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %.sink.split, %1
  ret ptr %2
}

; Function Attrs: nounwind uwtable
declare hidden ptr @SerialReverse(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 = { nounwind allocsize(0,1) }

!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 = !{!"waveletBase", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !10, i64 32}


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