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

; 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.CRC_HandleTypeDef = type { ptr, %struct.CRC_InitTypeDef, i32, i32, i32 }
%struct.CRC_InitTypeDef = type { i8, i8, i32, i32, i32, i32, i32 }
%struct.CRC_TypeDef = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_CRC_Init(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  br label %117

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %8, i32 0, i32 3
  %10 = load volatile i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %7
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %13, i32 0, i32 2
  store i32 0, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @HAL_CRC_MspInit(ptr noundef %15)
  br label %16

16:                                               ; preds = %12, %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %17, i32 0, i32 3
  store volatile i32 2, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %20, i32 0, i32 0
  %22 = load i8, ptr %21, align 8, !tbaa !14
  %23 = zext i8 %22 to i32
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %43

25:                                               ; preds = %16
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds %struct.CRC_TypeDef, ptr %28, i32 0, i32 5
  store volatile i32 79764919, ptr %29, align 4, !tbaa !16
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = getelementptr inbounds %struct.CRC_TypeDef, ptr %32, i32 0, i32 2
  %34 = load volatile i32, ptr %33, align 4, !tbaa !18
  %35 = zext i32 %34 to i64
  %36 = and i64 %35, -25
  %37 = or i64 %36, 0
  %38 = trunc i64 %37 to i32
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = getelementptr inbounds %struct.CRC_TypeDef, ptr %41, i32 0, i32 2
  store volatile i32 %38, ptr %42, align 4, !tbaa !18
  br label %57

43:                                               ; preds = %16
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !19
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 8, !tbaa !20
  %53 = call i32 @HAL_CRCEx_Polynomial_Set(ptr noundef %44, i32 noundef %48, i32 noundef %52)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %43
  store i32 1, ptr %2, align 4
  br label %117

56:                                               ; preds = %43
  br label %57

57:                                               ; preds = %56, %25
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %59, i32 0, i32 1
  %61 = load i8, ptr %60, align 1, !tbaa !21
  %62 = zext i8 %61 to i32
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %57
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = getelementptr inbounds %struct.CRC_TypeDef, ptr %67, i32 0, i32 4
  store volatile i32 -1, ptr %68, align 4, !tbaa !22
  br label %78

69:                                               ; preds = %57
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 4, !tbaa !23
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !15
  %77 = getelementptr inbounds %struct.CRC_TypeDef, ptr %76, i32 0, i32 4
  store volatile i32 %73, ptr %77, align 4, !tbaa !22
  br label %78

78:                                               ; preds = %69, %64
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = getelementptr inbounds %struct.CRC_TypeDef, ptr %81, i32 0, i32 2
  %83 = load volatile i32, ptr %82, align 4, !tbaa !18
  %84 = zext i32 %83 to i64
  %85 = and i64 %84, -97
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %86, i32 0, i32 1
  %88 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %87, i32 0, i32 5
  %89 = load i32, ptr %88, align 8, !tbaa !24
  %90 = zext i32 %89 to i64
  %91 = or i64 %85, %90
  %92 = trunc i64 %91 to i32
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !15
  %96 = getelementptr inbounds %struct.CRC_TypeDef, ptr %95, i32 0, i32 2
  store volatile i32 %92, ptr %96, align 4, !tbaa !18
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !15
  %100 = getelementptr inbounds %struct.CRC_TypeDef, ptr %99, i32 0, i32 2
  %101 = load volatile i32, ptr %100, align 4, !tbaa !18
  %102 = zext i32 %101 to i64
  %103 = and i64 %102, -129
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %104, i32 0, i32 1
  %106 = getelementptr inbounds %struct.CRC_InitTypeDef, ptr %105, i32 0, i32 6
  %107 = load i32, ptr %106, align 4, !tbaa !25
  %108 = zext i32 %107 to i64
  %109 = or i64 %103, %108
  %110 = trunc i64 %109 to i32
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %111, i32 0, i32 0
  %113 = load ptr, ptr %112, align 8, !tbaa !15
  %114 = getelementptr inbounds %struct.CRC_TypeDef, ptr %113, i32 0, i32 2
  store volatile i32 %110, ptr %114, align 4, !tbaa !18
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.CRC_HandleTypeDef, ptr %115, i32 0, i32 3
  store volatile i32 1, ptr %116, align 4, !tbaa !9
  store i32 0, ptr %2, align 4
  br label %117

117:                                              ; preds = %78, %55, %6
  %118 = load i32, ptr %2, align 4
  ret i32 %118
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_CRC_MspInit(ptr noundef) #0

declare i32 @HAL_CRCEx_Polynomial_Set(ptr noundef, i32 noundef, i32 noundef) #1

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 = { "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, !12, i64 36}
!10 = !{!"", !6, i64 0, !11, i64 8, !12, i64 32, !12, i64 36, !12, i64 40}
!11 = !{!"", !7, i64 0, !7, i64 1, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 32}
!14 = !{!10, !7, i64 8}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !12, i64 20}
!17 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!18 = !{!17, !12, i64 8}
!19 = !{!10, !12, i64 12}
!20 = !{!10, !12, i64 16}
!21 = !{!10, !7, i64 9}
!22 = !{!17, !12, i64 16}
!23 = !{!10, !12, i64 20}
!24 = !{!10, !12, i64 24}
!25 = !{!10, !12, i64 28}


; 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 @HAL_CRC_Init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %46, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 36
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %8, align 8, !tbaa !12
  tail call void @HAL_CRC_MspInit(ptr noundef nonnull %0)
  br label %9

9:                                                ; preds = %7, %3
  store volatile i32 2, ptr %4, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i8, ptr %10, align 8, !tbaa !13
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %13, label %19

13:                                               ; preds = %9
  %14 = load ptr, ptr %0, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %14, i64 20
  store volatile i32 79764919, ptr %15, align 4, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %14, i64 8
  %17 = load volatile i32, ptr %16, align 4, !tbaa !17
  %18 = and i32 %17, -25
  store volatile i32 %18, ptr %16, align 4, !tbaa !17
  br label %25

19:                                               ; preds = %9
  %20 = getelementptr inbounds i8, ptr %0, i64 12
  %21 = load i32, ptr %20, align 4, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = tail call i32 @HAL_CRCEx_Polynomial_Set(ptr noundef nonnull %0, i32 noundef %21, i32 noundef %23) #2
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %25, label %46

25:                                               ; preds = %19, %13
  %26 = getelementptr inbounds i8, ptr %0, i64 9
  %27 = load i8, ptr %26, align 1, !tbaa !20
  %28 = icmp eq i8 %27, 0
  br i1 %28, label %32, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 20
  %31 = load i32, ptr %30, align 4, !tbaa !21
  br label %32

32:                                               ; preds = %25, %29
  %.sink = phi i32 [ %31, %29 ], [ -1, %25 ]
  %33 = load ptr, ptr %0, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  store volatile i32 %.sink, ptr %34, align 4, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %33, i64 8
  %36 = load volatile i32, ptr %35, align 4, !tbaa !17
  %37 = and i32 %36, -97
  %38 = getelementptr inbounds i8, ptr %0, i64 24
  %39 = load i32, ptr %38, align 8, !tbaa !23
  %40 = or i32 %37, %39
  store volatile i32 %40, ptr %35, align 4, !tbaa !17
  %41 = load volatile i32, ptr %35, align 4, !tbaa !17
  %42 = and i32 %41, -129
  %43 = getelementptr inbounds i8, ptr %0, i64 28
  %44 = load i32, ptr %43, align 4, !tbaa !24
  %45 = or i32 %42, %44
  store volatile i32 %45, ptr %35, align 4, !tbaa !17
  store volatile i32 1, ptr %4, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %19, %1, %32
  %.0 = phi i32 [ 0, %32 ], [ 1, %1 ], [ 1, %19 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_CRC_MspInit(ptr noundef) local_unnamed_addr #0

declare i32 @HAL_CRCEx_Polynomial_Set(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { "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, !11, i64 36}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 32, !11, i64 36, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !8, i64 0, !8, i64 1, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 32}
!13 = !{!6, !8, i64 8}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !11, i64 20}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!17 = !{!16, !11, i64 8}
!18 = !{!6, !11, i64 12}
!19 = !{!6, !11, i64 16}
!20 = !{!6, !8, i64 9}
!21 = !{!6, !11, i64 20}
!22 = !{!16, !11, i64 16}
!23 = !{!6, !11, i64 24}
!24 = !{!6, !11, i64 28}


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