; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (Finish)

; 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.HASH_HandleTypeDef = type { %struct.HASH_InitTypeDef, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32 }
%struct.HASH_InitTypeDef = type { i32, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @HASH_Finish(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %8, i32 0, i32 13
  %10 = load volatile i32, ptr %9, align 4, !tbaa !11
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %66

12:                                               ; preds = %3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store i32 1, ptr %4, align 4
  br label %67

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %18, i32 0, i32 12
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = icmp eq i32 %20, 1
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  store i32 2, ptr %4, align 4
  br label %67

23:                                               ; preds = %17
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %24, i32 0, i32 12
  store i32 1, ptr %25, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %23
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %28, i32 0, i32 13
  store volatile i32 2, ptr %29, align 4, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = call i32 @HASH_WaitOnFlagUntilTimeout(ptr noundef %30, i32 noundef 2, i32 noundef 0, i32 noundef %31)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  store i32 3, ptr %4, align 4
  br label %67

35:                                               ; preds = %27
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 4, !tbaa !15
  %38 = zext i32 %37 to i64
  %39 = and i64 %38, 262272
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %35
  br label %57

42:                                               ; preds = %35
  %43 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 4, !tbaa !15
  %44 = zext i32 %43 to i64
  %45 = and i64 %44, 262272
  %46 = icmp eq i64 %45, 262144
  br i1 %46, label %47, label %48

47:                                               ; preds = %42
  br label %55

48:                                               ; preds = %42
  %49 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 4, !tbaa !15
  %50 = zext i32 %49 to i64
  %51 = and i64 %50, 262272
  %52 = icmp eq i64 %51, 262272
  %53 = zext i1 %52 to i64
  %54 = select i1 %52, i32 32, i32 16
  br label %55

55:                                               ; preds = %48, %47
  %56 = phi i32 [ 28, %47 ], [ %54, %48 ]
  br label %57

57:                                               ; preds = %55, %41
  %58 = phi i32 [ 20, %41 ], [ %56, %55 ]
  %59 = trunc i32 %58 to i8
  call void @HASH_GetDigest(ptr noundef %36, i8 noundef zeroext %59)
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %60, i32 0, i32 13
  store volatile i32 1, ptr %61, align 4, !tbaa !11
  br label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %63, i32 0, i32 12
  store i32 0, ptr %64, align 8, !tbaa !14
  br label %65

65:                                               ; preds = %62
  store i32 0, ptr %4, align 4
  br label %67

66:                                               ; preds = %3
  store i32 2, ptr %4, align 4
  br label %67

67:                                               ; preds = %66, %65, %34, %22, %15
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

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

; Function Attrs: nounwind uwtable
declare hidden void @HASH_GetDigest(ptr noundef, i8 noundef zeroext) #0

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

!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, !10, i64 84}
!12 = !{!"", !13, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100}
!13 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = !{!12, !10, i64 80}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 248}


; 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, 4) i32 @HASH_Finish(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 84
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %30

7:                                                ; preds = %3
  %8 = icmp eq ptr %1, null
  br i1 %8, label %30, label %9

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %30, label %13

13:                                               ; preds = %9
  store i32 1, ptr %10, align 8, !tbaa !12
  store volatile i32 2, ptr %4, align 4, !tbaa !5
  %14 = tail call i32 @HASH_WaitOnFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef 2, i32 noundef 0, i32 noundef %2)
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %30

15:                                               ; preds = %13
  %16 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 1024, !tbaa !13
  %17 = and i32 %16, 262272
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %28, label %19

19:                                               ; preds = %15
  %20 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 1024, !tbaa !13
  %21 = and i32 %20, 262272
  %22 = icmp eq i32 %21, 262144
  br i1 %22, label %28, label %23

23:                                               ; preds = %19
  %24 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 1024, !tbaa !13
  %25 = and i32 %24, 262272
  %26 = icmp eq i32 %25, 262272
  %27 = select i1 %26, i8 32, i8 16
  br label %28

28:                                               ; preds = %23, %19, %15
  %29 = phi i8 [ 20, %15 ], [ %27, %23 ], [ 28, %19 ]
  tail call void @HASH_GetDigest(ptr noundef nonnull %1, i8 noundef zeroext %29)
  store volatile i32 1, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %10, align 8, !tbaa !12
  br label %30

30:                                               ; preds = %3, %13, %9, %7, %28
  %.0 = phi i32 [ 0, %28 ], [ 1, %7 ], [ 2, %9 ], [ 3, %13 ], [ 2, %3 ]
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden void @HASH_GetDigest(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

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

!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, !8, i64 84}
!6 = !{!"", !7, i64 0, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !8, i64 48, !8, i64 52, !8, i64 56, !8, i64 60, !8, i64 64, !8, i64 68, !11, i64 72, !8, i64 80, !8, i64 84, !8, i64 88, !8, i64 92, !8, i64 96, !8, i64 100}
!7 = !{!"", !8, i64 0, !8, i64 4, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!6, !8, i64 80}
!13 = !{!14, !8, i64 0}
!14 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !9, i64 12, !8, i64 32, !8, i64 36, !9, i64 40, !9, i64 248}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass