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

; 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.decoder = type { %struct.mp3dec_ex_t, float, [32 x [2 x float]] }
%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
declare dso_local i32 @mp3dec_ex_open(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @open_dec(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %15

8:                                                ; preds = %2
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %16, label %15

15:                                               ; preds = %11, %8, %2
  store i32 0, ptr %3, align 4
  br label %29

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %17, i8 0, i64 11720, i1 false)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.decoder, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 @mp3dec_ex_open(ptr noundef %19, ptr noundef %20, i32 noundef 1)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.decoder, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.mp3dec_ex_t, ptr %23, i32 0, i32 5
  %25 = load i64, ptr %24, align 8, !tbaa !10
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  br label %29

28:                                               ; preds = %16
  store i32 1, ptr %3, align 4
  br label %29

29:                                               ; preds = %28, %27, %15
  %30 = load i32, ptr %3, align 4
  ret i32 %30
}

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

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


; 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
declare dso_local i32 @mp3dec_ex_open(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @open_dec(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %11

5:                                                ; preds = %2
  %6 = load i8, ptr %1, align 1, !tbaa !5
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %11, label %7

7:                                                ; preds = %5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(11720) %0, i8 0, i64 11720, i1 false)
  %8 = tail call i32 @mp3dec_ex_open(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef 1)
  %9 = getelementptr inbounds i8, ptr %0, i64 6728
  %10 = load i64, ptr %9, align 8, !tbaa !8
  %.not10 = icmp ne i64 %10, 0
  %. = zext i1 %.not10 to i32
  br label %11

11:                                               ; preds = %7, %2, %5
  %.0 = phi i32 [ 0, %5 ], [ 0, %2 ], [ %., %7 ]
  ret i32 %.0
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !15, i64 6728}
!9 = !{!"decoder", !10, i64 0, !18, i64 11456, !6, i64 11460}
!10 = !{!"", !11, i64 0, !13, i64 6672, !14, 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, !6, i64 6792, !15, i64 11400, !15, 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 = !{!"", !6, i64 0, !6, i64 2304, !12, i64 6144, !12, i64 6148, !6, i64 6152, !6, i64 6156}
!12 = !{!"int", !6, i64 0}
!13 = !{!"", !14, i64 0, !15, i64 8}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!"long", !6, i64 0}
!16 = !{!"", !14, i64 0, !15, i64 8, !15, i64 16}
!17 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!18 = !{!"float", !6, i64 0}


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