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

; 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.oggpack_buffer = type { i64, i32, ptr, ptr, i64 }
%struct.ogg_packet = type { ptr, i64, i64, i64, i64, i64 }
%struct.vorbis_info = type { i32, i32, i64, i64, i64, i64, i64, ptr }
%struct.vorbis_comment = type { ptr, ptr, i32, ptr }

@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

declare void @oggpack_readinit(ptr noundef, ptr noundef, i32 noundef) #2

declare i64 @oggpack_read(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @_v_readstring(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_synthesis_headerin(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.oggpack_buffer, align 8
  %9 = alloca [6 x i8], align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %72

14:                                               ; preds = %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ogg_packet, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ogg_packet, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !12
  %21 = trunc i64 %20 to i32
  call void @oggpack_readinit(ptr noundef %8, ptr noundef %17, i32 noundef %21)
  call void @llvm.lifetime.start.p0(i64 6, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %22 = call i64 @oggpack_read(ptr noundef %8, i32 noundef 8)
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %10, align 4, !tbaa !13
  %24 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %24, i8 0, i64 6, i1 false)
  %25 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  call void @_v_readstring(ptr noundef %8, ptr noundef %25, i32 noundef 6)
  %26 = getelementptr inbounds [6 x i8], ptr %9, i64 0, i64 0
  %27 = call i32 @memcmp(ptr noundef %26, ptr noundef @.str.1, i64 noundef 6) #6
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %14
  store i32 -132, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

30:                                               ; preds = %14
  %31 = load i32, ptr %10, align 4, !tbaa !13
  switch i32 %31, label %70 [
    i32 1, label %32
    i32 3, label %47
    i32 5, label %56
  ]

32:                                               ; preds = %30
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ogg_packet, ptr %33, i32 0, i32 2
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

38:                                               ; preds = %32
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vorbis_info, ptr %39, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !16
  %42 = icmp ne i64 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

44:                                               ; preds = %38
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call i32 @_vorbis_unpack_info(ptr noundef %45, ptr noundef %8)
  store i32 %46, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

47:                                               ; preds = %30
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vorbis_info, ptr %48, i32 0, i32 2
  %50 = load i64, ptr %49, align 8, !tbaa !16
  %51 = icmp eq i64 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

53:                                               ; preds = %47
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call i32 @_vorbis_unpack_comment(ptr noundef %54, ptr noundef %8)
  store i32 %55, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

56:                                               ; preds = %30
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.vorbis_info, ptr %57, i32 0, i32 2
  %59 = load i64, ptr %58, align 8, !tbaa !16
  %60 = icmp eq i64 %59, 0
  br i1 %60, label %66, label %61

61:                                               ; preds = %56
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.vorbis_comment, ptr %62, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !18
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %67

66:                                               ; preds = %61, %56
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

67:                                               ; preds = %61
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = call i32 @_vorbis_unpack_books(ptr noundef %68, ptr noundef %8)
  store i32 %69, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

70:                                               ; preds = %30
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %71

71:                                               ; preds = %70, %67, %66, %53, %52, %44, %43, %37, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 6, ptr %9) #5
  br label %73

72:                                               ; preds = %3
  store i32 -133, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %73

73:                                               ; preds = %72, %71
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #5
  %74 = load i32, ptr %4, align 4
  ret i32 %74
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_info(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_comment(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_books(ptr noundef, ptr noundef) #3

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

!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 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !11, i64 16}
!16 = !{!17, !11, i64 8}
!17 = !{!"vorbis_info", !14, i64 0, !14, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !6, i64 48}
!18 = !{!19, !6, i64 24}
!19 = !{!"vorbis_comment", !6, i64 0, !6, i64 8, !14, i64 16, !6, i64 24}


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

%struct.oggpack_buffer = type { i64, i32, ptr, ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @oggpack_readinit(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i64 @oggpack_read(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @_v_readstring(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_synthesis_headerin(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2) local_unnamed_addr #3 {
  %4 = alloca %struct.oggpack_buffer, align 8
  %5 = alloca [6 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %39, label %6

6:                                                ; preds = %3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = trunc i64 %9 to i32
  call void @oggpack_readinit(ptr noundef nonnull %4, ptr noundef %7, i32 noundef %10) #5
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %5) #5
  %11 = call i64 @oggpack_read(ptr noundef nonnull %4, i32 noundef 8) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(6) %5, i8 0, i64 6, i1 false)
  call void @_v_readstring(ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef 6)
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %5, ptr noundef nonnull dereferenceable(6) @.str.1, i64 6)
  %.not13 = icmp eq i32 %bcmp, 0
  br i1 %.not13, label %12, label %38

12:                                               ; preds = %6
  %13 = trunc i64 %11 to i32
  switch i32 %13, label %38 [
    i32 1, label %14
    i32 3, label %22
    i32 5, label %28
  ]

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = load i64, ptr %15, align 8, !tbaa !12
  %.not14 = icmp eq i64 %16, 0
  br i1 %.not14, label %38, label %17

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %.not15 = icmp eq i64 %19, 0
  br i1 %.not15, label %20, label %38

20:                                               ; preds = %17
  %21 = call i32 @_vorbis_unpack_info(ptr noundef nonnull %0, ptr noundef nonnull %4)
  br label %38

22:                                               ; preds = %12
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %38, label %26

26:                                               ; preds = %22
  %27 = call i32 @_vorbis_unpack_comment(ptr noundef %1, ptr noundef nonnull %4)
  br label %38

28:                                               ; preds = %12
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = load i64, ptr %29, align 8, !tbaa !13
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %38, label %32

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %1, i64 24
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = icmp eq ptr %34, null
  br i1 %35, label %38, label %36

36:                                               ; preds = %32
  %37 = call i32 @_vorbis_unpack_books(ptr noundef nonnull %0, ptr noundef nonnull %4)
  br label %38

38:                                               ; preds = %12, %28, %32, %22, %17, %14, %6, %36, %26, %20
  %.0 = phi i32 [ %37, %36 ], [ %27, %26 ], [ %21, %20 ], [ -132, %6 ], [ -133, %14 ], [ -133, %17 ], [ -133, %22 ], [ -133, %32 ], [ -133, %28 ], [ -133, %12 ]
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %5) #5
  br label %39

39:                                               ; preds = %3, %38
  %.1 = phi i32 [ %.0, %38 ], [ -133, %3 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #5
  ret i32 %.1
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_info(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_comment(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_vorbis_unpack_books(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress 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 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 = { nofree nounwind willreturn memory(argmem: read) }
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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !10, i64 8}
!14 = !{!"vorbis_info", !15, i64 0, !15, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !7, i64 48}
!15 = !{!"int", !8, i64 0}
!16 = !{!17, !7, i64 24}
!17 = !{!"vorbis_comment", !7, i64 0, !7, i64 8, !15, i64 16, !7, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass