; 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: nounwind uwtable
declare hidden void @I2C_Enable_IRQ(ptr noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_I2C_Slave_Transmit_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.__I2C_HandleTypeDef, ptr %8, i32 0, i32 11
  %10 = load volatile i32, ptr %9, align 4, !tbaa !11
  %11 = icmp eq i32 %10, 32
  br i1 %11, label %12, label %58

12:                                               ; preds = %3
  br label %13

13:                                               ; preds = %12
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %14, i32 0, i32 10
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  store i32 2, ptr %4, align 4
  br label %59

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %20, i32 0, i32 10
  store i32 1, ptr %21, align 8, !tbaa !15
  br label %22

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %24, i32 0, i32 11
  store volatile i32 33, ptr %25, align 4, !tbaa !11
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %26, i32 0, i32 12
  store volatile i32 32, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %28, i32 0, i32 13
  store volatile i32 0, ptr %29, align 4, !tbaa !17
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds %struct.I2C_TypeDef, ptr %32, i32 0, i32 1
  %34 = load volatile i32, ptr %33, align 4, !tbaa !19
  %35 = zext i32 %34 to i64
  %36 = and i64 %35, -32769
  %37 = trunc i64 %36 to i32
  store volatile i32 %37, ptr %33, align 4, !tbaa !19
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %39, i32 0, i32 2
  store ptr %38, ptr %40, align 8, !tbaa !21
  %41 = load i16, ptr %7, align 2, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %42, i32 0, i32 4
  store volatile i16 %41, ptr %43, align 2, !tbaa !22
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %44, i32 0, i32 4
  %46 = load volatile i16, ptr %45, align 2, !tbaa !22
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %47, i32 0, i32 3
  store i16 %46, ptr %48, align 8, !tbaa !23
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %49, i32 0, i32 5
  store volatile i32 -65536, ptr %50, align 4, !tbaa !24
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %51, i32 0, i32 7
  store ptr @I2C_Slave_ISR_IT, ptr %52, align 8, !tbaa !25
  br label %53

53:                                               ; preds = %23
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %54, i32 0, i32 10
  store i32 0, ptr %55, align 8, !tbaa !15
  br label %56

56:                                               ; preds = %53
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  call void @I2C_Enable_IRQ(ptr noundef %57, i16 noundef zeroext 5)
  store i32 0, ptr %4, align 4
  br label %59

58:                                               ; preds = %3
  store i32 2, ptr %4, align 4
  br label %59

59:                                               ; preds = %58, %56, %18
  %60 = load i32, ptr %4, align 4
  ret i32 %60
}

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_Slave_ISR_IT(ptr noundef, i32 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" }

!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, !14, i64 88}
!16 = !{!12, !14, i64 96}
!17 = !{!12, !14, i64 100}
!18 = !{!12, !6, i64 0}
!19 = !{!20, !14, i64 4}
!20 = !{!"", !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}
!21 = !{!12, !6, i64 40}
!22 = !{!12, !10, i64 50}
!23 = !{!12, !10, i64 48}
!24 = !{!12, !14, i64 52}
!25 = !{!12, !6, 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
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_Slave_Transmit_IT(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 92
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 32
  br i1 %6, label %7, label %24

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

11:                                               ; preds = %7
  store volatile i32 33, ptr %4, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  store volatile i32 32, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 0, ptr %13, align 4, !tbaa !15
  %14 = load ptr, ptr %0, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = load volatile i32, ptr %15, align 4, !tbaa !17
  %17 = and i32 %16, -32769
  store volatile i32 %17, ptr %15, align 4, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 50
  store volatile i16 %2, ptr %19, align 2, !tbaa !20
  %20 = load volatile i16, ptr %19, align 2, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 %20, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %0, i64 52
  store volatile i32 -65536, ptr %22, align 4, !tbaa !22
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr @I2C_Slave_ISR_IT, ptr %23, align 8, !tbaa !23
  store i32 0, ptr %8, align 8, !tbaa !13
  tail call void @I2C_Enable_IRQ(ptr noundef nonnull %0, i16 noundef zeroext 5)
  br label %24

24:                                               ; preds = %3, %7, %11
  %.0 = phi i32 [ 0, %11 ], [ 2, %7 ], [ 2, %3 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_Slave_ISR_IT(ptr noundef, i32 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" }

!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, !11, i64 88}
!14 = !{!6, !11, i64 96}
!15 = !{!6, !11, i64 100}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !11, i64 4}
!18 = !{!"", !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}
!19 = !{!6, !7, i64 40}
!20 = !{!6, !12, i64 50}
!21 = !{!6, !12, i64 48}
!22 = !{!6, !11, i64 52}
!23 = !{!6, !7, i64 64}


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