; 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 }

; 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_Seq_Transmit_IT(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i16 noundef zeroext %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i16 %1, ptr %8, align 2, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i16 %3, ptr %10, align 2, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 -2147475456, ptr %13, align 4, !tbaa !11
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %15, i32 0, i32 11
  %17 = load volatile i32, ptr %16, align 4, !tbaa !13
  %18 = icmp eq i32 %17, 32
  br i1 %18, label %19, label %109

19:                                               ; preds = %5
  br label %20

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

25:                                               ; preds = %20
  store i32 2, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %110

26:                                               ; preds = %20
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %27, i32 0, i32 10
  store i32 1, ptr %28, align 8, !tbaa !16
  br label %29

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %32, i32 0, i32 11
  store volatile i32 33, ptr %33, align 4, !tbaa !13
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %34, i32 0, i32 12
  store volatile i32 16, ptr %35, align 8, !tbaa !17
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %36, i32 0, i32 13
  store volatile i32 0, ptr %37, align 4, !tbaa !18
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %39, i32 0, i32 2
  store ptr %38, ptr %40, align 8, !tbaa !19
  %41 = load i16, ptr %10, align 2, !tbaa !9
  %42 = load ptr, ptr %7, 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 !20
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %45, i32 0, i32 5
  store volatile i32 %44, ptr %46, align 4, !tbaa !21
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %47, i32 0, i32 7
  store ptr @I2C_Master_ISR_IT, ptr %48, align 8, !tbaa !22
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %49, i32 0, i32 4
  %51 = load volatile i16, ptr %50, align 2, !tbaa !20
  %52 = zext i16 %51 to i32
  %53 = icmp ugt i32 %52, 255
  br i1 %53, label %54, label %57

54:                                               ; preds = %31
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %55, i32 0, i32 3
  store i16 255, ptr %56, align 8, !tbaa !23
  store i32 16777216, ptr %12, align 4, !tbaa !11
  br label %66

57:                                               ; preds = %31
  %58 = load ptr, ptr %7, 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 !20
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %61, i32 0, i32 3
  store i16 %60, ptr %62, align 8, !tbaa !23
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %63, i32 0, i32 5
  %65 = load volatile i32, ptr %64, align 4, !tbaa !21
  store i32 %65, ptr %12, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %57, %54
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %67, i32 0, i32 6
  %69 = load volatile i32, ptr %68, align 8, !tbaa !24
  %70 = icmp eq i32 %69, 17
  br i1 %70, label %71, label %82

71:                                               ; preds = %66
  %72 = load i32, ptr %11, align 4, !tbaa !11
  %73 = icmp eq i32 %72, 170
  br i1 %73, label %77, label %74

74:                                               ; preds = %71
  %75 = load i32, ptr %11, align 4, !tbaa !11
  %76 = icmp eq i32 %75, 43520
  br label %77

77:                                               ; preds = %74, %71
  %78 = phi i1 [ true, %71 ], [ %76, %74 ]
  %79 = zext i1 %78 to i32
  %80 = icmp eq i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %77
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %94

82:                                               ; preds = %77, %66
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  call void @I2C_ConvertOtherXferOptions(ptr noundef %83)
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %84, i32 0, i32 4
  %86 = load volatile i16, ptr %85, align 2, !tbaa !20
  %87 = zext i16 %86 to i32
  %88 = icmp ult i32 %87, 255
  br i1 %88, label %89, label %93

89:                                               ; preds = %82
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %90, i32 0, i32 5
  %92 = load volatile i32, ptr %91, align 4, !tbaa !21
  store i32 %92, ptr %12, align 4, !tbaa !11
  br label %93

93:                                               ; preds = %89, %82
  br label %94

94:                                               ; preds = %93, %81
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = load i16, ptr %8, align 2, !tbaa !9
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %97, i32 0, i32 3
  %99 = load i16, ptr %98, align 8, !tbaa !23
  %100 = trunc i16 %99 to i8
  %101 = load i32, ptr %12, align 4, !tbaa !11
  %102 = load i32, ptr %13, align 4, !tbaa !11
  call void @I2C_TransferConfig(ptr noundef %95, i16 noundef zeroext %96, i8 noundef zeroext %100, i32 noundef %101, i32 noundef %102)
  br label %103

103:                                              ; preds = %94
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %104, i32 0, i32 10
  store i32 0, ptr %105, align 8, !tbaa !16
  br label %106

106:                                              ; preds = %103
  br label %107

107:                                              ; preds = %106
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  call void @I2C_Enable_IRQ(ptr noundef %108, i16 noundef zeroext 1)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %110

109:                                              ; preds = %5
  store i32 2, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %110

110:                                              ; preds = %109, %107, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %111 = load i32, ptr %6, align 4
  ret i32 %111
}

; Function Attrs: nounwind uwtable
declare hidden void @I2C_ConvertOtherXferOptions(ptr noundef) #1

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


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

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

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

22:                                               ; preds = %13
  %23 = load volatile i16, ptr %17, align 2, !tbaa !17
  %24 = load volatile i32, ptr %18, align 4, !tbaa !18
  br label %25

25:                                               ; preds = %13, %22
  %.sink = phi i16 [ %23, %22 ], [ 255, %13 ]
  %.031 = phi i32 [ %24, %22 ], [ 16777216, %13 ]
  %26 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 %.sink, ptr %26, align 8
  %27 = getelementptr inbounds i8, ptr %0, i64 56
  %28 = load volatile i32, ptr %27, align 8, !tbaa !20
  %29 = icmp eq i32 %28, 17
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  switch i32 %4, label %36 [
    i32 43520, label %31
    i32 170, label %31
  ]

31:                                               ; preds = %30, %30, %25
  tail call void @I2C_ConvertOtherXferOptions(ptr noundef nonnull %0)
  %32 = load volatile i16, ptr %17, align 2, !tbaa !17
  %33 = icmp ult i16 %32, 255
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = load volatile i32, ptr %18, align 4, !tbaa !18
  br label %36

36:                                               ; preds = %30, %31, %34
  %.1 = phi i32 [ %35, %34 ], [ %.031, %31 ], [ %.031, %30 ]
  %.0 = phi i32 [ -2147475456, %34 ], [ -2147475456, %31 ], [ 0, %30 ]
  %37 = load i16, ptr %26, align 8, !tbaa !21
  %38 = trunc i16 %37 to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %38, i32 noundef %.1, i32 noundef %.0)
  store i32 0, ptr %10, align 8, !tbaa !13
  tail call void @I2C_Enable_IRQ(ptr noundef nonnull %0, i16 noundef zeroext 1)
  br label %39

39:                                               ; preds = %5, %9, %36
  %.032 = phi i32 [ 0, %36 ], [ 2, %9 ], [ 2, %5 ]
  ret i32 %.032
}

; Function Attrs: nounwind uwtable
declare hidden void @I2C_ConvertOtherXferOptions(ptr noundef) local_unnamed_addr #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 40}
!17 = !{!6, !12, i64 50}
!18 = !{!6, !11, i64 52}
!19 = !{!6, !7, i64 64}
!20 = !{!6, !11, i64 56}
!21 = !{!6, !12, i64 48}


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