; LLVM IR from reazon-research/OpenArm :: control/canfd_control/Drivers/STM32H7xx_HAL_Driver/Src (stm32h7xx_hal_i2c)

; 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, 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 %87

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 %88

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
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds %struct.I2C_InitTypeDef, ptr %54, i32 0, i32 7
  %56 = load i32, ptr %55, align 4, !tbaa !26
  %57 = zext i32 %56 to i64
  %58 = icmp eq i64 %57, 131072
  br i1 %58, label %59, label %81

59:                                               ; preds = %23
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = load i8, ptr %62, align 1, !tbaa !27
  %64 = zext i8 %63 to i32
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !18
  %68 = getelementptr inbounds %struct.I2C_TypeDef, ptr %67, i32 0, i32 10
  store volatile i32 %64, ptr %68, align 4, !tbaa !28
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %69, i32 0, i32 2
  %71 = load ptr, ptr %70, align 8, !tbaa !21
  %72 = getelementptr inbounds i8, ptr %71, i32 1
  store ptr %72, ptr %70, align 8, !tbaa !21
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %73, i32 0, i32 4
  %75 = load volatile i16, ptr %74, align 2, !tbaa !22
  %76 = add i16 %75, -1
  store volatile i16 %76, ptr %74, align 2, !tbaa !22
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %77, i32 0, i32 3
  %79 = load i16, ptr %78, align 8, !tbaa !23
  %80 = add i16 %79, -1
  store i16 %80, ptr %78, align 8, !tbaa !23
  br label %81

81:                                               ; preds = %59, %23
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %83, i32 0, i32 10
  store i32 0, ptr %84, align 8, !tbaa !15
  br label %85

85:                                               ; preds = %82
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  call void @I2C_Enable_IRQ(ptr noundef %86, i16 noundef zeroext -32767)
  store i32 0, ptr %4, align 4
  br label %88

87:                                               ; preds = %3
  store i32 2, ptr %4, align 4
  br label %88

88:                                               ; preds = %87, %85, %18
  %89 = load i32, ptr %4, align 4
  ret i32 %89
}

; 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, !14, i64 108, !14, i64 112}
!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}
!26 = !{!12, !14, i64 36}
!27 = !{!7, !7, i64 0}
!28 = !{!20, !14, i64 40}


; 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 %36

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 %36, label %11

11:                                               ; preds = %7
  store i32 1, ptr %8, align 8, !tbaa !13
  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
  %24 = getelementptr inbounds i8, ptr %0, i64 36
  %25 = load i32, ptr %24, align 4, !tbaa !24
  %26 = icmp eq i32 %25, 131072
  br i1 %26, label %27, label %35

27:                                               ; preds = %11
  %28 = load i8, ptr %1, align 1, !tbaa !25
  %29 = zext i8 %28 to i32
  %30 = getelementptr inbounds i8, ptr %14, i64 40
  store volatile i32 %29, ptr %30, align 4, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %1, i64 1
  store ptr %31, ptr %18, align 8, !tbaa !19
  %32 = load volatile i16, ptr %19, align 2, !tbaa !20
  %33 = add i16 %32, -1
  store volatile i16 %33, ptr %19, align 2, !tbaa !20
  %34 = add i16 %20, -1
  store i16 %34, ptr %21, align 8, !tbaa !21
  br label %35

35:                                               ; preds = %11, %27
  store i32 0, ptr %8, align 8, !tbaa !13
  tail call void @I2C_Enable_IRQ(ptr noundef nonnull %0, i16 noundef zeroext -32767)
  br label %36

36:                                               ; preds = %3, %7, %35
  %.0 = phi i32 [ 0, %35 ], [ 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, !11, i64 108, !11, i64 112}
!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}
!24 = !{!6, !11, i64 36}
!25 = !{!8, !8, i64 0}
!26 = !{!18, !11, i64 40}


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