; LLVM IR from AnzoDK/RPAudio :: includes/minimp3 (minimp3_test)

; 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.mp3dec_ex_t = type { %struct.mp3dec_t, %struct.mp3dec_map_info_t, ptr, %struct.mp3dec_index_t, i64, i64, i64, i64, i64, i64, %struct.mp3dec_frame_info_t, [2304 x i16], i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.mp3dec_t = type { [2 x [288 x float]], [960 x float], i32, i32, [4 x i8], [511 x i8] }
%struct.mp3dec_map_info_t = type { ptr, i64 }
%struct.mp3dec_index_t = type { ptr, i64, i64 }
%struct.mp3dec_frame_info_t = type { i32, i32, i32, i32, i32, i32 }

; 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: nounwind uwtable
define dso_local void @mp3dec_ex_close(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %18

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !17
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %18

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

18:                                               ; preds = %13, %7, %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %19, i32 0, i32 14
  %21 = load i32, ptr %20, align 8, !tbaa !18
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %18
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %24, i32 0, i32 1
  call void @mp3dec_close_file(ptr noundef %25)
  br label %26

26:                                               ; preds = %23, %18
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %27, i32 0, i32 3
  %29 = getelementptr inbounds %struct.mp3dec_index_t, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !19
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %37

32:                                               ; preds = %26
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %33, i32 0, i32 3
  %35 = getelementptr inbounds %struct.mp3dec_index_t, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  call void @free(ptr noundef %36) #3
  br label %37

37:                                               ; preds = %32, %26
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %38, i8 0, i64 11456, i1 false)
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @mp3dec_close_file(ptr noundef) #1

attributes #0 = { 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 = { 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 }

!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 6688}
!10 = !{!"", !11, i64 0, !13, i64 6672, !6, i64 6688, !15, i64 6696, !14, i64 6720, !14, i64 6728, !14, i64 6736, !14, i64 6744, !14, i64 6752, !14, i64 6760, !16, i64 6768, !7, i64 6792, !14, i64 11400, !14, i64 11408, !12, i64 11416, !12, i64 11420, !12, i64 11424, !12, i64 11428, !12, i64 11432, !12, i64 11436, !12, i64 11440, !12, i64 11444, !12, i64 11448, !12, i64 11452}
!11 = !{!"", !7, i64 0, !7, i64 2304, !12, i64 6144, !12, i64 6148, !7, i64 6152, !7, i64 6156}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !6, i64 0, !14, i64 8, !14, i64 16}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!17 = !{!10, !6, i64 6672}
!18 = !{!10, !12, i64 11416}
!19 = !{!10, !6, i64 6696}


; 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
define dso_local void @mp3dec_ex_close(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 6688
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %8, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 6672
  %6 = load ptr, ptr %5, align 8, !tbaa !16
  %.not9 = icmp eq ptr %6, null
  br i1 %.not9, label %8, label %7

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

8:                                                ; preds = %7, %4, %1
  %9 = getelementptr inbounds i8, ptr %0, i64 11416
  %10 = load i32, ptr %9, align 8, !tbaa !17
  %.not10 = icmp eq i32 %10, 0
  br i1 %.not10, label %13, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 6672
  tail call void @mp3dec_close_file(ptr noundef nonnull %12)
  br label %13

13:                                               ; preds = %11, %8
  %14 = getelementptr inbounds i8, ptr %0, i64 6696
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %.not11 = icmp eq ptr %15, null
  br i1 %.not11, label %17, label %16

16:                                               ; preds = %13
  tail call void @free(ptr noundef nonnull %15) #3
  br label %17

17:                                               ; preds = %16, %13
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(11456) %0, i8 0, i64 11456, i1 false)
  ret void
}

; 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
declare hidden void @mp3dec_close_file(ptr noundef) local_unnamed_addr #1

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 = { 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, !12, i64 6688}
!6 = !{!"", !7, i64 0, !11, i64 6672, !12, i64 6688, !14, i64 6696, !13, i64 6720, !13, i64 6728, !13, i64 6736, !13, i64 6744, !13, i64 6752, !13, i64 6760, !15, i64 6768, !8, i64 6792, !13, i64 11400, !13, i64 11408, !10, i64 11416, !10, i64 11420, !10, i64 11424, !10, i64 11428, !10, i64 11432, !10, i64 11436, !10, i64 11440, !10, i64 11444, !10, i64 11448, !10, i64 11452}
!7 = !{!"", !8, i64 0, !8, i64 2304, !10, i64 6144, !10, i64 6148, !8, i64 6152, !8, i64 6156}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !12, i64 0, !13, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"", !12, i64 0, !13, i64 8, !13, i64 16}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!16 = !{!6, !12, i64 6672}
!17 = !{!6, !10, i64 11416}
!18 = !{!6, !12, i64 6696}


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