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

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

22:                                               ; preds = %7
  %23 = load ptr, ptr %13, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %22
  %26 = load i16, ptr %14, align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %25, %22
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %30, i32 0, i32 13
  store volatile i32 512, ptr %31, align 4, !tbaa !16
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

32:                                               ; preds = %25
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %34, i32 0, i32 10
  %36 = load i32, ptr %35, align 8, !tbaa !17
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  store i32 2, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

39:                                               ; preds = %33
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %40, i32 0, i32 10
  store i32 1, ptr %41, align 8, !tbaa !17
  br label %42

42:                                               ; preds = %39
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = call i32 @HAL_GetTick()
  store i32 %45, ptr %16, align 4, !tbaa !11
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i32, ptr %16, align 4, !tbaa !11
  %48 = call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef %46, i32 noundef 32768, i32 noundef 1, i32 noundef 25, i32 noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

51:                                               ; preds = %44
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %52, i32 0, i32 11
  store volatile i32 33, ptr %53, align 4, !tbaa !13
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %54, i32 0, i32 12
  store volatile i32 64, ptr %55, align 8, !tbaa !18
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %56, i32 0, i32 13
  store volatile i32 0, ptr %57, align 4, !tbaa !16
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %59, i32 0, i32 2
  store ptr %58, ptr %60, align 8, !tbaa !19
  %61 = load i16, ptr %14, align 2, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %62, i32 0, i32 4
  store volatile i16 %61, ptr %63, align 2, !tbaa !20
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %64, i32 0, i32 7
  store ptr null, ptr %65, align 8, !tbaa !21
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i16, ptr %10, align 2, !tbaa !9
  %68 = load i16, ptr %11, align 2, !tbaa !9
  %69 = load i16, ptr %12, align 2, !tbaa !9
  %70 = load i32, ptr %15, align 4, !tbaa !11
  %71 = load i32, ptr %16, align 4, !tbaa !11
  %72 = call i32 @I2C_RequestMemoryWrite(ptr noundef %66, i16 noundef zeroext %67, i16 noundef zeroext %68, i16 noundef zeroext %69, i32 noundef %70, i32 noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %80

74:                                               ; preds = %51
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %76, i32 0, i32 10
  store i32 0, ptr %77, align 8, !tbaa !17
  br label %78

78:                                               ; preds = %75
  br label %79

79:                                               ; preds = %78
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

80:                                               ; preds = %51
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %81, i32 0, i32 4
  %83 = load volatile i16, ptr %82, align 2, !tbaa !20
  %84 = zext i16 %83 to i32
  %85 = icmp ugt i32 %84, 255
  br i1 %85, label %86, label %95

86:                                               ; preds = %80
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %87, i32 0, i32 3
  store i16 255, ptr %88, align 8, !tbaa !22
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i16, ptr %10, align 2, !tbaa !9
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %91, i32 0, i32 3
  %93 = load i16, ptr %92, align 8, !tbaa !22
  %94 = trunc i16 %93 to i8
  call void @I2C_TransferConfig(ptr noundef %89, i16 noundef zeroext %90, i8 noundef zeroext %94, i32 noundef 16777216, i32 noundef 0)
  br label %107

95:                                               ; preds = %80
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %96, i32 0, i32 4
  %98 = load volatile i16, ptr %97, align 2, !tbaa !20
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %99, i32 0, i32 3
  store i16 %98, ptr %100, align 8, !tbaa !22
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = load i16, ptr %10, align 2, !tbaa !9
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %103, i32 0, i32 3
  %105 = load i16, ptr %104, align 8, !tbaa !22
  %106 = trunc i16 %105 to i8
  call void @I2C_TransferConfig(ptr noundef %101, i16 noundef zeroext %102, i8 noundef zeroext %106, i32 noundef 33554432, i32 noundef 0)
  br label %107

107:                                              ; preds = %95, %86
  br label %108

108:                                              ; preds = %184, %107
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  %110 = load i32, ptr %15, align 4, !tbaa !11
  %111 = load i32, ptr %16, align 4, !tbaa !11
  %112 = call i32 @I2C_WaitOnTXISFlagUntilTimeout(ptr noundef %109, i32 noundef %110, i32 noundef %111)
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %115

114:                                              ; preds = %108
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

115:                                              ; preds = %108
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %117, align 8, !tbaa !19
  %119 = load i8, ptr %118, align 1, !tbaa !23
  %120 = zext i8 %119 to i32
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %121, i32 0, i32 0
  %123 = load ptr, ptr %122, align 8, !tbaa !24
  %124 = getelementptr inbounds %struct.I2C_TypeDef, ptr %123, i32 0, i32 10
  store volatile i32 %120, ptr %124, align 4, !tbaa !25
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %125, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !19
  %128 = getelementptr inbounds i8, ptr %127, i32 1
  store ptr %128, ptr %126, align 8, !tbaa !19
  %129 = load ptr, ptr %9, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %129, i32 0, i32 4
  %131 = load volatile i16, ptr %130, align 2, !tbaa !20
  %132 = add i16 %131, -1
  store volatile i16 %132, ptr %130, align 2, !tbaa !20
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %133, i32 0, i32 3
  %135 = load i16, ptr %134, align 8, !tbaa !22
  %136 = add i16 %135, -1
  store i16 %136, ptr %134, align 8, !tbaa !22
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %137, i32 0, i32 4
  %139 = load volatile i16, ptr %138, align 2, !tbaa !20
  %140 = zext i16 %139 to i32
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %142, label %183

142:                                              ; preds = %115
  %143 = load ptr, ptr %9, 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 = zext i16 %145 to i32
  %147 = icmp eq i32 %146, 0
  br i1 %147, label %148, label %183

148:                                              ; preds = %142
  %149 = load ptr, ptr %9, align 8, !tbaa !5
  %150 = load i32, ptr %15, align 4, !tbaa !11
  %151 = load i32, ptr %16, align 4, !tbaa !11
  %152 = call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef %149, i32 noundef 128, i32 noundef 0, i32 noundef %150, i32 noundef %151)
  %153 = icmp ne i32 %152, 0
  br i1 %153, label %154, label %155

154:                                              ; preds = %148
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

155:                                              ; preds = %148
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %156, i32 0, i32 4
  %158 = load volatile i16, ptr %157, align 2, !tbaa !20
  %159 = zext i16 %158 to i32
  %160 = icmp ugt i32 %159, 255
  br i1 %160, label %161, label %170

161:                                              ; preds = %155
  %162 = load ptr, ptr %9, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %162, i32 0, i32 3
  store i16 255, ptr %163, align 8, !tbaa !22
  %164 = load ptr, ptr %9, align 8, !tbaa !5
  %165 = load i16, ptr %10, align 2, !tbaa !9
  %166 = load ptr, ptr %9, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %166, i32 0, i32 3
  %168 = load i16, ptr %167, align 8, !tbaa !22
  %169 = trunc i16 %168 to i8
  call void @I2C_TransferConfig(ptr noundef %164, i16 noundef zeroext %165, i8 noundef zeroext %169, i32 noundef 16777216, i32 noundef 0)
  br label %182

170:                                              ; preds = %155
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %171, i32 0, i32 4
  %173 = load volatile i16, ptr %172, align 2, !tbaa !20
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %174, i32 0, i32 3
  store i16 %173, ptr %175, align 8, !tbaa !22
  %176 = load ptr, ptr %9, align 8, !tbaa !5
  %177 = load i16, ptr %10, align 2, !tbaa !9
  %178 = load ptr, ptr %9, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %178, i32 0, i32 3
  %180 = load i16, ptr %179, align 8, !tbaa !22
  %181 = trunc i16 %180 to i8
  call void @I2C_TransferConfig(ptr noundef %176, i16 noundef zeroext %177, i8 noundef zeroext %181, i32 noundef 33554432, i32 noundef 0)
  br label %182

182:                                              ; preds = %170, %161
  br label %183

183:                                              ; preds = %182, %142, %115
  br label %184

184:                                              ; preds = %183
  %185 = load ptr, ptr %9, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %185, i32 0, i32 4
  %187 = load volatile i16, ptr %186, align 2, !tbaa !20
  %188 = zext i16 %187 to i32
  %189 = icmp ugt i32 %188, 0
  br i1 %189, label %108, label %190, !llvm.loop !27

190:                                              ; preds = %184
  %191 = load ptr, ptr %9, align 8, !tbaa !5
  %192 = load i32, ptr %15, align 4, !tbaa !11
  %193 = load i32, ptr %16, align 4, !tbaa !11
  %194 = call i32 @I2C_WaitOnSTOPFlagUntilTimeout(ptr noundef %191, i32 noundef %192, i32 noundef %193)
  %195 = icmp ne i32 %194, 0
  br i1 %195, label %196, label %197

196:                                              ; preds = %190
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

197:                                              ; preds = %190
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %198, i32 0, i32 0
  %200 = load ptr, ptr %199, align 8, !tbaa !24
  %201 = getelementptr inbounds %struct.I2C_TypeDef, ptr %200, i32 0, i32 7
  store volatile i32 32, ptr %201, align 4, !tbaa !29
  %202 = load ptr, ptr %9, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !24
  %205 = getelementptr inbounds %struct.I2C_TypeDef, ptr %204, i32 0, i32 1
  %206 = load volatile i32, ptr %205, align 4, !tbaa !30
  %207 = and i32 %206, -33495040
  store volatile i32 %207, ptr %205, align 4, !tbaa !30
  %208 = load ptr, ptr %9, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %208, i32 0, i32 11
  store volatile i32 32, ptr %209, align 4, !tbaa !13
  %210 = load ptr, ptr %9, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %210, i32 0, i32 12
  store volatile i32 0, ptr %211, align 8, !tbaa !18
  br label %212

212:                                              ; preds = %197
  %213 = load ptr, ptr %9, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.__I2C_HandleTypeDef, ptr %213, i32 0, i32 10
  store i32 0, ptr %214, align 8, !tbaa !17
  br label %215

215:                                              ; preds = %212
  br label %216

216:                                              ; preds = %215
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

217:                                              ; preds = %7
  store i32 2, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %218

218:                                              ; preds = %217, %216, %196, %154, %114, %79, %50, %38, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %219 = load i32, ptr %8, align 4
  ret i32 %219
}

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_RequestMemoryWrite(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, 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 100}
!17 = !{!14, !12, i64 88}
!18 = !{!14, !12, i64 96}
!19 = !{!14, !6, i64 40}
!20 = !{!14, !10, i64 50}
!21 = !{!14, !6, i64 64}
!22 = !{!14, !10, i64 48}
!23 = !{!7, !7, i64 0}
!24 = !{!14, !6, i64 0}
!25 = !{!26, !12, i64 40}
!26 = !{!"", !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}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!26, !12, i64 28}
!30 = !{!26, !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_WaitOnTXISFlagUntilTimeout(ptr noundef, 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_Mem_Write(ptr noundef %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, ptr noundef %4, i16 noundef zeroext %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = getelementptr inbounds i8, ptr %0, i64 92
  %9 = load volatile i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 32
  br i1 %10, label %11, label %.loopexit

11:                                               ; preds = %7
  %12 = icmp eq ptr %4, null
  %13 = icmp eq i16 %5, 0
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %14, label %16

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 512, ptr %15, align 4, !tbaa !13
  br label %.loopexit

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %.loopexit, label %20

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

23:                                               ; preds = %20
  store volatile i32 33, ptr %8, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 96
  store volatile i32 64, ptr %24, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %0, i64 100
  store volatile i32 0, ptr %25, align 4, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %4, ptr %26, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %0, i64 50
  store volatile i16 %5, ptr %27, align 2, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr null, ptr %28, align 8, !tbaa !18
  %29 = tail call i32 @I2C_RequestMemoryWrite(ptr noundef nonnull %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i32 noundef %6, i32 noundef %21)
  %.not68 = icmp eq i32 %29, 0
  br i1 %.not68, label %31, label %30

30:                                               ; preds = %23
  store i32 0, ptr %17, align 8, !tbaa !14
  br label %.loopexit

31:                                               ; preds = %23
  %32 = load volatile i16, ptr %27, align 2, !tbaa !17
  %33 = icmp ugt i16 %32, 255
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 255, ptr %35, 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 %40

36:                                               ; preds = %31
  %37 = load volatile i16, ptr %27, align 2, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %0, i64 48
  store i16 %37, ptr %38, align 8, !tbaa !19
  %39 = trunc i16 %37 to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %39, i32 noundef 33554432, i32 noundef 0)
  br label %40

40:                                               ; preds = %36, %34
  %41 = getelementptr inbounds i8, ptr %0, i64 48
  br label %42

42:                                               ; preds = %66, %40
  %43 = tail call i32 @I2C_WaitOnTXISFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef %6, i32 noundef %21)
  %.not69 = icmp eq i32 %43, 0
  br i1 %.not69, label %44, label %.loopexit

44:                                               ; preds = %42
  %45 = load ptr, ptr %26, align 8, !tbaa !16
  %46 = load i8, ptr %45, align 1, !tbaa !20
  %47 = zext i8 %46 to i32
  %48 = load ptr, ptr %0, align 8, !tbaa !21
  %49 = getelementptr inbounds i8, ptr %48, i64 40
  store volatile i32 %47, ptr %49, align 4, !tbaa !22
  %50 = getelementptr inbounds i8, ptr %45, i64 1
  store ptr %50, ptr %26, align 8, !tbaa !16
  %51 = load volatile i16, ptr %27, align 2, !tbaa !17
  %52 = add i16 %51, -1
  store volatile i16 %52, ptr %27, align 2, !tbaa !17
  %53 = load i16, ptr %41, align 8, !tbaa !19
  %54 = add i16 %53, -1
  store i16 %54, ptr %41, align 8, !tbaa !19
  %55 = load volatile i16, ptr %27, align 2, !tbaa !17
  %.not70 = icmp ne i16 %55, 0
  %56 = icmp eq i16 %54, 0
  %or.cond74 = select i1 %.not70, i1 %56, i1 false
  br i1 %or.cond74, label %57, label %66

57:                                               ; preds = %44
  %58 = tail call i32 @I2C_WaitOnFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef 128, i32 noundef 0, i32 noundef %6, i32 noundef %21)
  %.not71 = icmp eq i32 %58, 0
  br i1 %.not71, label %59, label %.loopexit

59:                                               ; preds = %57
  %60 = load volatile i16, ptr %27, align 2, !tbaa !17
  %61 = icmp ugt i16 %60, 255
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i16 255, ptr %41, 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 %66

63:                                               ; preds = %59
  %64 = load volatile i16, ptr %27, align 2, !tbaa !17
  store i16 %64, ptr %41, align 8, !tbaa !19
  %65 = trunc i16 %64 to i8
  tail call void @I2C_TransferConfig(ptr noundef nonnull %0, i16 noundef zeroext %1, i8 noundef zeroext %65, i32 noundef 33554432, i32 noundef 0)
  br label %66

66:                                               ; preds = %44, %63, %62
  %67 = load volatile i16, ptr %27, align 2, !tbaa !17
  %.not72 = icmp eq i16 %67, 0
  br i1 %.not72, label %68, label %42, !llvm.loop !24

68:                                               ; preds = %66
  %69 = tail call i32 @I2C_WaitOnSTOPFlagUntilTimeout(ptr noundef nonnull %0, i32 noundef %6, i32 noundef %21)
  %.not73 = icmp eq i32 %69, 0
  br i1 %.not73, label %70, label %.loopexit

70:                                               ; preds = %68
  %71 = load ptr, ptr %0, align 8, !tbaa !21
  %72 = getelementptr inbounds i8, ptr %71, i64 28
  store volatile i32 32, ptr %72, align 4, !tbaa !26
  %73 = getelementptr inbounds i8, ptr %71, i64 4
  %74 = load volatile i32, ptr %73, align 4, !tbaa !27
  %75 = and i32 %74, -33495040
  store volatile i32 %75, ptr %73, align 4, !tbaa !27
  store volatile i32 32, ptr %8, align 4, !tbaa !5
  store volatile i32 0, ptr %24, align 8, !tbaa !15
  store i32 0, ptr %17, align 8, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %57, %42, %7, %68, %20, %16, %70, %30, %14
  %.0 = phi i32 [ 1, %14 ], [ 1, %30 ], [ 0, %70 ], [ 2, %16 ], [ 1, %20 ], [ 1, %68 ], [ 2, %7 ], [ 1, %42 ], [ 1, %57 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @I2C_RequestMemoryWrite(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, 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 100}
!14 = !{!6, !11, i64 88}
!15 = !{!6, !11, i64 96}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !12, i64 50}
!18 = !{!6, !7, i64 64}
!19 = !{!6, !12, i64 48}
!20 = !{!8, !8, i64 0}
!21 = !{!6, !7, i64 0}
!22 = !{!23, !11, i64 40}
!23 = !{!"", !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}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!23, !11, i64 28}
!27 = !{!23, !11, i64 4}


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