; LLVM IR from FrancesoM/Bisc8FX :: sdk_projects/bisc8_platform/zynq_fsbl (md5)

; 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.MD5Context = type { [4 x i32], [2 x i32], [64 x i8] }

; Function Attrs: inlinehint nounwind uwtable
declare dso_local ptr @MD5Memset(ptr noundef, i32 noundef, i32 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: inlinehint nounwind uwtable
declare dso_local ptr @MD5Memcpy(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) #0

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

; Function Attrs: inlinehint nounwind uwtable
define dso_local void @MD5Final(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i8 %2, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.MD5Context, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  %12 = load i32, ptr %11, align 4, !tbaa !10
  %13 = lshr i32 %12, 3
  %14 = and i32 %13, 63
  store i32 %14, ptr %7, align 4, !tbaa !10
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.MD5Context, ptr %15, i32 0, i32 2
  %17 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %18 = load i32, ptr %7, align 4, !tbaa !10
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i32 1
  store ptr %22, ptr %8, align 8, !tbaa !5
  store i8 -128, ptr %21, align 1, !tbaa !9
  %23 = load i32, ptr %7, align 4, !tbaa !10
  %24 = sub i32 63, %23
  store i32 %24, ptr %7, align 4, !tbaa !10
  %25 = load i32, ptr %7, align 4, !tbaa !10
  %26 = icmp ult i32 %25, 8
  br i1 %26, label %27, label %41

27:                                               ; preds = %3
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !10
  %30 = call ptr @MD5Memset(ptr noundef %28, i32 noundef 0, i32 noundef %29)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.MD5Context, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [4 x i32], ptr %32, i64 0, i64 0
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.MD5Context, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds [64 x i8], ptr %35, i64 0, i64 0
  call void @MD5Transform(ptr noundef %33, ptr noundef %36)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.MD5Context, ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds [64 x i8], ptr %38, i64 0, i64 0
  %40 = call ptr @MD5Memset(ptr noundef %39, i32 noundef 0, i32 noundef 56)
  br label %46

41:                                               ; preds = %3
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !10
  %44 = sub i32 %43, 8
  %45 = call ptr @MD5Memset(ptr noundef %42, i32 noundef 0, i32 noundef %44)
  br label %46

46:                                               ; preds = %41, %27
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.MD5Context, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds [2 x i32], ptr %48, i64 0, i64 0
  %50 = load i32, ptr %49, align 4, !tbaa !10
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MD5Context, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds [64 x i8], ptr %52, i64 0, i64 0
  %54 = getelementptr inbounds i32, ptr %53, i64 14
  store i32 %50, ptr %54, align 4, !tbaa !10
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MD5Context, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds [2 x i32], ptr %56, i64 0, i64 1
  %58 = load i32, ptr %57, align 4, !tbaa !10
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.MD5Context, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds [64 x i8], ptr %60, i64 0, i64 0
  %62 = getelementptr inbounds i32, ptr %61, i64 15
  store i32 %58, ptr %62, align 4, !tbaa !10
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MD5Context, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds [4 x i32], ptr %64, i64 0, i64 0
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MD5Context, ptr %66, i32 0, i32 2
  %68 = getelementptr inbounds [64 x i8], ptr %67, i64 0, i64 0
  call void @MD5Transform(ptr noundef %65, ptr noundef %68)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MD5Context, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds [4 x i32], ptr %71, i64 0, i64 0
  %73 = load i8, ptr %6, align 1, !tbaa !9
  %74 = call ptr @MD5Memcpy(ptr noundef %69, ptr noundef %72, i32 noundef 16, i8 noundef zeroext %73)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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: inlinehint nounwind uwtable
declare dso_local ptr @MD5Memset(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local ptr @MD5Memcpy(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @MD5Transform(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
define dso_local void @MD5Final(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = lshr i32 %5, 3
  %7 = and i32 %6, 63
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = zext nneg i32 %7 to i64
  %10 = getelementptr inbounds i8, ptr %8, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 1
  store i8 -128, ptr %10, align 1, !tbaa !9
  %12 = xor i32 %7, 63
  %13 = icmp ult i32 %12, 8
  br i1 %13, label %14, label %17

14:                                               ; preds = %3
  %15 = tail call ptr @MD5Memset(ptr noundef nonnull %11, i32 noundef 0, i32 noundef %12)
  tail call void @MD5Transform(ptr noundef nonnull %0, ptr noundef nonnull %8)
  %16 = tail call ptr @MD5Memset(ptr noundef nonnull %8, i32 noundef 0, i32 noundef 56)
  br label %20

17:                                               ; preds = %3
  %18 = sub nsw i32 55, %7
  %19 = tail call ptr @MD5Memset(ptr noundef nonnull %11, i32 noundef 0, i32 noundef %18)
  br label %20

20:                                               ; preds = %17, %14
  %21 = getelementptr inbounds i8, ptr %0, i64 80
  %22 = load <2 x i32>, ptr %4, align 4, !tbaa !5
  store <2 x i32> %22, ptr %21, align 4, !tbaa !5
  tail call void @MD5Transform(ptr noundef nonnull %0, ptr noundef nonnull %8)
  %23 = tail call ptr @MD5Memcpy(ptr noundef %1, ptr noundef nonnull %0, i32 noundef 16, i8 noundef zeroext %2)
  ret void
}

attributes #0 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


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