; 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.IRDA_HandleTypeDef = type { ptr, %struct.IRDA_InitTypeDef, ptr, i16, i16, ptr, i16, i16, i16, ptr, ptr, i32, i32, i32, i32 }
%struct.IRDA_InitTypeDef = type { i32, i32, i32, i32, i8, i16, i32 }
%struct.USART_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_IRDA_Receive_IT(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  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
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %8, i32 0, i32 13
  %10 = load volatile i32, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i32 %10, 32
  br i1 %11, label %12, label %131

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

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

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

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %22, i32 0, i32 11
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i32 2, ptr %4, align 4
  br label %132

27:                                               ; preds = %21
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %28, i32 0, i32 11
  store i32 1, ptr %29, align 8, !tbaa !15
  br label %30

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %33, i32 0, i32 5
  store ptr %32, ptr %34, align 8, !tbaa !16
  %35 = load i16, ptr %7, align 2, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %36, i32 0, i32 6
  store i16 %35, ptr %37, align 8, !tbaa !17
  %38 = load i16, ptr %7, align 2, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %39, i32 0, i32 7
  store volatile i16 %38, ptr %40, align 2, !tbaa !18
  br label %41

41:                                               ; preds = %31
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = zext i32 %45 to i64
  %47 = icmp eq i64 %46, 4096
  br i1 %47, label %48, label %61

48:                                               ; preds = %41
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !20
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %48
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %55, i32 0, i32 8
  store i16 511, ptr %56, align 4, !tbaa !21
  br label %60

57:                                               ; preds = %48
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %58, i32 0, i32 8
  store i16 255, ptr %59, align 4, !tbaa !21
  br label %60

60:                                               ; preds = %57, %54
  br label %105

61:                                               ; preds = %41
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !19
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %80

67:                                               ; preds = %61
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %68, i32 0, i32 1
  %70 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !20
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %76

73:                                               ; preds = %67
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %74, i32 0, i32 8
  store i16 255, ptr %75, align 4, !tbaa !21
  br label %79

76:                                               ; preds = %67
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %77, i32 0, i32 8
  store i16 127, ptr %78, align 4, !tbaa !21
  br label %79

79:                                               ; preds = %76, %73
  br label %104

80:                                               ; preds = %61
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %81, i32 0, i32 1
  %83 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %82, i32 0, i32 1
  %84 = load i32, ptr %83, align 4, !tbaa !19
  %85 = zext i32 %84 to i64
  %86 = icmp eq i64 %85, 268435456
  br i1 %86, label %87, label %100

87:                                               ; preds = %80
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %88, i32 0, i32 1
  %90 = getelementptr inbounds %struct.IRDA_InitTypeDef, ptr %89, i32 0, i32 2
  %91 = load i32, ptr %90, align 8, !tbaa !20
  %92 = icmp eq i32 %91, 0
  br i1 %92, label %93, label %96

93:                                               ; preds = %87
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %94, i32 0, i32 8
  store i16 127, ptr %95, align 4, !tbaa !21
  br label %99

96:                                               ; preds = %87
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %97, i32 0, i32 8
  store i16 63, ptr %98, align 4, !tbaa !21
  br label %99

99:                                               ; preds = %96, %93
  br label %103

100:                                              ; preds = %80
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %101, i32 0, i32 8
  store i16 0, ptr %102, align 4, !tbaa !21
  br label %103

103:                                              ; preds = %100, %99
  br label %104

104:                                              ; preds = %103, %79
  br label %105

105:                                              ; preds = %104, %60
  br label %106

106:                                              ; preds = %105
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %107, i32 0, i32 14
  store volatile i32 0, ptr %108, align 4, !tbaa !22
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %109, i32 0, i32 13
  store volatile i32 34, ptr %110, align 8, !tbaa !11
  br label %111

111:                                              ; preds = %106
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %112, i32 0, i32 11
  store i32 0, ptr %113, align 8, !tbaa !15
  br label %114

114:                                              ; preds = %111
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !23
  %118 = getelementptr inbounds %struct.USART_TypeDef, ptr %117, i32 0, i32 0
  %119 = load volatile i32, ptr %118, align 4, !tbaa !24
  %120 = zext i32 %119 to i64
  %121 = or i64 %120, 288
  %122 = trunc i64 %121 to i32
  store volatile i32 %122, ptr %118, align 4, !tbaa !24
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !23
  %126 = getelementptr inbounds %struct.USART_TypeDef, ptr %125, i32 0, i32 2
  %127 = load volatile i32, ptr %126, align 4, !tbaa !26
  %128 = zext i32 %127 to i64
  %129 = or i64 %128, 1
  %130 = trunc i64 %129 to i32
  store volatile i32 %130, ptr %126, align 4, !tbaa !26
  store i32 0, ptr %4, align 4
  br label %132

131:                                              ; preds = %3
  store i32 2, ptr %4, align 4
  br label %132

132:                                              ; preds = %131, %114, %26, %19
  %133 = load i32, ptr %4, align 4
  ret i32 %133
}

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 = !{!"short", !7, i64 0}
!11 = !{!12, !14, i64 88}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 32, !10, i64 40, !10, i64 42, !6, i64 48, !10, i64 56, !10, i64 58, !10, i64 60, !6, i64 64, !6, i64 72, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92}
!13 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !7, i64 16, !10, i64 18, !14, i64 20}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !14, i64 80}
!16 = !{!12, !6, i64 48}
!17 = !{!12, !10, i64 56}
!18 = !{!12, !10, i64 58}
!19 = !{!12, !14, i64 12}
!20 = !{!12, !14, i64 16}
!21 = !{!12, !10, i64 60}
!22 = !{!12, !14, i64 92}
!23 = !{!12, !6, i64 0}
!24 = !{!25, !14, i64 0}
!25 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44}
!26 = !{!25, !14, i64 8}


; 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_IRDA_Receive_IT(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  %5 = load volatile i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 32
  br i1 %6, label %7, label %51

7:                                                ; preds = %3
  %8 = icmp eq ptr %1, null
  %9 = icmp eq i16 %2, 0
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %51, label %10

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

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %1, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  store i16 %2, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %0, i64 58
  store volatile i16 %2, ptr %17, align 2, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %0, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !17
  switch i32 %19, label %41 [
    i32 4096, label %20
    i32 0, label %27
    i32 268435456, label %34
  ]

20:                                               ; preds = %14
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !18
  %23 = icmp eq i32 %22, 0
  %24 = getelementptr inbounds i8, ptr %0, i64 60
  br i1 %23, label %25, label %26

25:                                               ; preds = %20
  store i16 511, ptr %24, align 4, !tbaa !19
  br label %43

26:                                               ; preds = %20
  store i16 255, ptr %24, align 4, !tbaa !19
  br label %43

27:                                               ; preds = %14
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %30 = icmp eq i32 %29, 0
  %31 = getelementptr inbounds i8, ptr %0, i64 60
  br i1 %30, label %32, label %33

32:                                               ; preds = %27
  store i16 255, ptr %31, align 4, !tbaa !19
  br label %43

33:                                               ; preds = %27
  store i16 127, ptr %31, align 4, !tbaa !19
  br label %43

34:                                               ; preds = %14
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load i32, ptr %35, align 8, !tbaa !18
  %37 = icmp eq i32 %36, 0
  %38 = getelementptr inbounds i8, ptr %0, i64 60
  br i1 %37, label %39, label %40

39:                                               ; preds = %34
  store i16 127, ptr %38, align 4, !tbaa !19
  br label %43

40:                                               ; preds = %34
  store i16 63, ptr %38, align 4, !tbaa !19
  br label %43

41:                                               ; preds = %14
  %42 = getelementptr inbounds i8, ptr %0, i64 60
  store i16 0, ptr %42, align 4, !tbaa !19
  br label %43

43:                                               ; preds = %26, %25, %41, %40, %39, %32, %33
  %44 = getelementptr inbounds i8, ptr %0, i64 92
  store volatile i32 0, ptr %44, align 4, !tbaa !20
  store volatile i32 34, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %11, align 8, !tbaa !13
  %45 = load ptr, ptr %0, align 8, !tbaa !21
  %46 = load volatile i32, ptr %45, align 4, !tbaa !22
  %47 = or i32 %46, 288
  store volatile i32 %47, ptr %45, align 4, !tbaa !22
  %48 = getelementptr inbounds i8, ptr %45, i64 8
  %49 = load volatile i32, ptr %48, align 4, !tbaa !24
  %50 = or i32 %49, 1
  store volatile i32 %50, ptr %48, align 4, !tbaa !24
  br label %51

51:                                               ; preds = %3, %10, %7, %43
  %.0 = phi i32 [ 0, %43 ], [ 1, %7 ], [ 2, %10 ], [ 2, %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 88}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 32, !12, i64 40, !12, i64 42, !7, i64 48, !12, i64 56, !12, i64 58, !12, i64 60, !7, i64 64, !7, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92}
!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, !8, i64 16, !12, i64 18, !11, i64 20}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !11, i64 80}
!14 = !{!6, !7, i64 48}
!15 = !{!6, !12, i64 56}
!16 = !{!6, !12, i64 58}
!17 = !{!6, !11, i64 12}
!18 = !{!6, !11, i64 16}
!19 = !{!6, !12, i64 60}
!20 = !{!6, !11, i64 92}
!21 = !{!6, !7, i64 0}
!22 = !{!23, !11, i64 0}
!23 = !{!"", !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, !11, i64 40, !11, i64 44}
!24 = !{!23, !11, i64 8}


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