; LLVM IR from herrkaefer/AccelerateWatch :: AccelerateWatch/Classes/acceleratelib (dsbuffer)

; 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._dsbuffer_t = type { ptr, i64, i64, ptr, i8, ptr, ptr, i64, ptr }

@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_new = external hidden unnamed_addr constant [40 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @dsbuffer_new(i64 noundef %0, i1 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  %8 = zext i1 %1 to i8
  store i8 %8, ptr %5, align 1, !tbaa !9
  %9 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %17

11:                                               ; preds = %2
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = urem i64 %12, 2
  %14 = icmp eq i64 %13, 1
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store ptr null, ptr %3, align 8
  br label %97

17:                                               ; preds = %11, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %18 = call noalias ptr @malloc(i64 noundef 72) #7
  store ptr %18, ptr %6, align 8, !tbaa !13
  %19 = load ptr, ptr %6, align 8, !tbaa !13
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  br label %23

22:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 127, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

23:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %24 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %29

26:                                               ; preds = %23
  %27 = load i64, ptr %4, align 8, !tbaa !5
  %28 = mul i64 %27, 2
  br label %31

29:                                               ; preds = %23
  %30 = load i64, ptr %4, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %29, %26
  %32 = phi i64 [ %28, %26 ], [ %30, %29 ]
  store i64 %32, ptr %7, align 8, !tbaa !5
  %33 = load i64, ptr %7, align 8, !tbaa !5
  %34 = call noalias ptr @calloc(i64 noundef %33, i64 noundef 4) #9
  %35 = load ptr, ptr %6, align 8, !tbaa !13
  %36 = getelementptr inbounds %struct._dsbuffer_t, ptr %35, i32 0, i32 0
  store ptr %34, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %6, align 8, !tbaa !13
  %38 = getelementptr inbounds %struct._dsbuffer_t, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %31
  br label %43

42:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 132, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

43:                                               ; preds = %41
  %44 = load i64, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !13
  %46 = getelementptr inbounds %struct._dsbuffer_t, ptr %45, i32 0, i32 1
  store i64 %44, ptr %46, align 8, !tbaa !17
  %47 = load ptr, ptr %6, align 8, !tbaa !13
  %48 = getelementptr inbounds %struct._dsbuffer_t, ptr %47, i32 0, i32 2
  store i64 0, ptr %48, align 8, !tbaa !18
  %49 = load i64, ptr %4, align 8, !tbaa !5
  %50 = call zeroext i1 @is_power_of_2(i64 noundef %49)
  br i1 %50, label %51, label %58

51:                                               ; preds = %43
  %52 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %53 = trunc i8 %52 to i1
  %54 = zext i1 %53 to i64
  %55 = select i1 %53, ptr @dsbuffer_push_fast_with_fft, ptr @dsbuffer_push_fast
  %56 = load ptr, ptr %6, align 8, !tbaa !13
  %57 = getelementptr inbounds %struct._dsbuffer_t, ptr %56, i32 0, i32 3
  store ptr %55, ptr %57, align 8, !tbaa !19
  br label %65

58:                                               ; preds = %43
  %59 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %60 = trunc i8 %59 to i1
  %61 = zext i1 %60 to i64
  %62 = select i1 %60, ptr @dsbuffer_push_normal_with_fft, ptr @dsbuffer_push_normal
  %63 = load ptr, ptr %6, align 8, !tbaa !13
  %64 = getelementptr inbounds %struct._dsbuffer_t, ptr %63, i32 0, i32 3
  store ptr %62, ptr %64, align 8, !tbaa !19
  br label %65

65:                                               ; preds = %58, %51
  %66 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %67 = trunc i8 %66 to i1
  %68 = load ptr, ptr %6, align 8, !tbaa !13
  %69 = getelementptr inbounds %struct._dsbuffer_t, ptr %68, i32 0, i32 4
  %70 = zext i1 %67 to i8
  store i8 %70, ptr %69, align 8, !tbaa !20
  %71 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %86

73:                                               ; preds = %65
  %74 = load i64, ptr %4, align 8, !tbaa !5
  %75 = trunc i64 %74 to i32
  %76 = call ptr @kiss_fftr_alloc(i32 noundef %75, i32 noundef 0, ptr noundef null, ptr noundef null)
  %77 = load ptr, ptr %6, align 8, !tbaa !13
  %78 = getelementptr inbounds %struct._dsbuffer_t, ptr %77, i32 0, i32 5
  store ptr %76, ptr %78, align 8, !tbaa !21
  %79 = load ptr, ptr %6, align 8, !tbaa !13
  %80 = getelementptr inbounds %struct._dsbuffer_t, ptr %79, i32 0, i32 5
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %84

83:                                               ; preds = %73
  br label %85

84:                                               ; preds = %73
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 151, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

85:                                               ; preds = %83
  br label %89

86:                                               ; preds = %65
  %87 = load ptr, ptr %6, align 8, !tbaa !13
  %88 = getelementptr inbounds %struct._dsbuffer_t, ptr %87, i32 0, i32 5
  store ptr null, ptr %88, align 8, !tbaa !21
  br label %89

89:                                               ; preds = %86, %85
  %90 = load ptr, ptr %6, align 8, !tbaa !13
  %91 = getelementptr inbounds %struct._dsbuffer_t, ptr %90, i32 0, i32 6
  store ptr null, ptr %91, align 8, !tbaa !22
  %92 = load ptr, ptr %6, align 8, !tbaa !13
  %93 = getelementptr inbounds %struct._dsbuffer_t, ptr %92, i32 0, i32 7
  store i64 0, ptr %93, align 8, !tbaa !23
  %94 = load ptr, ptr %6, align 8, !tbaa !13
  %95 = getelementptr inbounds %struct._dsbuffer_t, ptr %94, i32 0, i32 8
  store ptr null, ptr %95, align 8, !tbaa !24
  %96 = load ptr, ptr %6, align 8, !tbaa !13
  store ptr %96, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %97

97:                                               ; preds = %89, %15
  %98 = load ptr, ptr %3, align 8
  ret ptr %98
}

declare i32 @printf(ptr 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_power_of_2(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_fast_with_fft(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_fast(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_normal_with_fft(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_normal(ptr noundef, float noundef) #0

declare ptr @kiss_fftr_alloc(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

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

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 = { "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 = { nounwind allocsize(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 #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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_dsbuffer_t", !14, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !10, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !14, i64 64}
!17 = !{!16, !6, i64 8}
!18 = !{!16, !6, i64 16}
!19 = !{!16, !14, i64 24}
!20 = !{!16, !10, i64 32}
!21 = !{!16, !14, i64 40}
!22 = !{!16, !14, i64 48}
!23 = !{!16, !6, i64 56}
!24 = !{!16, !14, i64 64}


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

@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_new = external hidden unnamed_addr constant [40 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @dsbuffer_new(i64 noundef %0, i1 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = zext i1 %1 to i8
  %4 = and i64 %0, 1
  %.not = icmp ne i64 %4, 0
  %or.cond.not = and i1 %.not, %1
  br i1 %or.cond.not, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %32

7:                                                ; preds = %2
  %8 = tail call noalias dereferenceable_or_null(72) ptr @malloc(i64 noundef 72) #7
  %.not29 = icmp eq ptr %8, null
  br i1 %.not29, label %9, label %10

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 127, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

10:                                               ; preds = %7
  %11 = zext i1 %1 to i64
  %12 = shl i64 %0, %11
  %13 = tail call noalias ptr @calloc(i64 noundef %12, i64 noundef 4) #9
  store ptr %13, ptr %8, align 8, !tbaa !5
  %.not30 = icmp eq ptr %13, null
  br i1 %.not30, label %14, label %15

14:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 132, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 %0, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %8, i64 16
  store i64 0, ptr %17, align 8, !tbaa !13
  %18 = tail call zeroext i1 @is_power_of_2(i64 noundef %0)
  %19 = select i1 %1, ptr @dsbuffer_push_fast_with_fft, ptr @dsbuffer_push_fast
  %20 = select i1 %1, ptr @dsbuffer_push_normal_with_fft, ptr @dsbuffer_push_normal
  %.sink = select i1 %18, ptr %19, ptr %20
  %21 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %.sink, ptr %21, align 8
  %22 = getelementptr inbounds i8, ptr %8, i64 32
  store i8 %3, ptr %22, align 8, !tbaa !14
  br i1 %1, label %23, label %28

23:                                               ; preds = %15
  %24 = trunc i64 %0 to i32
  %25 = tail call ptr @kiss_fftr_alloc(i32 noundef %24, i32 noundef 0, ptr noundef null, ptr noundef null) #10
  %26 = getelementptr inbounds i8, ptr %8, i64 40
  store ptr %25, ptr %26, align 8, !tbaa !15
  %.not31 = icmp eq ptr %25, null
  br i1 %.not31, label %27, label %30

27:                                               ; preds = %23
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 151, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_new) #8
  unreachable

28:                                               ; preds = %15
  %29 = getelementptr inbounds i8, ptr %8, i64 40
  store ptr null, ptr %29, align 8, !tbaa !15
  br label %30

30:                                               ; preds = %23, %28
  %31 = getelementptr inbounds i8, ptr %8, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %31, i8 0, i64 24, i1 false)
  br label %32

32:                                               ; preds = %30, %5
  %.0 = phi ptr [ null, %5 ], [ %8, %30 ]
  ret ptr %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; 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 #4

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_power_of_2(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_fast_with_fft(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_fast(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_normal_with_fft(ptr noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @dsbuffer_push_normal(ptr noundef, float noundef) #0

declare ptr @kiss_fftr_alloc(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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 = { nofree 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #3 = { 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 #4 = { 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 #5 = { "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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0,1) }
attributes #10 = { 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 = !{!"_dsbuffer_t", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, 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 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !7, i64 40}


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