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

; 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.SWPMI_HandleTypeDef = type { ptr, %struct.SWPMI_InitTypeDef, ptr, i32, i32, ptr, i32, i32, ptr, ptr, i32, i32, i32 }
%struct.SWPMI_InitTypeDef = type { i32, i32, i32, i32 }
%struct.SWPMI_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; 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 @HAL_SWPMI_Receive_IT(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i16 %2, ptr %7, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %17, label %13

13:                                               ; preds = %3
  %14 = load i16, ptr %7, align 2, !tbaa !9
  %15 = zext i16 %14 to i32
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %13, %3
  store i32 1, ptr %8, align 4, !tbaa !11
  br label %90

18:                                               ; preds = %13
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %20, i32 0, i32 10
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store i32 2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %92

25:                                               ; preds = %19
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %26, i32 0, i32 10
  store i32 1, ptr %27, align 8, !tbaa !13
  br label %28

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %31, i32 0, i32 11
  %33 = load volatile i32, ptr %32, align 4, !tbaa !16
  store i32 %33, ptr %9, align 4, !tbaa !11
  %34 = load i32, ptr %9, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %39, label %36

36:                                               ; preds = %30
  %37 = load i32, ptr %9, align 4, !tbaa !11
  %38 = icmp eq i32 %37, 18
  br i1 %38, label %39, label %83

39:                                               ; preds = %36, %30
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %41, i32 0, i32 5
  store ptr %40, ptr %42, align 8, !tbaa !17
  %43 = load i16, ptr %7, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %45, i32 0, i32 6
  store i32 %44, ptr %46, align 8, !tbaa !18
  %47 = load i16, ptr %7, align 2, !tbaa !9
  %48 = zext i16 %47 to i32
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %49, i32 0, i32 7
  store i32 %48, ptr %50, align 4, !tbaa !19
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %51, i32 0, i32 12
  store volatile i32 0, ptr %52, align 8, !tbaa !20
  %53 = load i32, ptr %9, align 4, !tbaa !11
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %55, label %66

55:                                               ; preds = %39
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %56, i32 0, i32 11
  store volatile i32 34, ptr %57, align 4, !tbaa !16
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %60, i32 0, i32 0
  %62 = load volatile i32, ptr %61, align 4, !tbaa !22
  %63 = zext i32 %62 to i64
  %64 = or i64 %63, 32
  %65 = trunc i64 %64 to i32
  store volatile i32 %65, ptr %61, align 4, !tbaa !22
  br label %69

66:                                               ; preds = %39
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %67, i32 0, i32 11
  store volatile i32 50, ptr %68, align 4, !tbaa !16
  br label %69

69:                                               ; preds = %66, %55
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %71, i32 0, i32 10
  store i32 0, ptr %72, align 8, !tbaa !13
  br label %73

73:                                               ; preds = %70
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = getelementptr inbounds %struct.SWPMI_TypeDef, ptr %77, i32 0, i32 5
  %79 = load volatile i32, ptr %78, align 4, !tbaa !24
  %80 = zext i32 %79 to i64
  %81 = or i64 %80, 45
  %82 = trunc i64 %81 to i32
  store volatile i32 %82, ptr %78, align 4, !tbaa !24
  br label %89

83:                                               ; preds = %36
  store i32 2, ptr %8, align 4, !tbaa !11
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.SWPMI_HandleTypeDef, ptr %85, i32 0, i32 10
  store i32 0, ptr %86, align 8, !tbaa !13
  br label %87

87:                                               ; preds = %84
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88, %74
  br label %90

90:                                               ; preds = %89, %17
  %91 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %91, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %92

92:                                               ; preds = %90, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %93 = load i32, ptr %4, align 4
  ret i32 %93
}

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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 72}
!14 = !{!"", !6, i64 0, !15, i64 8, !6, i64 24, !12, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !12, i64 80}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!16 = !{!14, !12, i64 76}
!17 = !{!14, !6, i64 40}
!18 = !{!14, !12, i64 48}
!19 = !{!14, !12, i64 52}
!20 = !{!14, !12, i64 80}
!21 = !{!14, !6, i64 0}
!22 = !{!23, !12, i64 0}
!23 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36}
!24 = !{!23, !12, i64 20}


; 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_SWPMI_Receive_IT(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %1, null
  %5 = zext i16 %2 to i32
  %6 = icmp eq i16 %2, 0
  %or.cond = or i1 %4, %6
  br i1 %or.cond, label %31, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %31, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 76
  %13 = load volatile i32, ptr %12, align 4, !tbaa !12
  switch i32 %13, label %30 [
    i32 18, label %14
    i32 1, label %14
  ]

14:                                               ; preds = %11, %11
  %15 = icmp eq i32 %13, 1
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %5, ptr %17, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %5, ptr %18, align 4, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  store volatile i32 0, ptr %19, align 8, !tbaa !16
  br i1 %15, label %20, label %24

20:                                               ; preds = %14
  store volatile i32 34, ptr %12, align 4, !tbaa !12
  %21 = load ptr, ptr %0, align 8, !tbaa !17
  %22 = load volatile i32, ptr %21, align 4, !tbaa !18
  %23 = or i32 %22, 32
  store volatile i32 %23, ptr %21, align 4, !tbaa !18
  br label %25

24:                                               ; preds = %14
  store volatile i32 50, ptr %12, align 4, !tbaa !12
  %.pre = load ptr, ptr %0, align 8, !tbaa !17
  br label %25

25:                                               ; preds = %20, %24
  %26 = phi ptr [ %21, %20 ], [ %.pre, %24 ]
  store i32 0, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 20
  %28 = load volatile i32, ptr %27, align 4, !tbaa !20
  %29 = or i32 %28, 45
  store volatile i32 %29, ptr %27, align 4, !tbaa !20
  br label %31

30:                                               ; preds = %11
  store i32 0, ptr %8, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %30, %25, %3, %7
  %.0 = phi i32 [ 2, %7 ], [ 0, %25 ], [ 2, %30 ], [ 1, %3 ]
  ret i32 %.0
}

attributes #0 = { nofree norecurse 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, !11, i64 72}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 24, !11, i64 32, !11, i64 36, !7, i64 40, !11, i64 48, !11, i64 52, !7, i64 56, !7, i64 64, !11, i64 72, !11, i64 76, !11, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 76}
!13 = !{!6, !7, i64 40}
!14 = !{!6, !11, i64 48}
!15 = !{!6, !11, i64 52}
!16 = !{!6, !11, i64 80}
!17 = !{!6, !7, i64 0}
!18 = !{!19, !11, i64 0}
!19 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!20 = !{!19, !11, i64 20}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass