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

; 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_t = type { [2 x [288 x float]], [960 x float], i32, i32, [4 x i8], [511 x i8] }
%struct.mp3dec_frame_info_t = type { i32, i32, i32, i32, i32, i32 }

@main.mp3d = external hidden global %struct.mp3dec_t, align 4
@stdin = external global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @mp3dec_init(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp3dec_decode_frame(ptr noundef, ptr noundef, i32 noundef, ptr noundef, 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.mp3dec_frame_info_t, align 4
  %3 = alloca [4096 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca [2304 x i16], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4096, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @mp3dec_init(ptr noundef @main.mp3d)
  br label %6

6:                                                ; preds = %28, %0
  call void @llvm.lifetime.start.p0(i64 4608, ptr %5) #3
  %7 = getelementptr inbounds [4096 x i8], ptr %3, i64 0, i64 0
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i8, ptr %7, i64 %9
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = sub i64 4096, %12
  %14 = load ptr, ptr @stdin, align 8, !tbaa !9
  %15 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef %13, ptr noundef %14)
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = add i64 %17, %15
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %4, align 4, !tbaa !5
  %20 = getelementptr inbounds [4096 x i8], ptr %3, i64 0, i64 0
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = getelementptr inbounds [2304 x i16], ptr %5, i64 0, i64 0
  %23 = call i32 @mp3dec_decode_frame(ptr noundef @main.mp3d, ptr noundef %20, i32 noundef %21, ptr noundef %22, ptr noundef %2)
  %24 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %2, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sub nsw i32 %26, %25
  store i32 %27, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4608, ptr %5) #3
  br label %28

28:                                               ; preds = %6
  %29 = getelementptr inbounds %struct.mp3dec_frame_info_t, ptr %2, i32 0, i32 0
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %6, label %32, !llvm.loop !13

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4096, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %2) #3
  ret i32 0
}

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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_t = type { [2 x [288 x float]], [960 x float], i32, i32, [4 x i8], [511 x i8] }
%struct.mp3dec_frame_info_t = type { i32, i32, i32, i32, i32, i32 }

@main.mp3d = external hidden global %struct.mp3dec_t, align 4
@stdin = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @mp3dec_init(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.mp3dec_frame_info_t, align 4
  %2 = alloca [4096 x i8], align 16
  %3 = alloca [2304 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %2) #3
  tail call void @mp3dec_init(ptr noundef nonnull @main.mp3d)
  br label %4

4:                                                ; preds = %4, %0
  %.0 = phi i32 [ 0, %0 ], [ %14, %4 ]
  call void @llvm.lifetime.start.p0(i64 4608, ptr nonnull %3) #3
  %5 = sext i32 %.0 to i64
  %6 = getelementptr inbounds i8, ptr %2, i64 %5
  %7 = sub nsw i64 4096, %5
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = call i64 @fread(ptr noundef nonnull %6, i64 noundef 1, i64 noundef %7, ptr noundef %8)
  %10 = trunc i64 %9 to i32
  %11 = add i32 %.0, %10
  %12 = call i32 @mp3dec_decode_frame(ptr noundef nonnull @main.mp3d, ptr noundef nonnull %2, i32 noundef %11, ptr noundef nonnull %3, ptr noundef nonnull %1)
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = sub nsw i32 %11, %13
  call void @llvm.lifetime.end.p0(i64 4608, ptr nonnull %3) #3
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %15, label %4, !llvm.loop !12

15:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #3
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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