; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (Receive)

; 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

declare i32 @HAL_GetTick() #1

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

; Function Attrs: nounwind uwtable
declare hidden void @I2C_TransferConfig(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i32 noundef, i32 noundef) #2

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

; 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
define dso_local i32 @HAL_I2C_Master_Receive(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i16 noundef zeroext %3, i32 noundef %4) #2 {
  %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
  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) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %14, i32 0, i32 11
  %16 = load volatile i32, ptr %15, align 4, !tbaa !13
  %17 = icmp eq i32 %16, 32
  br i1 %17, label %18, label %188

18:                                               ; preds = %5
  br label %19

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

24:                                               ; preds = %19
  store i32 2, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

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

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = call i32 @HAL_GetTick()
  store i32 %31, ptr %12, align 4, !tbaa !11
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i32, ptr %12, align 4, !tbaa !11
  %34 = call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef %32, i32 noundef 32768, i32 noundef 1, i32 noundef 25, i32 noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

37:                                               ; preds = %30
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %38, i32 0, i32 11
  store volatile i32 34, ptr %39, align 4, !tbaa !13
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %40, i32 0, i32 12
  store volatile i32 16, ptr %41, align 8, !tbaa !17
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %42, i32 0, i32 13
  store volatile i32 0, ptr %43, align 4, !tbaa !18
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %45, i32 0, i32 2
  store ptr %44, ptr %46, align 8, !tbaa !19
  %47 = load i16, ptr %10, align 2, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %48, i32 0, i32 4
  store volatile i16 %47, ptr %49, align 2, !tbaa !20
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %50, i32 0, i32 7
  store ptr null, ptr %51, align 8, !tbaa !21
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %52, i32 0, i32 4
  %54 = load volatile i16, ptr %53, align 2, !tbaa !20
  %55 = zext i16 %54 to i32
  %56 = icmp ugt i32 %55, 255
  br i1 %56, label %57, label %66

57:                                               ; preds = %37
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %58, i32 0, i32 3
  store i16 255, ptr %59, align 8, !tbaa !22
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load i16, ptr %8, align 2, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %62, i32 0, i32 3
  %64 = load i16, ptr %63, align 8, !tbaa !22
  %65 = trunc i16 %64 to i8
  call void @I2C_TransferConfig(ptr noundef %60, i16 noundef zeroext %61, i8 noundef zeroext %65, i32 noundef 16777216, i32 noundef -2147474432)
  br label %78

66:                                               ; preds = %37
  %67 = load ptr, ptr %7, 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 !20
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %70, i32 0, i32 3
  store i16 %69, ptr %71, align 8, !tbaa !22
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load i16, ptr %8, align 2, !tbaa !9
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %74, i32 0, i32 3
  %76 = load i16, ptr %75, align 8, !tbaa !22
  %77 = trunc i16 %76 to i8
  call void @I2C_TransferConfig(ptr noundef %72, i16 noundef zeroext %73, i8 noundef zeroext %77, i32 noundef 33554432, i32 noundef -2147474432)
  br label %78

78:                                               ; preds = %66, %57
  br label %79

79:                                               ; preds = %160, %78
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %80, i32 0, i32 4
  %82 = load volatile i16, ptr %81, align 2, !tbaa !20
  %83 = zext i16 %82 to i32
  %84 = icmp ugt i32 %83, 0
  br i1 %84, label %85, label %161

85:                                               ; preds = %79
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load i32, ptr %11, align 4, !tbaa !11
  %88 = load i32, ptr %12, align 4, !tbaa !11
  %89 = call i32 @I2C_WaitOnRXNEFlagUntilTimeout(ptr noundef %86, i32 noundef %87, i32 noundef %88)
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %85
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

92:                                               ; preds = %85
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !23
  %96 = getelementptr inbounds %struct.I2C_TypeDef, ptr %95, i32 0, i32 9
  %97 = load volatile i32, ptr %96, align 4, !tbaa !24
  %98 = trunc i32 %97 to i8
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %99, i32 0, i32 2
  %101 = load ptr, ptr %100, align 8, !tbaa !19
  store i8 %98, ptr %101, align 1, !tbaa !26
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !19
  %105 = getelementptr inbounds i8, ptr %104, i32 1
  store ptr %105, ptr %103, align 8, !tbaa !19
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %106, i32 0, i32 3
  %108 = load i16, ptr %107, align 8, !tbaa !22
  %109 = add i16 %108, -1
  store i16 %109, ptr %107, align 8, !tbaa !22
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %110, i32 0, i32 4
  %112 = load volatile i16, ptr %111, align 2, !tbaa !20
  %113 = add i16 %112, -1
  store volatile i16 %113, ptr %111, align 2, !tbaa !20
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %114, i32 0, i32 4
  %116 = load volatile i16, ptr %115, align 2, !tbaa !20
  %117 = zext i16 %116 to i32
  %118 = icmp ne i32 %117, 0
  br i1 %118, label %119, label %160

119:                                              ; preds = %92
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %120, i32 0, i32 3
  %122 = load i16, ptr %121, align 8, !tbaa !22
  %123 = zext i16 %122 to i32
  %124 = icmp eq i32 %123, 0
  br i1 %124, label %125, label %160

125:                                              ; preds = %119
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = load i32, ptr %11, align 4, !tbaa !11
  %128 = load i32, ptr %12, align 4, !tbaa !11
  %129 = call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef %126, i32 noundef 128, i32 noundef 0, i32 noundef %127, i32 noundef %128)
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %132

131:                                              ; preds = %125
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

132:                                              ; preds = %125
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %133, i32 0, i32 4
  %135 = load volatile i16, ptr %134, align 2, !tbaa !20
  %136 = zext i16 %135 to i32
  %137 = icmp ugt i32 %136, 255
  br i1 %137, label %138, label %147

138:                                              ; preds = %132
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %139, i32 0, i32 3
  store i16 255, ptr %140, align 8, !tbaa !22
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = load i16, ptr %8, align 2, !tbaa !9
  %143 = load ptr, ptr %7, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %143, i32 0, i32 3
  %145 = load i16, ptr %144, align 8, !tbaa !22
  %146 = trunc i16 %145 to i8
  call void @I2C_TransferConfig(ptr noundef %141, i16 noundef zeroext %142, i8 noundef zeroext %146, i32 noundef 16777216, i32 noundef 0)
  br label %159

147:                                              ; preds = %132
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %148, i32 0, i32 4
  %150 = load volatile i16, ptr %149, align 2, !tbaa !20
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %151, i32 0, i32 3
  store i16 %150, ptr %152, align 8, !tbaa !22
  %153 = load ptr, ptr %7, align 8, !tbaa !5
  %154 = load i16, ptr %8, align 2, !tbaa !9
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %155, i32 0, i32 3
  %157 = load i16, ptr %156, align 8, !tbaa !22
  %158 = trunc i16 %157 to i8
  call void @I2C_TransferConfig(ptr noundef %153, i16 noundef zeroext %154, i8 noundef zeroext %158, i32 noundef 33554432, i32 noundef 0)
  br label %159

159:                                              ; preds = %147, %138
  br label %160

160:                                              ; preds = %159, %119, %92
  br label %79, !llvm.loop !27

161:                                              ; preds = %79
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  %163 = load i32, ptr %11, align 4, !tbaa !11
  %164 = load i32, ptr %12, align 4, !tbaa !11
  %165 = call i32 @I2C_WaitOnSTOPFlagUntilTimeout(ptr noundef %162, i32 noundef %163, i32 noundef %164)
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %161
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

168:                                              ; preds = %161
  %169 = load ptr, ptr %7, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %169, i32 0, i32 0
  %171 = load ptr, ptr %170, align 8, !tbaa !23
  %172 = getelementptr inbounds %struct.I2C_TypeDef, ptr %171, i32 0, i32 7
  store volatile i32 32, ptr %172, align 4, !tbaa !29
  %173 = load ptr, ptr %7, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %173, i32 0, i32 0
  %175 = load ptr, ptr %174, align 8, !tbaa !23
  %176 = getelementptr inbounds %struct.I2C_TypeDef, ptr %175, i32 0, i32 1
  %177 = load volatile i32, ptr %176, align 4, !tbaa !30
  %178 = and i32 %177, -33495040
  store volatile i32 %178, ptr %176, align 4, !tbaa !30
  %179 = load ptr, ptr %7, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %179, i32 0, i32 11
  store volatile i32 32, ptr %180, align 4, !tbaa !13
  %181 = load ptr, ptr %7, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %181, i32 0, i32 12
  store volatile i32 0, ptr %182, align 8, !tbaa !17
  br label %183

183:                                              ; preds = %168
  %184 = load ptr, ptr %7, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %184, i32 0, i32 10
  store i32 0, ptr %185, align 8, !tbaa !16
  br label %186

186:                                              ; preds = %183
  br label %187

187:                                              ; preds = %186
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

188:                                              ; preds = %5
  store i32 2, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %189

189:                                              ; preds = %188, %187, %167, %131, %91, %36, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %190 = load i32, ptr %6, align 4
  ret i32 %190
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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, !6, i64 64}
!22 = !{!14, !10, i64 48}
!23 = !{!14, !6, i64 0}
!24 = !{!25, !12, i64 36}
!25 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40}
!26 = !{!7, !7, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!25, !12, i64 28}
!30 = !{!25, !12, i64 4}


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

declare i32 @HAL_GetTick() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @I2C_TransferConfig(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_WaitOnSTOPFlagUntilTimeout(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_I2C_Master_Receive(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i16 noundef zeroext %3, i32 noundef %4) local_unnamed_addr #1 {
  %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 %.loopexit

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 %.loopexit, label %13

13:                                               ; preds = %9
  store i32 1, ptr %10, align 8, !tbaa !13
  %14 = tail call i32 @HAL_GetTick() #2
  %15 = tail call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef 32768, i32 noundef 1, i32 noundef 25, i32 noundef %14)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %16, label %.loopexit

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

24:                                               ; preds = %16
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 255, ptr %25, align 8, !tbaa !19
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext -1, i32 noundef 16777216, i32 noundef -2147474432)
  br label %30

26:                                               ; preds = %16
  %27 = load volatile i16, ptr %20, align 2, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 %27, ptr %28, align 8, !tbaa !19
  %29 = trunc i16 %27 to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %29, i32 noundef 33554432, i32 noundef -2147474432)
  br label %30

30:                                               ; preds = %26, %24
  %31 = load volatile i16, ptr %20, align 2, !tbaa !17
  %.not5560 = icmp eq i16 %31, 0
  br i1 %.not5560, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %30
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  br label %33

33:                                               ; preds = %.lr.ph, %58
  %34 = tail call i32 @I2C_WaitOnRXNEFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef %4, i32 noundef %14)
  %.not57 = icmp eq i32 %34, 0
  br i1 %.not57, label %35, label %.loopexit

35:                                               ; preds = %33
  %36 = load ptr, ptr %0, align 8, !tbaa !20
  %37 = getelementptr inbounds i8, ptr %36, i64 36
  %38 = load volatile i32, ptr %37, align 4, !tbaa !21
  %39 = trunc i32 %38 to i8
  %40 = load ptr, ptr %19, align 8, !tbaa !16
  store i8 %39, ptr %40, align 1, !tbaa !23
  %41 = load ptr, ptr %19, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %41, i64 1
  store ptr %42, ptr %19, align 8, !tbaa !16
  %43 = load i16, ptr %32, align 8, !tbaa !19
  %44 = add i16 %43, -1
  store i16 %44, ptr %32, align 8, !tbaa !19
  %45 = load volatile i16, ptr %20, align 2, !tbaa !17
  %46 = add i16 %45, -1
  store volatile i16 %46, ptr %20, align 2, !tbaa !17
  %47 = load volatile i16, ptr %20, align 2, !tbaa !17
  %.not58 = icmp ne i16 %47, 0
  %48 = icmp eq i16 %44, 0
  %or.cond = select i1 %.not58, i1 %48, i1 false
  br i1 %or.cond, label %49, label %58

49:                                               ; preds = %35
  %50 = tail call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef 128, i32 noundef 0, i32 noundef %4, i32 noundef %14)
  %.not59 = icmp eq i32 %50, 0
  br i1 %.not59, label %51, label %.loopexit

51:                                               ; preds = %49
  %52 = load volatile i16, ptr %20, align 2, !tbaa !17
  %53 = icmp ugt i16 %52, 255
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  store i16 255, ptr %32, align 8, !tbaa !19
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext -1, i32 noundef 16777216, i32 noundef 0)
  br label %58

55:                                               ; preds = %51
  %56 = load volatile i16, ptr %20, align 2, !tbaa !17
  store i16 %56, ptr %32, align 8, !tbaa !19
  %57 = trunc i16 %56 to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %57, i32 noundef 33554432, i32 noundef 0)
  br label %58

58:                                               ; preds = %54, %55, %35
  %59 = load volatile i16, ptr %20, align 2, !tbaa !17
  %.not55 = icmp eq i16 %59, 0
  br i1 %.not55, label %._crit_edge, label %33, !llvm.loop !24

._crit_edge:                                      ; preds = %58, %30
  %60 = tail call i32 @I2C_WaitOnSTOPFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef %4, i32 noundef %14)
  %.not56 = icmp eq i32 %60, 0
  br i1 %.not56, label %61, label %.loopexit

61:                                               ; preds = %._crit_edge
  %62 = load ptr, ptr %0, align 8, !tbaa !20
  %63 = getelementptr inbounds i8, ptr %62, i64 28
  store volatile i32 32, ptr %63, align 4, !tbaa !26
  %64 = getelementptr inbounds i8, ptr %62, i64 4
  %65 = load volatile i32, ptr %64, align 4, !tbaa !27
  %66 = and i32 %65, -33495040
  store volatile i32 %66, ptr %64, align 4, !tbaa !27
  store volatile i32 32, ptr %6, align 4, !tbaa !5
  store volatile i32 0, ptr %17, align 8, !tbaa !14
  store i32 0, ptr %10, align 8, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %49, %33, %5, %._crit_edge, %13, %9, %61
  %.0 = phi i32 [ 0, %61 ], [ 2, %9 ], [ 1, %13 ], [ 1, %._crit_edge ], [ 2, %5 ], [ 1, %33 ], [ 1, %49 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_WaitOnRXNEFlagUntilTimeout(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #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 #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, !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, !7, i64 64}
!19 = !{!6, !12, i64 48}
!20 = !{!6, !7, i64 0}
!21 = !{!22, !11, i64 36}
!22 = !{!"", !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}
!23 = !{!8, !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!22, !11, i64 28}
!27 = !{!22, !11, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass