; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_audio_formats/codecs/oggvorbis (clear)

; 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.vorbis_block = type { ptr, %struct.oggpack_buffer, i64, i64, i64, i32, i32, i32, i64, i64, ptr, ptr, i64, i64, i64, ptr, i64, i64, i64, i64, ptr }
%struct.oggpack_buffer = type { i64, i32, ptr, ptr, i64 }
%struct.vorbis_block_internal = type { ptr, float, i32, [15 x ptr] }

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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
declare dso_local void @_vorbis_block_ripcord(ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_block_clear(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.vorbis_block, ptr %5, i32 0, i32 20
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_vorbis_block_ripcord(ptr noundef %8)
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.vorbis_block, ptr %9, i32 0, i32 11
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %17

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.vorbis_block, ptr %14, i32 0, i32 11
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  call void @free(ptr noundef %16) #5
  br label %17

17:                                               ; preds = %13, %1
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %46

20:                                               ; preds = %17
  store i32 0, ptr %3, align 4, !tbaa !15
  br label %21

21:                                               ; preds = %41, %20
  %22 = load i32, ptr %3, align 4, !tbaa !15
  %23 = icmp slt i32 %22, 15
  br i1 %23, label %24, label %44

24:                                               ; preds = %21
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.vorbis_block_internal, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %3, align 4, !tbaa !15
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [15 x ptr], ptr %26, i64 0, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  call void @oggpack_writeclear(ptr noundef %30)
  %31 = load i32, ptr %3, align 4, !tbaa !15
  %32 = icmp ne i32 %31, 7
  br i1 %32, label %33, label %40

33:                                               ; preds = %24
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.vorbis_block_internal, ptr %34, i32 0, i32 3
  %36 = load i32, ptr %3, align 4, !tbaa !15
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [15 x ptr], ptr %35, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  call void @free(ptr noundef %39) #5
  br label %40

40:                                               ; preds = %33, %24
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %3, align 4, !tbaa !15
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !15
  br label %21, !llvm.loop !16

44:                                               ; preds = %21
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %45) #5
  br label %46

46:                                               ; preds = %44, %17
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %47, i8 0, i64 192, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret i32 0
}

declare void @oggpack_writeclear(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 }

!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 184}
!10 = !{!"vorbis_block", !6, i64 0, !11, i64 8, !12, i64 48, !12, i64 56, !12, i64 64, !13, i64 72, !13, i64 76, !13, i64 80, !12, i64 88, !12, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !6, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !6, i64 184}
!11 = !{!"", !12, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !6, i64 112}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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

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

; Function Attrs: nounwind uwtable
declare dso_local void @_vorbis_block_ripcord(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @vorbis_block_clear(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 184
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_vorbis_block_ripcord(ptr noundef %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 112
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void @free(ptr noundef nonnull %5) #4
  br label %7

7:                                                ; preds = %6, %1
  %.not15 = icmp eq ptr %3, null
  br i1 %.not15, label %52, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %10) #4
  %11 = load ptr, ptr %9, align 8, !tbaa !14
  tail call void @free(ptr noundef %11) #4
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %13) #4
  %14 = load ptr, ptr %12, align 8, !tbaa !14
  tail call void @free(ptr noundef %14) #4
  %15 = getelementptr inbounds i8, ptr %3, i64 32
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %16) #4
  %17 = load ptr, ptr %15, align 8, !tbaa !14
  tail call void @free(ptr noundef %17) #4
  %18 = getelementptr inbounds i8, ptr %3, i64 40
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %19) #4
  %20 = load ptr, ptr %18, align 8, !tbaa !14
  tail call void @free(ptr noundef %20) #4
  %21 = getelementptr inbounds i8, ptr %3, i64 48
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %22) #4
  %23 = load ptr, ptr %21, align 8, !tbaa !14
  tail call void @free(ptr noundef %23) #4
  %24 = getelementptr inbounds i8, ptr %3, i64 56
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %25) #4
  %26 = load ptr, ptr %24, align 8, !tbaa !14
  tail call void @free(ptr noundef %26) #4
  %27 = getelementptr inbounds i8, ptr %3, i64 64
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %28) #4
  %29 = load ptr, ptr %27, align 8, !tbaa !14
  tail call void @free(ptr noundef %29) #4
  %30 = getelementptr inbounds i8, ptr %3, i64 72
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %31) #4
  %.phi.trans.insert = getelementptr inbounds i8, ptr %3, i64 80
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %.pre) #4
  %32 = getelementptr inbounds i8, ptr %3, i64 80
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  tail call void @free(ptr noundef %33) #4
  %34 = getelementptr inbounds i8, ptr %3, i64 88
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %35) #4
  %36 = load ptr, ptr %34, align 8, !tbaa !14
  tail call void @free(ptr noundef %36) #4
  %37 = getelementptr inbounds i8, ptr %3, i64 96
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %38) #4
  %39 = load ptr, ptr %37, align 8, !tbaa !14
  tail call void @free(ptr noundef %39) #4
  %40 = getelementptr inbounds i8, ptr %3, i64 104
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %41) #4
  %42 = load ptr, ptr %40, align 8, !tbaa !14
  tail call void @free(ptr noundef %42) #4
  %43 = getelementptr inbounds i8, ptr %3, i64 112
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %44) #4
  %45 = load ptr, ptr %43, align 8, !tbaa !14
  tail call void @free(ptr noundef %45) #4
  %46 = getelementptr inbounds i8, ptr %3, i64 120
  %47 = load ptr, ptr %46, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %47) #4
  %48 = load ptr, ptr %46, align 8, !tbaa !14
  tail call void @free(ptr noundef %48) #4
  %49 = getelementptr inbounds i8, ptr %3, i64 128
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  tail call void @oggpack_writeclear(ptr noundef %50) #4
  %51 = load ptr, ptr %49, align 8, !tbaa !14
  tail call void @free(ptr noundef %51) #4
  tail call void @free(ptr noundef nonnull %3) #4
  br label %52

52:                                               ; preds = %8, %7
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(192) %0, i8 0, i64 192, i1 false)
  ret i32 0
}

declare void @oggpack_writeclear(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 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 #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 = { 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 184}
!6 = !{!"vorbis_block", !7, i64 0, !10, i64 8, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !11, i64 88, !11, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !12, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 112}
!14 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass