; 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 }
%struct.mp3dec_io_t = type { ptr, ptr, ptr, ptr }

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp3dec_iterate_cb(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mp3dec_load_index(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mp3dec_ex_open_cb(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %19

12:                                               ; preds = %3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %19

15:                                               ; preds = %12
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = and i32 %16, -8
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %15, %12, %3
  store i32 -1, ptr %4, align 4
  br label %117

20:                                               ; preds = %15
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %21, i8 0, i64 11456, i1 false)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %23, i32 0, i32 1
  store i64 131072, ptr %24, align 8, !tbaa !11
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = call noalias ptr @malloc(i64 noundef %28) #4
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %31, i32 0, i32 0
  store ptr %29, ptr %32, align 8, !tbaa !18
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = icmp ne ptr %36, null
  br i1 %37, label %39, label %38

38:                                               ; preds = %20
  store i32 -2, ptr %4, align 4
  br label %117

39:                                               ; preds = %20
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %41, i32 0, i32 15
  store i32 %40, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %44, i32 0, i32 2
  store ptr %43, ptr %45, align 8, !tbaa !20
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %46, i32 0, i32 0
  call void @mp3dec_init(ptr noundef %47)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mp3dec_io_t, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mp3dec_io_t, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  %54 = call i32 %50(i64 noundef 0, ptr noundef %53)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %39
  store i32 -3, ptr %4, align 4
  br label %117

57:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !18
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !11
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call i32 @mp3dec_iterate_cb(ptr noundef %58, ptr noundef %62, i64 noundef %66, ptr noundef @mp3dec_load_index, ptr noundef %67)
  store i32 %68, ptr %8, align 4, !tbaa !9
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %76

71:                                               ; preds = %57
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = icmp ne i32 -4, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %75, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %116

76:                                               ; preds = %71, %57
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %77, i32 0, i32 2
  %79 = load ptr, ptr %78, align 8, !tbaa !20
  %80 = getelementptr inbounds %struct.mp3dec_io_t, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %82, i32 0, i32 8
  %84 = load i64, ptr %83, align 8, !tbaa !24
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !20
  %88 = getelementptr inbounds %struct.mp3dec_io_t, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !23
  %90 = call i32 %81(i64 noundef %84, ptr noundef %89)
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %76
  store i32 -3, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %116

93:                                               ; preds = %76
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %94, i32 0, i32 0
  call void @mp3dec_init(ptr noundef %95)
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %96, i32 0, i32 19
  store i32 0, ptr %97, align 4, !tbaa !25
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %98, i32 0, i32 16
  %100 = load i32, ptr %99, align 8, !tbaa !26
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %106, label %102

102:                                              ; preds = %93
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = and i32 %103, 2
  %105 = icmp ne i32 %104, 0
  br label %106

106:                                              ; preds = %102, %93
  %107 = phi i1 [ true, %93 ], [ %105, %102 ]
  %108 = xor i1 %107, true
  %109 = zext i1 %108 to i32
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %110, i32 0, i32 17
  store i32 %109, ptr %111, align 4, !tbaa !27
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %112, i32 0, i32 15
  %114 = load i32, ptr %113, align 4, !tbaa !19
  %115 = and i32 %114, -3
  store i32 %115, ptr %113, align 4, !tbaa !19
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %116

116:                                              ; preds = %106, %92, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %117

117:                                              ; preds = %116, %56, %38, %19
  %118 = load i32, ptr %4, align 4
  ret i32 %118
}

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(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 allocsize(0) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !15, i64 6680}
!12 = !{!"", !13, i64 0, !14, i64 6672, !6, i64 6688, !16, i64 6696, !15, i64 6720, !15, i64 6728, !15, i64 6736, !15, i64 6744, !15, i64 6752, !15, i64 6760, !17, i64 6768, !7, i64 6792, !15, i64 11400, !15, 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}
!13 = !{!"", !7, i64 0, !7, i64 2304, !10, i64 6144, !10, i64 6148, !7, i64 6152, !7, i64 6156}
!14 = !{!"", !6, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !6, i64 0, !15, i64 8, !15, i64 16}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!18 = !{!12, !6, i64 6672}
!19 = !{!12, !10, i64 11420}
!20 = !{!12, !6, i64 6688}
!21 = !{!22, !6, i64 16}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = !{!22, !6, i64 24}
!24 = !{!12, !15, i64 6752}
!25 = !{!12, !10, i64 11436}
!26 = !{!12, !10, i64 11424}
!27 = !{!12, !10, i64 11428}


; 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: nounwind uwtable
declare dso_local void @mp3dec_init(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp3dec_iterate_cb(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mp3dec_load_index(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @mp3dec_ex_open_cb(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = and i1 %4, %5
  %.not = icmp ult i32 %2, 8
  %or.cond41 = and i1 %or.cond, %.not
  br i1 %or.cond41, label %6, label %41

6:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(11456) %0, i8 0, i64 11456, i1 false)
  %7 = getelementptr inbounds i8, ptr %0, i64 6672
  %8 = getelementptr inbounds i8, ptr %0, i64 6680
  store i64 131072, ptr %8, align 8, !tbaa !5
  %9 = tail call noalias dereferenceable_or_null(131072) ptr @malloc(i64 noundef 131072) #3
  store ptr %9, ptr %7, align 8, !tbaa !16
  %.not37 = icmp eq ptr %9, null
  br i1 %.not37, label %41, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 11420
  store i32 %2, ptr %11, align 4, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %0, i64 6688
  store ptr %1, ptr %12, align 8, !tbaa !18
  tail call void @mp3dec_init(ptr noundef nonnull %0)
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !21
  %17 = tail call i32 %14(i64 noundef 0, ptr noundef %16) #4
  %.not38 = icmp eq i32 %17, 0
  br i1 %.not38, label %18, label %41

18:                                               ; preds = %10
  %19 = load ptr, ptr %7, align 8, !tbaa !16
  %20 = load i64, ptr %8, align 8, !tbaa !5
  %21 = tail call i32 @mp3dec_iterate_cb(ptr noundef nonnull %1, ptr noundef %19, i64 noundef %20, ptr noundef nonnull @mp3dec_load_index, ptr noundef nonnull %0)
  switch i32 %21, label %41 [
    i32 -4, label %22
    i32 0, label %22
  ]

22:                                               ; preds = %18, %18
  %23 = load ptr, ptr %12, align 8, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %0, i64 6752
  %27 = load i64, ptr %26, align 8, !tbaa !22
  %28 = getelementptr inbounds i8, ptr %23, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = tail call i32 %25(i64 noundef %27, ptr noundef %29) #4
  %.not39 = icmp eq i32 %30, 0
  br i1 %.not39, label %31, label %41

31:                                               ; preds = %22
  tail call void @mp3dec_init(ptr noundef nonnull %0)
  %32 = getelementptr inbounds i8, ptr %0, i64 11436
  store i32 0, ptr %32, align 4, !tbaa !23
  %33 = getelementptr inbounds i8, ptr %0, i64 11424
  %34 = load i32, ptr %33, align 8, !tbaa !24
  %35 = and i32 %2, 2
  %36 = or i32 %34, %35
  %.not40 = icmp eq i32 %36, 0
  %37 = zext i1 %.not40 to i32
  %38 = getelementptr inbounds i8, ptr %0, i64 11428
  store i32 %37, ptr %38, align 4, !tbaa !25
  %39 = load i32, ptr %11, align 4, !tbaa !17
  %40 = and i32 %39, -3
  store i32 %40, ptr %11, align 4, !tbaa !17
  br label %41

41:                                               ; preds = %31, %18, %22, %10, %6, %3
  %.1 = phi i32 [ -1, %3 ], [ -2, %6 ], [ -3, %10 ], [ 0, %31 ], [ %21, %18 ], [ -3, %22 ]
  ret i32 %.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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 allocsize(0) }
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, !13, i64 6680}
!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 11420}
!18 = !{!6, !12, i64 6688}
!19 = !{!20, !12, i64 16}
!20 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!21 = !{!20, !12, i64 24}
!22 = !{!6, !13, i64 6752}
!23 = !{!6, !10, i64 11436}
!24 = !{!6, !10, i64 11424}
!25 = !{!6, !10, i64 11428}


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