; 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_frame_info_t = type { i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: 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 hidden i32 @mp3d_find_frame(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_sample_rate_hz(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_bitrate_kbps(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @mp3dec_skip_id3(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mp3dec_iterate_buf(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.mp3dec_frame_info_t, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %18, ptr %10, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %4
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = icmp eq i64 -1, %22
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %24, %21, %4
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %118

28:                                               ; preds = %24
  call void @mp3dec_skip_id3(ptr noundef %6, ptr noundef %7)
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %118

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #3
  call void @llvm.memset.p0.i64(ptr align 4 %12, i8 0, i64 24, i1 false)
  br label %33

33:                                               ; preds = %115, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = trunc i64 %35 to i32
  %37 = call i32 @mp3d_find_frame(ptr noundef %34, i32 noundef %36, ptr noundef %13, ptr noundef %14)
  store i32 %37, ptr %16, align 4, !tbaa !11
  %38 = load i32, ptr %16, align 4, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = sext i32 %38 to i64
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  store ptr %41, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %16, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = sub i64 %44, %43
  store i64 %45, ptr %7, align 8, !tbaa !9
  %46 = load i32, ptr %16, align 4, !tbaa !11
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %52

48:                                               ; preds = %33
  %49 = load i32, ptr %14, align 4, !tbaa !11
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 3, ptr %11, align 4
  br label %112

52:                                               ; preds = %48, %33
  %53 = load i32, ptr %14, align 4, !tbaa !11
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %52
  store i32 2, ptr %11, align 4
  br label %112

56:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %57, ptr %17, align 8, !tbaa !5
  %58 = load ptr, ptr %17, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 3
  %60 = load i8, ptr %59, align 1, !tbaa !13
  %61 = zext i8 %60 to i32
  %62 = and i32 %61, 192
  %63 = icmp eq i32 %62, 192
  %64 = zext i1 %63 to i64
  %65 = select i1 %63, i32 1, i32 2
  %66 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %12, i32 0, i32 2
  store i32 %65, ptr %66, align 4, !tbaa !14
  %67 = load ptr, ptr %17, align 8, !tbaa !5
  %68 = call i32 @hdr_sample_rate_hz(ptr noundef %67)
  %69 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %12, i32 0, i32 3
  store i32 %68, ptr %69, align 4, !tbaa !16
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i64 1
  %72 = load i8, ptr %71, align 1, !tbaa !13
  %73 = zext i8 %72 to i32
  %74 = ashr i32 %73, 1
  %75 = and i32 %74, 3
  %76 = sub nsw i32 4, %75
  %77 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %12, i32 0, i32 4
  store i32 %76, ptr %77, align 4, !tbaa !17
  %78 = load ptr, ptr %17, align 8, !tbaa !5
  %79 = call i32 @hdr_bitrate_kbps(ptr noundef %78)
  %80 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %12, i32 0, i32 5
  store i32 %79, ptr %80, align 4, !tbaa !18
  %81 = load i32, ptr %14, align 4, !tbaa !11
  %82 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %12, i32 0, i32 0
  store i32 %81, ptr %82, align 4, !tbaa !19
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %102

85:                                               ; preds = %56
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = load ptr, ptr %17, align 8, !tbaa !5
  %89 = load i32, ptr %14, align 4, !tbaa !11
  %90 = load i32, ptr %13, align 4, !tbaa !11
  %91 = load i64, ptr %7, align 8, !tbaa !9
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = ptrtoint ptr %92 to i64
  %95 = ptrtoint ptr %93 to i64
  %96 = sub i64 %94, %95
  %97 = call i32 %86(ptr noundef %87, ptr noundef %88, i32 noundef %89, i32 noundef %90, i64 noundef %91, i64 noundef %96, ptr noundef %12)
  store i32 %97, ptr %15, align 4, !tbaa !11
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %101

99:                                               ; preds = %85
  %100 = load i32, ptr %15, align 4, !tbaa !11
  store i32 %100, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %111

101:                                              ; preds = %85
  br label %102

102:                                              ; preds = %101, %56
  %103 = load i32, ptr %14, align 4, !tbaa !11
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = sext i32 %103 to i64
  %106 = getelementptr inbounds i8, ptr %104, i64 %105
  store ptr %106, ptr %6, align 8, !tbaa !5
  %107 = load i32, ptr %14, align 4, !tbaa !11
  %108 = sext i32 %107 to i64
  %109 = load i64, ptr %7, align 8, !tbaa !9
  %110 = sub i64 %109, %108
  store i64 %110, ptr %7, align 8, !tbaa !9
  store i32 0, ptr %11, align 4
  br label %111

111:                                              ; preds = %102, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %112

112:                                              ; preds = %111, %55, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  %113 = load i32, ptr %11, align 4
  switch i32 %113, label %117 [
    i32 0, label %114
    i32 3, label %115
    i32 2, label %116
  ]

114:                                              ; preds = %112
  br label %115

115:                                              ; preds = %114, %112
  br i1 true, label %33, label %116

116:                                              ; preds = %115, %112
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %117

117:                                              ; preds = %116, %112
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  br label %118

118:                                              ; preds = %117, %31, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %119 = load i32, ptr %5, align 4
  ret i32 %119
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 8}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!16 = !{!15, !12, i64 12}
!17 = !{!15, !12, i64 16}
!18 = !{!15, !12, i64 20}
!19 = !{!15, !12, 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"

%struct.mp3dec_frame_info_t = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 hidden i32 @mp3d_find_frame(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_sample_rate_hz(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_bitrate_kbps(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden void @mp3dec_skip_id3(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mp3dec_iterate_buf(ptr noundef %0, i64 noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.mp3dec_frame_info_t, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  %10 = icmp ne ptr %0, null
  %11 = icmp ne i64 %1, -1
  %or.cond.not26 = and i1 %10, %11
  %12 = icmp ne ptr %2, null
  %or.cond3 = and i1 %or.cond.not26, %12
  br i1 %or.cond3, label %13, label %58

13:                                               ; preds = %4
  call void @mp3dec_skip_id3(ptr noundef nonnull %5, ptr noundef nonnull %6)
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %58, label %15

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) %7, i8 0, i64 24, i1 false)
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  %17 = getelementptr inbounds i8, ptr %7, i64 12
  %18 = getelementptr inbounds i8, ptr %7, i64 16
  %19 = getelementptr inbounds i8, ptr %7, i64 20
  %20 = ptrtoint ptr %0 to i64
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %.backedge, %15
  %22 = phi i64 [ %14, %15 ], [ %.be, %.backedge ]
  %23 = phi ptr [ %.pre, %15 ], [ %.be39, %.backedge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  %24 = trunc i64 %22 to i32
  %25 = call i32 @mp3d_find_frame(ptr noundef %23, i32 noundef %24, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = sext i32 %25 to i64
  %28 = getelementptr inbounds i8, ptr %26, i64 %27
  store ptr %28, ptr %5, align 8, !tbaa !5
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = sub i64 %29, %27
  store i64 %30, ptr %6, align 8, !tbaa !9
  %31 = load i32, ptr %9, align 4
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %57, label %33

33:                                               ; preds = %21
  %34 = getelementptr inbounds i8, ptr %28, i64 3
  %35 = load i8, ptr %34, align 1, !tbaa !13
  %36 = icmp ugt i8 %35, -65
  %37 = select i1 %36, i32 1, i32 2
  store i32 %37, ptr %16, align 4, !tbaa !14
  %38 = call i32 @hdr_sample_rate_hz(ptr noundef %28)
  store i32 %38, ptr %17, align 4, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %28, i64 1
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = lshr i8 %40, 1
  %42 = and i8 %41, 3
  %narrow = sub nuw nsw i8 4, %42
  %43 = zext nneg i8 %narrow to i32
  store i32 %43, ptr %18, align 4, !tbaa !17
  %44 = call i32 @hdr_bitrate_kbps(ptr noundef %28)
  store i32 %44, ptr %19, align 4, !tbaa !18
  %45 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %45, ptr %7, align 4, !tbaa !19
  %46 = load i32, ptr %8, align 4, !tbaa !11
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = ptrtoint ptr %28 to i64
  %49 = sub i64 %48, %20
  %50 = call i32 %2(ptr noundef %3, ptr noundef %28, i32 noundef %45, i32 noundef %46, i64 noundef %47, i64 noundef %49, ptr noundef nonnull %7) #3
  %.not27 = icmp eq i32 %50, 0
  br i1 %.not27, label %.thread, label %.thread32

.thread32:                                        ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  br label %.loopexit

.thread:                                          ; preds = %33
  %51 = load i32, ptr %9, align 4, !tbaa !11
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = sext i32 %51 to i64
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  store ptr %54, ptr %5, align 8, !tbaa !5
  %55 = load i64, ptr %6, align 8, !tbaa !9
  %56 = sub i64 %55, %53
  store i64 %56, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  br label %.backedge

57:                                               ; preds = %21
  %.not38 = icmp eq i32 %25, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  br i1 %.not38, label %.loopexit, label %.backedge

.backedge:                                        ; preds = %57, %.thread
  %.be = phi i64 [ %30, %57 ], [ %56, %.thread ]
  %.be39 = phi ptr [ %28, %57 ], [ %54, %.thread ]
  br label %21

.loopexit:                                        ; preds = %57, %.thread32
  %.3 = phi i32 [ %50, %.thread32 ], [ 0, %57 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  br label %58

58:                                               ; preds = %13, %4, %.loopexit
  %.4 = phi i32 [ %.3, %.loopexit ], [ -1, %4 ], [ 0, %13 ]
  ret i32 %.4
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 8}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!16 = !{!15, !12, i64 12}
!17 = !{!15, !12, i64 16}
!18 = !{!15, !12, i64 20}
!19 = !{!15, !12, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass