; 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.__I2C_HandleTypeDef = type { ptr, %struct.I2C_InitTypeDef, ptr, i16, i16, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.I2C_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.I2C_TypeDef = type { i32, 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: nounwind uwtable
declare hidden void @I2C_TransferConfig(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i32 noundef, i32 noundef) #1

; 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
declare hidden i32 @I2C_Master_ISR_IT(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @I2C_Enable_IRQ(ptr noundef, i16 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_I2C_Master_Receive_IT(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i16 noundef zeroext %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i16 %1, ptr %7, align 2, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i16 %3, ptr %9, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %12, i32 0, i32 11
  %14 = load volatile i32, ptr %13, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 32
  br i1 %15, label %16, label %86

16:                                               ; preds = %4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = getelementptr inbounds %struct.I2C_TypeDef, ptr %19, i32 0, i32 6
  %21 = load volatile i32, ptr %20, align 4, !tbaa !16
  %22 = zext i32 %21 to i64
  %23 = and i64 %22, 32768
  %24 = icmp eq i64 %23, 32768
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, i32 1, i32 0
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %29

28:                                               ; preds = %16
  store i32 2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

29:                                               ; preds = %16
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %31, i32 0, i32 10
  %33 = load i32, ptr %32, align 8, !tbaa !18
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %35, label %36

35:                                               ; preds = %30
  store i32 2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

36:                                               ; preds = %30
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %37, i32 0, i32 10
  store i32 1, ptr %38, align 8, !tbaa !18
  br label %39

39:                                               ; preds = %36
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %42, i32 0, i32 11
  store volatile i32 34, ptr %43, align 4, !tbaa !11
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %44, i32 0, i32 12
  store volatile i32 16, ptr %45, align 8, !tbaa !19
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %46, i32 0, i32 13
  store volatile i32 0, ptr %47, align 4, !tbaa !20
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %49, i32 0, i32 2
  store ptr %48, ptr %50, align 8, !tbaa !21
  %51 = load i16, ptr %9, align 2, !tbaa !9
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %52, i32 0, i32 4
  store volatile i16 %51, ptr %53, align 2, !tbaa !22
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %54, i32 0, i32 5
  store volatile i32 -65536, ptr %55, align 4, !tbaa !23
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %56, i32 0, i32 7
  store ptr @I2C_Master_ISR_IT, ptr %57, align 8, !tbaa !24
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %58, i32 0, i32 4
  %60 = load volatile i16, ptr %59, align 2, !tbaa !22
  %61 = zext i16 %60 to i32
  %62 = icmp ugt i32 %61, 255
  br i1 %62, label %63, label %66

63:                                               ; preds = %41
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %64, i32 0, i32 3
  store i16 255, ptr %65, align 8, !tbaa !25
  store i32 16777216, ptr %10, align 4, !tbaa !26
  br label %72

66:                                               ; preds = %41
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %67, i32 0, i32 4
  %69 = load volatile i16, ptr %68, align 2, !tbaa !22
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %70, i32 0, i32 3
  store i16 %69, ptr %71, align 8, !tbaa !25
  store i32 33554432, ptr %10, align 4, !tbaa !26
  br label %72

72:                                               ; preds = %66, %63
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load i16, ptr %7, align 2, !tbaa !9
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %75, i32 0, i32 3
  %77 = load i16, ptr %76, align 8, !tbaa !25
  %78 = trunc i16 %77 to i8
  %79 = load i32, ptr %10, align 4, !tbaa !26
  call void @I2C_TransferConfig(ptr noundef %73, i16 noundef zeroext %74, i8 noundef zeroext %78, i32 noundef %79, i32 noundef -2147474432)
  br label %80

80:                                               ; preds = %72
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %81, i32 0, i32 10
  store i32 0, ptr %82, align 8, !tbaa !18
  br label %83

83:                                               ; preds = %80
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  call void @I2C_Enable_IRQ(ptr noundef %85, i16 noundef zeroext 2)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

86:                                               ; preds = %4
  store i32 2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

87:                                               ; preds = %86, %84, %35, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %88 = load i32, ptr %5, align 4
  ret i32 %88
}

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, !14, i64 92}
!12 = !{!"__I2C_HandleTypeDef", !6, i64 0, !13, i64 8, !6, i64 40, !10, i64 48, !10, i64 50, !14, i64 52, !14, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88, !14, i64 92, !14, i64 96, !14, i64 100, !14, i64 104}
!13 = !{!"", !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 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !14, i64 24}
!17 = !{!"", !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}
!18 = !{!12, !14, i64 88}
!19 = !{!12, !14, i64 96}
!20 = !{!12, !14, i64 100}
!21 = !{!12, !6, i64 40}
!22 = !{!12, !10, i64 50}
!23 = !{!12, !14, i64 52}
!24 = !{!12, !6, i64 64}
!25 = !{!12, !10, i64 48}
!26 = !{!14, !14, i64 0}


; 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
declare hidden void @I2C_TransferConfig(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_I2C_Master_Receive_IT(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i16 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 92
  %6 = load volatile i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 32
  br i1 %7, label %8, label %31

8:                                                ; preds = %4
  %9 = load ptr, ptr %0, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load volatile i32, ptr %10, align 4, !tbaa !14
  %12 = and i32 %11, 32768
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %31

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 88
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %31, label %17

17:                                               ; preds = %13
  store i32 1, ptr %14, align 8, !tbaa !16
  store volatile i32 34, ptr %5, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 96
  store volatile i32 16, ptr %18, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 0, ptr %19, align 4, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %2, ptr %20, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %0, i64 50
  store volatile i16 %3, ptr %21, align 2, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %0, i64 52
  store volatile i32 -65536, ptr %22, align 4, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr @I2C_Master_ISR_IT, ptr %23, align 8, !tbaa !22
  %24 = load volatile i16, ptr %21, align 2, !tbaa !20
  %25 = icmp ugt i16 %24, 255
  br i1 %25, label %28, label %26

26:                                               ; preds = %17
  %27 = load volatile i16, ptr %21, align 2, !tbaa !20
  br label %28

28:                                               ; preds = %17, %26
  %.sink = phi i16 [ %27, %26 ], [ 255, %17 ]
  %.0 = phi i32 [ 33554432, %26 ], [ 16777216, %17 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 %.sink, ptr %29, align 8
  %30 = trunc i16 %.sink to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %30, i32 noundef %.0, i32 noundef -2147474432)
  store i32 0, ptr %14, align 8, !tbaa !16
  tail call void @I2C_Enable_IRQ(ptr noundef nonnull %0, i16 noundef zeroext 2)
  br label %31

31:                                               ; preds = %4, %13, %8, %28
  %.023 = phi i32 [ 0, %28 ], [ 2, %8 ], [ 2, %13 ], [ 2, %4 ]
  ret i32 %.023
}

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, !11, i64 92}
!6 = !{!"__I2C_HandleTypeDef", !7, i64 0, !10, i64 8, !7, i64 40, !12, i64 48, !12, i64 50, !11, i64 52, !11, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104}
!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, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 24}
!15 = !{!"", !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}
!16 = !{!6, !11, i64 88}
!17 = !{!6, !11, i64 96}
!18 = !{!6, !11, i64 100}
!19 = !{!6, !7, i64 40}
!20 = !{!6, !12, i64 50}
!21 = !{!6, !11, i64 52}
!22 = !{!6, !7, i64 64}


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