; 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.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_mod = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr 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 void @dsbuffer_mod(ptr noundef %0, float noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 374, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_mod) #4
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  br label %19

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 375, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_mod) #4
  unreachable

19:                                               ; preds = %17
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._dsbuffer_t, ptr %20, i32 0, i32 4
  %22 = load i8, ptr %21, align 8, !tbaa !11, !range !15, !noundef !16
  %23 = trunc i8 %22 to i1
  br i1 %23, label %24, label %52

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !17
  br label %25

25:                                               ; preds = %48, %24
  %26 = load i64, ptr %7, align 8, !tbaa !17
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._dsbuffer_t, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = icmp ult i64 %26, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %51

32:                                               ; preds = %25
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._dsbuffer_t, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._dsbuffer_t, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !20
  %39 = load i64, ptr %7, align 8, !tbaa !17
  %40 = add i64 %38, %39
  %41 = getelementptr inbounds float, ptr %35, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !9
  %43 = load float, ptr %5, align 4, !tbaa !9
  %44 = call float @fmodf(float noundef %42, float noundef %43) #5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !17
  %47 = getelementptr inbounds float, ptr %45, i64 %46
  store float %44, ptr %47, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %32
  %49 = load i64, ptr %7, align 8, !tbaa !17
  %50 = add i64 %49, 1
  store i64 %50, ptr %7, align 8, !tbaa !17
  br label %25, !llvm.loop !21

51:                                               ; preds = %31
  br label %87

52:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._dsbuffer_t, ptr %53, i32 0, i32 2
  %55 = load i64, ptr %54, align 8, !tbaa !20
  store i64 %55, ptr %8, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !17
  br label %56

56:                                               ; preds = %83, %52
  %57 = load i64, ptr %9, align 8, !tbaa !17
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._dsbuffer_t, ptr %58, i32 0, i32 1
  %60 = load i64, ptr %59, align 8, !tbaa !18
  %61 = icmp ult i64 %57, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %86

63:                                               ; preds = %56
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._dsbuffer_t, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !19
  %67 = load i64, ptr %8, align 8, !tbaa !17
  %68 = getelementptr inbounds float, ptr %66, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !9
  %70 = load float, ptr %5, align 4, !tbaa !9
  %71 = call float @fmodf(float noundef %69, float noundef %70) #5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i64, ptr %9, align 8, !tbaa !17
  %74 = getelementptr inbounds float, ptr %72, i64 %73
  store float %71, ptr %74, align 4, !tbaa !9
  %75 = load i64, ptr %8, align 8, !tbaa !17
  %76 = add i64 %75, 1
  store i64 %76, ptr %8, align 8, !tbaa !17
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._dsbuffer_t, ptr %77, i32 0, i32 1
  %79 = load i64, ptr %78, align 8, !tbaa !18
  %80 = icmp eq i64 %76, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %63
  store i64 0, ptr %8, align 8, !tbaa !17
  br label %82

82:                                               ; preds = %81, %63
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %9, align 8, !tbaa !17
  %85 = add i64 %84, 1
  store i64 %85, ptr %9, align 8, !tbaa !17
  br label %56, !llvm.loop !23

86:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %87

87:                                               ; preds = %86, %51
  ret void
}

; Function Attrs: nounwind
declare float @fmodf(float noundef, float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { noreturn nounwind }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !14, i64 32}
!12 = !{!"_dsbuffer_t", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 64}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !13, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_mod = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @dsbuffer_mod(ptr noundef readonly %0, float noundef %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 374, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_mod) #3
  unreachable

5:                                                ; preds = %3
  %.not26 = icmp eq ptr %2, null
  br i1 %.not26, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 375, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_mod) #3
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i8, ptr %8, align 8, !tbaa !5, !range !12, !noundef !13
  %10 = trunc nuw i8 %9 to i1
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !14
  %.not33 = icmp eq i64 %12, 0
  br i1 %10, label %.preheader, label %25

.preheader:                                       ; preds = %7
  br i1 %.not33, label %.loopexit, label %.lr.ph31

.lr.ph31:                                         ; preds = %.preheader
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  br label %14

14:                                               ; preds = %.lr.ph31, %14
  %.02330 = phi i64 [ 0, %.lr.ph31 ], [ %22, %14 ]
  %15 = load ptr, ptr %0, align 8, !tbaa !15
  %16 = load i64, ptr %13, align 8, !tbaa !16
  %17 = getelementptr float, ptr %15, i64 %16
  %18 = getelementptr float, ptr %17, i64 %.02330
  %19 = load float, ptr %18, align 4, !tbaa !17
  %20 = tail call float @fmodf(float noundef %19, float noundef %1) #4
  %21 = getelementptr inbounds float, ptr %2, i64 %.02330
  store float %20, ptr %21, align 4, !tbaa !17
  %22 = add nuw i64 %.02330, 1
  %23 = load i64, ptr %11, align 8, !tbaa !14
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %14, label %.loopexit, !llvm.loop !19

25:                                               ; preds = %7
  br i1 %.not33, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %25
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  %27 = load i64, ptr %26, align 8, !tbaa !16
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.029 = phi i64 [ %36, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.02228 = phi i64 [ %spec.store.select, %.lr.ph ], [ %27, %.lr.ph.preheader ]
  %28 = load ptr, ptr %0, align 8, !tbaa !15
  %29 = getelementptr inbounds float, ptr %28, i64 %.02228
  %30 = load float, ptr %29, align 4, !tbaa !17
  %31 = tail call float @fmodf(float noundef %30, float noundef %1) #4
  %32 = getelementptr inbounds float, ptr %2, i64 %.029
  store float %31, ptr %32, align 4, !tbaa !17
  %33 = add i64 %.02228, 1
  %34 = load i64, ptr %11, align 8, !tbaa !14
  %35 = icmp eq i64 %33, %34
  %spec.store.select = select i1 %35, i64 0, i64 %33
  %36 = add nuw i64 %.029, 1
  %37 = icmp ult i64 %36, %34
  br i1 %37, label %.lr.ph, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %.lr.ph, %14, %25, %.preheader
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @fmodf(float noundef, float noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(write) "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 }
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, !11, i64 32}
!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 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !10, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass