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

; 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_Accumulate(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %14, i32 0, i32 13
  %16 = load volatile i32, ptr %15, align 4, !tbaa !11
  store i32 %16, ptr %12, align 4, !tbaa !9
  %17 = load i32, ptr %12, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %22, label %19

19:                                               ; preds = %4
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 8
  br i1 %21, label %22, label %107

22:                                               ; preds = %19, %4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %25, %22
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %29, i32 0, i32 13
  store volatile i32 1, ptr %30, align 4, !tbaa !11
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %108

31:                                               ; preds = %25
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %33, i32 0, i32 12
  %35 = load i32, ptr %34, align 8, !tbaa !14
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store i32 2, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %108

38:                                               ; preds = %32
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %39, i32 0, i32 12
  store i32 1, ptr %40, align 8, !tbaa !14
  br label %41

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %44, i32 0, i32 13
  %46 = load volatile i32, ptr %45, align 4, !tbaa !11
  %47 = icmp eq i32 %46, 8
  br i1 %47, label %48, label %57

48:                                               ; preds = %43
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %49, i32 0, i32 13
  store volatile i32 2, ptr %50, align 4, !tbaa !11
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  store ptr %53, ptr %10, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %54, i32 0, i32 6
  %56 = load volatile i32, ptr %55, align 4, !tbaa !16
  store i32 %56, ptr %11, align 4, !tbaa !9
  br label %78

57:                                               ; preds = %43
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %58, i32 0, i32 13
  store volatile i32 2, ptr %59, align 4, !tbaa !11
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %60, ptr %10, align 8, !tbaa !5
  %61 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %61, ptr %11, align 4, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %62, i32 0, i32 10
  %64 = load i32, ptr %63, align 4, !tbaa !17
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %66, label %75

66:                                               ; preds = %57
  %67 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 4, !tbaa !18
  %68 = zext i32 %67 to i64
  %69 = and i64 %68, -327877
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = or i64 %71, 4
  %73 = or i64 %69, %72
  %74 = trunc i64 %73 to i32
  store volatile i32 %74, ptr inttoptr (i64 1208095744 to ptr), align 4, !tbaa !18
  br label %75

75:                                               ; preds = %66, %57
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %76, i32 0, i32 10
  store i32 2, ptr %77, align 4, !tbaa !17
  br label %78

78:                                               ; preds = %75, %48
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = call i32 @HASH_WriteData(ptr noundef %79, ptr noundef %80, i32 noundef %81)
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %83, i32 0, i32 9
  store i32 %82, ptr %84, align 8, !tbaa !20
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %85, i32 0, i32 9
  %87 = load i32, ptr %86, align 8, !tbaa !20
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %93

89:                                               ; preds = %78
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %90, i32 0, i32 9
  %92 = load i32, ptr %91, align 8, !tbaa !20
  store i32 %92, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %108

93:                                               ; preds = %78
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %94, i32 0, i32 13
  %96 = load volatile i32, ptr %95, align 4, !tbaa !11
  %97 = icmp ne i32 %96, 8
  br i1 %97, label %98, label %101

98:                                               ; preds = %93
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %99, i32 0, i32 13
  store volatile i32 1, ptr %100, align 4, !tbaa !11
  br label %101

101:                                              ; preds = %98, %93
  br label %102

102:                                              ; preds = %101
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.HASH_HandleTypeDef, ptr %103, i32 0, i32 12
  store i32 0, ptr %104, align 8, !tbaa !14
  br label %105

105:                                              ; preds = %102
  br label %106

106:                                              ; preds = %105
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %108

107:                                              ; preds = %19
  store i32 2, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %108

108:                                              ; preds = %107, %106, %89, %37, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %109 = load i32, ptr %5, align 4
  ret i32 %109
}

; 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
declare hidden i32 @HASH_WriteData(ptr noundef, ptr noundef, i32 noundef) #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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{!12, !6, i64 16}
!16 = !{!12, !10, i64 52}
!17 = !{!12, !10, i64 68}
!18 = !{!19, !10, i64 0}
!19 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 248}
!20 = !{!12, !10, i64 64}


; 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 i32 @HASH_Accumulate(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 84
  %6 = load volatile i32, ptr %5, align 4, !tbaa !5
  switch i32 %6, label %40 [
    i32 8, label %7
    i32 1, label %7
  ]

7:                                                ; preds = %4, %4
  %8 = icmp eq ptr %1, null
  %9 = icmp eq i32 %2, 0
  %or.cond3 = or i1 %8, %9
  br i1 %or.cond3, label %10, label %11

10:                                               ; preds = %7
  store volatile i32 1, ptr %5, align 4, !tbaa !5
  br label %40

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

15:                                               ; preds = %11
  store i32 1, ptr %12, align 8, !tbaa !12
  %16 = load volatile i32, ptr %5, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 8
  store volatile i32 2, ptr %5, align 4, !tbaa !5
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %0, i64 52
  %22 = load volatile i32, ptr %21, align 4, !tbaa !14
  br label %33

23:                                               ; preds = %15
  %24 = getelementptr inbounds i8, ptr %0, i64 68
  %25 = load i32, ptr %24, align 4, !tbaa !15
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %32

27:                                               ; preds = %23
  %28 = load volatile i32, ptr inttoptr (i64 1208095744 to ptr), align 1024, !tbaa !16
  %29 = and i32 %28, -327877
  %30 = or i32 %29, %3
  %31 = or i32 %30, 4
  store volatile i32 %31, ptr inttoptr (i64 1208095744 to ptr), align 1024, !tbaa !16
  br label %32

32:                                               ; preds = %27, %23
  store i32 2, ptr %24, align 4, !tbaa !15
  br label %33

33:                                               ; preds = %32, %18
  %.031 = phi ptr [ %20, %18 ], [ %1, %32 ]
  %.030 = phi i32 [ %22, %18 ], [ %2, %32 ]
  %34 = tail call i32 @HASH_WriteData(ptr noundef nonnull %0, ptr noundef %.031, i32 noundef %.030)
  %35 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %34, ptr %35, align 8, !tbaa !18
  %.not = icmp eq i32 %34, 0
  br i1 %.not, label %36, label %40

36:                                               ; preds = %33
  %37 = load volatile i32, ptr %5, align 4, !tbaa !5
  %.not35 = icmp eq i32 %37, 8
  br i1 %.not35, label %39, label %38

38:                                               ; preds = %36
  store volatile i32 1, ptr %5, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %36, %38
  store i32 0, ptr %12, align 8, !tbaa !12
  br label %40

40:                                               ; preds = %4, %33, %11, %39, %10
  %.0 = phi i32 [ 1, %10 ], [ 0, %39 ], [ 2, %11 ], [ %34, %33 ], [ 2, %4 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @HASH_WriteData(ptr noundef, ptr noundef, i32 noundef) 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 = !{!6, !11, i64 16}
!14 = !{!6, !8, i64 52}
!15 = !{!6, !8, i64 68}
!16 = !{!17, !8, i64 0}
!17 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !9, i64 12, !8, i64 32, !8, i64 36, !9, i64 40, !9, i64 248}
!18 = !{!6, !8, i64 64}


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