; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/flac-src/src/libFLAC/md5.ll_FLAC (MD5Accumulate)

; 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.FLAC__MD5Context = type { [16 x i32], [4 x i32], [2 x i32], %union.FLAC__multibyte, i64 }
%union.FLAC__multibyte = type { ptr }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @FLAC__MD5Accumulate(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = mul i64 %15, %17
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = mul i64 %18, %20
  store i64 %21, ptr %12, align 8, !tbaa !11
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = udiv i64 -1, %25
  %27 = icmp ugt i64 %23, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %82

29:                                               ; preds = %5
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = mul i64 %31, %33
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = udiv i64 -1, %36
  %38 = icmp ugt i64 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %29
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %82

40:                                               ; preds = %29
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %41, i32 0, i32 4
  %43 = load i64, ptr %42, align 8, !tbaa !13
  %44 = load i64, ptr %12, align 8, !tbaa !11
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %46, label %69

46:                                               ; preds = %40
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %47, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = load i64, ptr %12, align 8, !tbaa !11
  %51 = call ptr @safe_realloc_(ptr noundef %49, i64 noundef %50)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %52, i32 0, i32 3
  store ptr %51, ptr %53, align 8, !tbaa !15
  %54 = icmp eq ptr null, %51
  br i1 %54, label %55, label %65

55:                                               ; preds = %46
  %56 = load i64, ptr %12, align 8, !tbaa !11
  %57 = call ptr @safe_malloc_(i64 noundef %56)
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %58, i32 0, i32 3
  store ptr %57, ptr %59, align 8, !tbaa !15
  %60 = icmp eq ptr null, %57
  br i1 %60, label %61, label %64

61:                                               ; preds = %55
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %62, i32 0, i32 4
  store i64 0, ptr %63, align 8, !tbaa !13
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %82

64:                                               ; preds = %55
  br label %65

65:                                               ; preds = %64, %46
  %66 = load i64, ptr %12, align 8, !tbaa !11
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %67, i32 0, i32 4
  store i64 %66, ptr %68, align 8, !tbaa !13
  br label %69

69:                                               ; preds = %65, %40
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = load i32, ptr %11, align 4, !tbaa !9
  call void @format_input_(ptr noundef %71, ptr noundef %72, i32 noundef %73, i32 noundef %74, i32 noundef %75)
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.FLAC__MD5Context, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  %80 = load i64, ptr %12, align 8, !tbaa !11
  %81 = trunc i64 %80 to i32
  call void @FLAC__MD5Update(ptr noundef %76, ptr noundef %79, i32 noundef %81)
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %82

82:                                               ; preds = %69, %61, %39, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %83 = load i32, ptr %6, align 4
  ret i32 %83
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @safe_realloc_(ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @safe_malloc_(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @format_input_(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @FLAC__MD5Update(ptr noundef, ptr noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { inlinehint 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 96}
!14 = !{!"", !7, i64 0, !7, i64 64, !7, i64 80, !7, i64 88, !12, i64 96}
!15 = !{!7, !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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @FLAC__MD5Accumulate(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = zext i32 %2 to i64
  %7 = zext i32 %3 to i64
  %8 = zext i32 %4 to i64
  %9 = mul nuw i64 %8, %6
  %10 = mul i64 %9, %7
  %mul = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %7, i64 %9)
  %mul.ov = extractvalue { i64, i1 } %mul, 1
  br i1 %mul.ov, label %29, label %11

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = icmp ult i64 %13, %10
  br i1 %14, label %15, label %25

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %0, i64 88
  %17 = load ptr, ptr %16, align 8, !tbaa !10
  %18 = tail call ptr @safe_realloc_(ptr noundef %17, i64 noundef %10)
  store ptr %18, ptr %16, align 8, !tbaa !10
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = tail call ptr @safe_malloc_(i64 noundef %10)
  store ptr %21, ptr %16, align 8, !tbaa !10
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %29

24:                                               ; preds = %20, %15
  store i64 %10, ptr %12, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %24, %11
  %26 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @format_input_(ptr noundef nonnull %26, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4)
  %27 = load ptr, ptr %26, align 8, !tbaa !10
  %28 = trunc i64 %10 to i32
  tail call void @FLAC__MD5Update(ptr noundef nonnull %0, ptr noundef %27, i32 noundef %28)
  br label %29

29:                                               ; preds = %5, %25, %23
  %.0 = phi i32 [ 0, %23 ], [ 1, %25 ], [ 0, %5 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @safe_realloc_(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @safe_malloc_(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @format_input_(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @FLAC__MD5Update(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #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 = { inlinehint 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !9, i64 96}
!6 = !{!"", !7, i64 0, !7, i64 64, !7, i64 80, !7, i64 88, !9, i64 96}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!7, !7, i64 0}


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