; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/flac-src/src/test_libFLAC++ (decoders)

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

%class.DecoderCommon = type <{ ptr, i32, i32, i8, i8, [6 x i8] }>
%class.StreamDecoder = type { %"class.FLAC::Decoder::Stream", %class.DecoderCommon.base, ptr }
%"class.FLAC::Decoder::Stream" = type { ptr, ptr }
%class.DecoderCommon.base = type <{ ptr, i32, i32, i8, i8 }>

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN13StreamDecoder13read_callbackEPhPm(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %12, ptr %8, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %10, i64 16
  %14 = getelementptr inbounds %class.DecoderCommon, ptr %13, i32 0, i32 4
  %15 = load i8, ptr %14, align 1, !tbaa !11, !range !16, !noundef !17
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i32 2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

18:                                               ; preds = %3
  %19 = getelementptr inbounds %class.StreamDecoder, ptr %10, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = call i32 @feof(ptr noundef %20) #4
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %18
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %24, align 8, !tbaa !9
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

25:                                               ; preds = %18
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = icmp ugt i64 %26, 0
  br i1 %27, label %28, label %46

28:                                               ; preds = %25
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = getelementptr inbounds %class.StreamDecoder, ptr %10, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = call i64 @fread(ptr noundef %29, i64 noundef 1, i64 noundef %30, ptr noundef %32)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %33, ptr %34, align 8, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %38, label %45

38:                                               ; preds = %28
  %39 = getelementptr inbounds %class.StreamDecoder, ptr %10, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = call i32 @feof(ptr noundef %40) #4
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

44:                                               ; preds = %38
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

45:                                               ; preds = %28
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

46:                                               ; preds = %25
  store i32 2, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %47

47:                                               ; preds = %46, %45, %44, %43, %23, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %48 = load i32, ptr %4, align 4
  ret i32 %48
}

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

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #2

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

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

attributes #0 = { mustprogress 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 = { 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 = { "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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !15, i64 17}
!12 = !{!"_ZTS13DecoderCommon", !13, i64 8, !14, i64 12, !15, i64 16, !15, i64 17}
!13 = !{!"_ZTS5Layer", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!19, !6, i64 40}
!19 = !{!"_ZTS13StreamDecoder", !20, i64 0, !12, i64 16, !6, i64 40}
!20 = !{!"_ZTSN4FLAC7Decoder6StreamE", !6, i64 8}


; 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 nofree nounwind uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZN13StreamDecoder13read_callbackEPhPm(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, ptr nocapture noundef %1, ptr nocapture noundef %2) unnamed_addr #0 align 2 {
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 33
  %6 = load i8, ptr %5, align 1, !tbaa !9, !range !14, !noundef !15
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %21, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %11 = tail call i32 @feof(ptr noundef %10) #2
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %8
  store i64 0, ptr %2, align 8, !tbaa !5
  br label %21

13:                                               ; preds = %8
  %.not9 = icmp eq i64 %4, 0
  br i1 %.not9, label %21, label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr %9, align 8, !tbaa !16
  %16 = tail call i64 @fread(ptr noundef %1, i64 noundef 1, i64 noundef %4, ptr noundef %15)
  store i64 %16, ptr %2, align 8, !tbaa !5
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = load ptr, ptr %9, align 8, !tbaa !16
  %20 = tail call i32 @feof(ptr noundef %19) #2
  %.not10 = icmp ne i32 %20, 0
  %. = zext i1 %.not10 to i32
  br label %21

21:                                               ; preds = %13, %14, %18, %3, %12
  %.0 = phi i32 [ 1, %12 ], [ 2, %3 ], [ %., %18 ], [ 0, %14 ], [ 2, %13 ]
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nofree 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 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 17}
!10 = !{!"_ZTS13DecoderCommon", !11, i64 8, !12, i64 12, !13, i64 16, !13, i64 17}
!11 = !{!"_ZTS5Layer", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !19, i64 40}
!17 = !{!"_ZTS13StreamDecoder", !18, i64 0, !10, i64 16, !19, i64 40}
!18 = !{!"_ZTSN4FLAC7Decoder6StreamE", !19, i64 8}
!19 = !{!"any pointer", !7, i64 0}


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