; 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
@__PRETTY_FUNCTION__.dsbuffer_print = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dsbuffer_print(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %10

9:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 534, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_print) #4
  unreachable

10:                                               ; preds = %8
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._dsbuffer_t, ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i64 noundef %13)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._dsbuffer_t, ptr %15, i32 0, i32 4
  %17 = load i8, ptr %16, align 8, !tbaa !13, !range !14, !noundef !15
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %45

19:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store i64 0, ptr %3, align 8, !tbaa !16
  br label %20

20:                                               ; preds = %40, %19
  %21 = load i64, ptr %3, align 8, !tbaa !16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._dsbuffer_t, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = icmp ult i64 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %43

27:                                               ; preds = %20
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._dsbuffer_t, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._dsbuffer_t, ptr %31, i32 0, i32 2
  %33 = load i64, ptr %32, align 8, !tbaa !18
  %34 = load i64, ptr %3, align 8, !tbaa !16
  %35 = add i64 %33, %34
  %36 = getelementptr inbounds float, ptr %30, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !19
  %38 = fpext float %37 to double
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, double noundef %38)
  br label %40

40:                                               ; preds = %27
  %41 = load i64, ptr %3, align 8, !tbaa !16
  %42 = add i64 %41, 1
  store i64 %42, ptr %3, align 8, !tbaa !16
  br label %20, !llvm.loop !21

43:                                               ; preds = %26
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %79

45:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %46

46:                                               ; preds = %74, %45
  %47 = load i64, ptr %4, align 8, !tbaa !16
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._dsbuffer_t, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = icmp ult i64 %47, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %77

53:                                               ; preds = %46
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._dsbuffer_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._dsbuffer_t, ptr %57, i32 0, i32 2
  %59 = load i64, ptr %58, align 8, !tbaa !18
  %60 = load i64, ptr %5, align 8, !tbaa !16
  %61 = add i64 %59, %60
  %62 = getelementptr inbounds float, ptr %56, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !19
  %64 = fpext float %63 to double
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, double noundef %64)
  %66 = load i64, ptr %5, align 8, !tbaa !16
  %67 = add i64 %66, 1
  store i64 %67, ptr %5, align 8, !tbaa !16
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._dsbuffer_t, ptr %68, i32 0, i32 1
  %70 = load i64, ptr %69, align 8, !tbaa !9
  %71 = icmp eq i64 %67, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %53
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %73

73:                                               ; preds = %72, %53
  br label %74

74:                                               ; preds = %73
  %75 = load i64, ptr %4, align 8, !tbaa !16
  %76 = add i64 %75, 1
  store i64 %76, ptr %4, align 8, !tbaa !16
  br label %46, !llvm.loop !23

77:                                               ; preds = %52
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %79

79:                                               ; preds = %77, %43
  ret void
}

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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, !11, i64 8}
!10 = !{!"_dsbuffer_t", !6, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !12, i64 32}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 0}
!18 = !{!10, !11, i64 16}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!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
@__PRETTY_FUNCTION__.dsbuffer_print = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dsbuffer_print(ptr noundef readonly %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

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

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i64 noundef %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load i8, ptr %7, align 8, !tbaa !12, !range !13, !noundef !14
  %9 = trunc nuw i8 %8 to i1
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %.not26 = icmp eq i64 %10, 0
  br i1 %9, label %.preheader, label %.preheader19

.preheader19:                                     ; preds = %3
  br i1 %.not26, label %._crit_edge24, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader19
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  br label %24

.preheader:                                       ; preds = %3
  br i1 %.not26, label %._crit_edge24, label %.lr.ph23

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

13:                                               ; preds = %.lr.ph23, %13
  %.01722 = phi i64 [ 0, %.lr.ph23 ], [ %21, %13 ]
  %14 = load ptr, ptr %0, align 8, !tbaa !15
  %15 = load i64, ptr %12, align 8, !tbaa !16
  %16 = getelementptr float, ptr %14, i64 %15
  %17 = getelementptr float, ptr %16, i64 %.01722
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = fpext float %18 to double
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, double noundef %19)
  %21 = add nuw i64 %.01722, 1
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %13, label %._crit_edge24, !llvm.loop !19

24:                                               ; preds = %.lr.ph, %24
  %.021 = phi i64 [ 0, %.lr.ph ], [ %spec.store.select, %24 ]
  %.01620 = phi i64 [ 0, %.lr.ph ], [ %35, %24 ]
  %25 = load ptr, ptr %0, align 8, !tbaa !15
  %26 = load i64, ptr %11, align 8, !tbaa !16
  %27 = getelementptr float, ptr %25, i64 %26
  %28 = getelementptr float, ptr %27, i64 %.021
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = fpext float %29 to double
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, double noundef %30)
  %32 = add i64 %.021, 1
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = icmp eq i64 %32, %33
  %spec.store.select = select i1 %34, i64 0, i64 %32
  %35 = add nuw i64 %.01620, 1
  %36 = icmp ult i64 %35, %33
  br i1 %36, label %24, label %._crit_edge24, !llvm.loop !21

._crit_edge24:                                    ; preds = %24, %13, %.preheader19, %.preheader
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  ret void
}

attributes #0 = { 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 #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 = { noreturn 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, !10, i64 8}
!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, !11, i64 32}
!13 = !{i8 0, i8 2}
!14 = !{}
!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