; 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: 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 uwtable
declare dso_local i32 @mp3dec_iterate_buf(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #0

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

14:                                               ; preds = %4
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %24

17:                                               ; preds = %14
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = icmp eq i64 -1, %18
  br i1 %19, label %24, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %9, align 4, !tbaa !11
  %22 = and i32 %21, -8
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %20, %17, %14, %4
  store i32 -1, ptr %5, align 4
  br label %81

25:                                               ; preds = %20
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %26, i8 0, i64 11456, i1 false)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %29, i32 0, i32 0
  store ptr %27, ptr %30, align 8, !tbaa !13
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %33, i32 0, i32 1
  store i64 %31, ptr %34, align 8, !tbaa !19
  %35 = load i32, ptr %9, align 4, !tbaa !11
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %36, i32 0, i32 15
  store i32 %35, ptr %37, align 4, !tbaa !20
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %38, i32 0, i32 0
  call void @mp3dec_init(ptr noundef %39)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds %struct.mp3dec_map_info_t, ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !19
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call i32 @mp3dec_iterate_buf(ptr noundef %43, i64 noundef %47, ptr noundef @mp3dec_load_index, ptr noundef %48)
  store i32 %49, ptr %10, align 4, !tbaa !11
  %50 = load i32, ptr %10, align 4, !tbaa !11
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %25
  %53 = load i32, ptr %10, align 4, !tbaa !11
  %54 = icmp ne i32 -4, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %52
  %56 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %56, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %80

57:                                               ; preds = %52, %25
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %58, i32 0, i32 0
  call void @mp3dec_init(ptr noundef %59)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %60, i32 0, i32 19
  store i32 0, ptr %61, align 4, !tbaa !21
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %62, i32 0, i32 16
  %64 = load i32, ptr %63, align 8, !tbaa !22
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %70, label %66

66:                                               ; preds = %57
  %67 = load i32, ptr %9, align 4, !tbaa !11
  %68 = and i32 %67, 2
  %69 = icmp ne i32 %68, 0
  br label %70

70:                                               ; preds = %66, %57
  %71 = phi i1 [ true, %57 ], [ %69, %66 ]
  %72 = xor i1 %71, true
  %73 = zext i1 %72 to i32
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %74, i32 0, i32 17
  store i32 %73, ptr %75, align 4, !tbaa !23
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %76, i32 0, i32 15
  %78 = load i32, ptr %77, align 4, !tbaa !20
  %79 = and i32 %78, -3
  store i32 %79, ptr %77, align 4, !tbaa !20
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %80

80:                                               ; preds = %70, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %81

81:                                               ; preds = %80, %24
  %82 = load i32, ptr %5, align 4
  ret i32 %82
}

; 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

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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 6672}
!14 = !{!"", !15, i64 0, !16, i64 6672, !6, i64 6688, !17, i64 6696, !10, i64 6720, !10, i64 6728, !10, i64 6736, !10, i64 6744, !10, i64 6752, !10, i64 6760, !18, i64 6768, !7, i64 6792, !10, i64 11400, !10, 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}
!15 = !{!"", !7, i64 0, !7, i64 2304, !12, i64 6144, !12, i64 6148, !7, i64 6152, !7, i64 6156}
!16 = !{!"", !6, i64 0, !10, i64 8}
!17 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!19 = !{!14, !10, i64 6680}
!20 = !{!14, !12, i64 11420}
!21 = !{!14, !12, i64 11436}
!22 = !{!14, !12, i64 11424}
!23 = !{!14, !12, 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: nounwind uwtable
declare dso_local i32 @mp3dec_iterate_buf(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @mp3dec_ex_open_buf(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %1, null
  %or.cond.not32.not38 = and i1 %5, %6
  %7 = icmp ne i64 %2, -1
  %or.cond3.not35 = and i1 %or.cond.not32.not38, %7
  %.not = icmp ult i32 %3, 8
  %or.cond = and i1 %or.cond3.not35, %.not
  br i1 %or.cond, label %8, label %25

8:                                                ; preds = %4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(11456) %0, i8 0, i64 11456, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 6672
  store ptr %1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 6680
  store i64 %2, ptr %10, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 11420
  store i32 %3, ptr %11, align 4, !tbaa !17
  tail call void @mp3dec_init(ptr noundef nonnull %0)
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = load i64, ptr %10, align 8, !tbaa !16
  %14 = tail call i32 @mp3dec_iterate_buf(ptr noundef %12, i64 noundef %13, ptr noundef nonnull @mp3dec_load_index, ptr noundef nonnull %0)
  switch i32 %14, label %25 [
    i32 -4, label %15
    i32 0, label %15
  ]

15:                                               ; preds = %8, %8
  tail call void @mp3dec_init(ptr noundef nonnull %0)
  %16 = getelementptr inbounds i8, ptr %0, i64 11436
  store i32 0, ptr %16, align 4, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 11424
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %19 = and i32 %3, 2
  %20 = or i32 %18, %19
  %.not33 = icmp eq i32 %20, 0
  %21 = zext i1 %.not33 to i32
  %22 = getelementptr inbounds i8, ptr %0, i64 11428
  store i32 %21, ptr %22, align 4, !tbaa !20
  %23 = load i32, ptr %11, align 4, !tbaa !17
  %24 = and i32 %23, -3
  store i32 %24, ptr %11, align 4, !tbaa !17
  br label %25

25:                                               ; preds = %15, %8, %4
  %.1 = phi i32 [ -1, %4 ], [ 0, %15 ], [ %14, %8 ]
  ret i32 %.1
}

; 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

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) }

!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 6672}
!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, !13, i64 6680}
!17 = !{!6, !10, i64 11420}
!18 = !{!6, !10, i64 11436}
!19 = !{!6, !10, i64 11424}
!20 = !{!6, !10, i64 11428}


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