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

; 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] }
%struct.vorbis_func_mapping = type { ptr, ptr, ptr, ptr, ptr }
%struct.ogg_packet = type { ptr, i64, i64, i64, i64, i64 }

@_mapping_P = external constant [0 x ptr], align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_analysis(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.vorbis_block, ptr %10, i32 0, i32 20
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.vorbis_block, ptr %13, i32 0, i32 16
  store i64 0, ptr %14, align 8, !tbaa !14
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.vorbis_block, ptr %15, i32 0, i32 17
  store i64 0, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vorbis_block, ptr %17, i32 0, i32 18
  store i64 0, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.vorbis_block, ptr %19, i32 0, i32 19
  store i64 0, ptr %20, align 8, !tbaa !17
  store i32 0, ptr %7, align 4, !tbaa !18
  br label %21

21:                                               ; preds = %31, %2
  %22 = load i32, ptr %7, align 4, !tbaa !18
  %23 = icmp slt i32 %22, 15
  br i1 %23, label %24, label %34

24:                                               ; preds = %21
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.vorbis_block_internal, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %7, align 4, !tbaa !18
  %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_reset(ptr noundef %30)
  br label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %7, align 4, !tbaa !18
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !18
  br label %21, !llvm.loop !19

34:                                               ; preds = %21
  %35 = load ptr, ptr @_mapping_P, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.vorbis_func_mapping, ptr %35, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call i32 %37(ptr noundef %38)
  store i32 %39, ptr %6, align 4, !tbaa !18
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %34
  %42 = load i32, ptr %6, align 4, !tbaa !18
  store i32 %42, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %81

43:                                               ; preds = %34
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %80

46:                                               ; preds = %43
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 @vorbis_bitrate_managed(ptr noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %46
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %81

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.vorbis_block, ptr %52, i32 0, i32 1
  %54 = call ptr @oggpack_get_buffer(ptr noundef %53)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ogg_packet, ptr %55, i32 0, i32 0
  store ptr %54, ptr %56, align 8, !tbaa !23
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.vorbis_block, ptr %57, i32 0, i32 1
  %59 = call i64 @oggpack_bytes(ptr noundef %58)
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ogg_packet, ptr %60, i32 0, i32 1
  store i64 %59, ptr %61, align 8, !tbaa !25
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ogg_packet, ptr %62, i32 0, i32 2
  store i64 0, ptr %63, align 8, !tbaa !26
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.vorbis_block, ptr %64, i32 0, i32 7
  %66 = load i32, ptr %65, align 8, !tbaa !27
  %67 = sext i32 %66 to i64
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ogg_packet, ptr %68, i32 0, i32 3
  store i64 %67, ptr %69, align 8, !tbaa !28
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.vorbis_block, ptr %70, i32 0, i32 8
  %72 = load i64, ptr %71, align 8, !tbaa !29
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ogg_packet, ptr %73, i32 0, i32 4
  store i64 %72, ptr %74, align 8, !tbaa !30
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.vorbis_block, ptr %75, i32 0, i32 9
  %77 = load i64, ptr %76, align 8, !tbaa !31
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ogg_packet, ptr %78, i32 0, i32 5
  store i64 %77, ptr %79, align 8, !tbaa !32
  br label %80

80:                                               ; preds = %51, %43
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %81

81:                                               ; preds = %80, %50, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %82 = load i32, ptr %3, align 4
  ret i32 %82
}

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

declare void @oggpack_reset(ptr noundef) #2

declare i32 @vorbis_bitrate_managed(ptr noundef) #2

declare ptr @oggpack_get_buffer(ptr noundef) #2

declare i64 @oggpack_bytes(ptr noundef) #2

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

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

!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, !12, i64 152}
!15 = !{!10, !12, i64 160}
!16 = !{!10, !12, i64 168}
!17 = !{!10, !12, i64 176}
!18 = !{!13, !13, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !6, i64 24}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!24, !6, i64 0}
!24 = !{!"", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!25 = !{!24, !12, i64 8}
!26 = !{!24, !12, i64 16}
!27 = !{!10, !13, i64 80}
!28 = !{!24, !12, i64 24}
!29 = !{!10, !12, i64 88}
!30 = !{!24, !12, i64 32}
!31 = !{!10, !12, i64 96}
!32 = !{!24, !12, i64 40}


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

@_mapping_P = external local_unnamed_addr constant [0 x ptr], align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_analysis(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 184
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 152
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %5, i8 0, i64 32, i1 false)
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %7) #3
  %8 = getelementptr inbounds i8, ptr %4, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %9) #3
  %10 = getelementptr inbounds i8, ptr %4, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %11) #3
  %12 = getelementptr inbounds i8, ptr %4, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %13) #3
  %14 = getelementptr inbounds i8, ptr %4, i64 48
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %15) #3
  %16 = getelementptr inbounds i8, ptr %4, i64 56
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %17) #3
  %18 = getelementptr inbounds i8, ptr %4, i64 64
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %19) #3
  %20 = getelementptr inbounds i8, ptr %4, i64 72
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %21) #3
  %22 = getelementptr inbounds i8, ptr %4, i64 80
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %23) #3
  %24 = getelementptr inbounds i8, ptr %4, i64 88
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %25) #3
  %26 = getelementptr inbounds i8, ptr %4, i64 96
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %27) #3
  %28 = getelementptr inbounds i8, ptr %4, i64 104
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %29) #3
  %30 = getelementptr inbounds i8, ptr %4, i64 112
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %31) #3
  %32 = getelementptr inbounds i8, ptr %4, i64 120
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %33) #3
  %34 = getelementptr inbounds i8, ptr %4, i64 128
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  tail call void @oggpack_reset(ptr noundef %35) #3
  %36 = load ptr, ptr @_mapping_P, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 24
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = tail call i32 %38(ptr noundef %0) #3
  %.not = icmp eq i32 %39, 0
  br i1 %.not, label %40, label %56

40:                                               ; preds = %2
  %.not27 = icmp eq ptr %1, null
  br i1 %.not27, label %56, label %41

41:                                               ; preds = %40
  %42 = tail call i32 @vorbis_bitrate_managed(ptr noundef nonnull %0) #3
  %.not28 = icmp eq i32 %42, 0
  br i1 %.not28, label %43, label %56

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  %45 = tail call ptr @oggpack_get_buffer(ptr noundef nonnull %44) #3
  store ptr %45, ptr %1, align 8, !tbaa !16
  %46 = tail call i64 @oggpack_bytes(ptr noundef nonnull %44) #3
  %47 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %46, ptr %47, align 8, !tbaa !18
  %48 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 0, ptr %48, align 8, !tbaa !19
  %49 = getelementptr inbounds i8, ptr %0, i64 80
  %50 = load i32, ptr %49, align 8, !tbaa !20
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 %51, ptr %52, align 8, !tbaa !21
  %53 = getelementptr inbounds i8, ptr %0, i64 88
  %54 = getelementptr inbounds i8, ptr %1, i64 32
  %55 = load <2 x i64>, ptr %53, align 8, !tbaa !22
  store <2 x i64> %55, ptr %54, align 8, !tbaa !22
  br label %56

56:                                               ; preds = %40, %43, %41, %2
  %.0 = phi i32 [ %39, %2 ], [ -131, %41 ], [ 0, %43 ], [ 0, %40 ]
  ret i32 %.0
}

declare void @oggpack_reset(ptr noundef) local_unnamed_addr #1

declare i32 @vorbis_bitrate_managed(ptr noundef) local_unnamed_addr #1

declare ptr @oggpack_get_buffer(ptr noundef) local_unnamed_addr #1

declare i64 @oggpack_bytes(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 24}
!15 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!16 = !{!17, !7, i64 0}
!17 = !{!"", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!18 = !{!17, !11, i64 8}
!19 = !{!17, !11, i64 16}
!20 = !{!6, !12, i64 80}
!21 = !{!17, !11, i64 24}
!22 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass