; LLVM IR from koshkin-sergey/mbOS :: Middleware/I2C (i2c_master)

; 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_com = type { i32, i32, i32, i32, %struct.osSemaphore_s }
%struct.osSemaphore_s = type { i8, i8, i8, i8, %struct.queue_s, %struct.queue_s, i16, i16, ptr }
%struct.queue_s = type { ptr, ptr }
%struct.I2C_PortResources = type { ptr, ptr, ptr }
%struct.I2C_PortInfo = type { %struct.I2C_PortStatus, ptr, %struct.osSemaphore_s, %struct.osEventFlags_s }
%struct.I2C_PortStatus = type { i32 }
%struct.osEventFlags_s = type { i8, i8, i8, i8, %struct.queue_s, %struct.queue_s, i32, ptr }
%struct._DRIVER_I2C = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; 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 ptr @GetPort(i32 noundef) #1

declare i32 @osSemaphoreRelease(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @osSemaphoreAcquire(ptr noundef, i32 noundef) #2

declare i32 @osKernelGetTickCount() #2

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

declare i32 @osDelay(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @I2C_Read(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %28, label %19

19:                                               ; preds = %5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %28, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp ugt i32 %26, 4
  br i1 %27, label %28, label %29

28:                                               ; preds = %25, %22, %19, %5
  store i32 -4, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %157

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.i2c_com, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = call ptr @GetPort(i32 noundef %32)
  store ptr %33, ptr %16, align 8, !tbaa !5
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %156

37:                                               ; preds = %29
  %38 = load ptr, ptr %16, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.I2C_PortResources, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = getelementptr inbounds %struct.I2C_PortInfo, ptr %40, i32 0, i32 2
  %42 = call i32 @osSemaphoreAcquire(ptr noundef %41, i32 noundef -1)
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %153

44:                                               ; preds = %37
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.I2C_PortResources, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = getelementptr inbounds %struct.I2C_PortInfo, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = icmp ne ptr %49, %50
  br i1 %51, label %52, label %67

52:                                               ; preds = %44
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.I2C_PortResources, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !22
  %56 = getelementptr inbounds %struct._DRIVER_I2C, ptr %55, i32 0, i32 10
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.i2c_com, ptr %58, i32 0, i32 3
  %60 = load i32, ptr %59, align 4, !tbaa !25
  %61 = call i32 %57(i32 noundef 2, i32 noundef %60)
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.I2C_PortResources, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = getelementptr inbounds %struct.I2C_PortInfo, ptr %65, i32 0, i32 1
  store ptr %62, ptr %66, align 8, !tbaa !18
  br label %67

67:                                               ; preds = %52, %44
  %68 = call i32 @osKernelGetTickCount()
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.i2c_com, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !26
  %72 = add i32 %68, %71
  store i32 %72, ptr %14, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %126, %67
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %102

76:                                               ; preds = %73
  %77 = load ptr, ptr %16, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.I2C_PortResources, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !22
  %80 = getelementptr inbounds %struct._DRIVER_I2C, ptr %79, i32 0, i32 5
  %81 = load ptr, ptr %80, align 8, !tbaa !27
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.i2c_com, ptr %82, i32 0, i32 1
  %84 = load i32, ptr %83, align 4, !tbaa !28
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = call i32 %81(i32 noundef %84, ptr noundef %8, i32 noundef %85, i1 noundef zeroext true)
  store i32 %86, ptr %13, align 4, !tbaa !9
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = load i32, ptr %13, align 4, !tbaa !9
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.i2c_com, ptr %89, i32 0, i32 2
  %91 = load i32, ptr %90, align 8, !tbaa !26
  %92 = call i32 @WaitOperation(ptr noundef %87, i32 noundef %88, i32 noundef %91)
  store i32 %92, ptr %12, align 4, !tbaa !9
  %93 = load i32, ptr %12, align 4, !tbaa !9
  %94 = icmp eq i32 %93, -2
  br i1 %94, label %95, label %97

95:                                               ; preds = %76
  %96 = call i32 @osDelay(i32 noundef 1)
  br label %126

97:                                               ; preds = %76
  %98 = load i32, ptr %12, align 4, !tbaa !9
  %99 = icmp ne i32 %98, 0
  br i1 %99, label %100, label %101

100:                                              ; preds = %97
  br label %131

101:                                              ; preds = %97
  br label %102

102:                                              ; preds = %101, %73
  %103 = load ptr, ptr %16, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.I2C_PortResources, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !22
  %106 = getelementptr inbounds %struct._DRIVER_I2C, ptr %105, i32 0, i32 6
  %107 = load ptr, ptr %106, align 8, !tbaa !29
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.i2c_com, ptr %108, i32 0, i32 1
  %110 = load i32, ptr %109, align 4, !tbaa !28
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = call i32 %107(i32 noundef %110, ptr noundef %111, i32 noundef %112, i1 noundef zeroext false)
  store i32 %113, ptr %13, align 4, !tbaa !9
  %114 = load ptr, ptr %16, align 8, !tbaa !5
  %115 = load i32, ptr %13, align 4, !tbaa !9
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.i2c_com, ptr %116, i32 0, i32 2
  %118 = load i32, ptr %117, align 8, !tbaa !26
  %119 = call i32 @WaitOperation(ptr noundef %114, i32 noundef %115, i32 noundef %118)
  store i32 %119, ptr %12, align 4, !tbaa !9
  %120 = load i32, ptr %12, align 4, !tbaa !9
  %121 = icmp eq i32 %120, -2
  br i1 %121, label %122, label %124

122:                                              ; preds = %102
  %123 = call i32 @osDelay(i32 noundef 1)
  br label %125

124:                                              ; preds = %102
  br label %131

125:                                              ; preds = %122
  br label %126

126:                                              ; preds = %125, %95
  %127 = call i32 @osKernelGetTickCount()
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = sub nsw i32 %127, %128
  %130 = icmp slt i32 %129, 0
  br i1 %130, label %73, label %131, !llvm.loop !30

131:                                              ; preds = %126, %124, %100
  %132 = load i32, ptr %12, align 4, !tbaa !9
  %133 = icmp eq i32 %132, -2
  br i1 %133, label %134, label %147

134:                                              ; preds = %131
  %135 = load ptr, ptr %16, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.I2C_PortResources, ptr %135, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8, !tbaa !22
  %138 = getelementptr inbounds %struct._DRIVER_I2C, ptr %137, i32 0, i32 10
  %139 = load ptr, ptr %138, align 8, !tbaa !23
  %140 = call i32 %139(i32 noundef 4, i32 noundef 0)
  %141 = load ptr, ptr %16, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.I2C_PortResources, ptr %141, i32 0, i32 0
  %143 = load ptr, ptr %142, align 8, !tbaa !22
  %144 = getelementptr inbounds %struct._DRIVER_I2C, ptr %143, i32 0, i32 10
  %145 = load ptr, ptr %144, align 8, !tbaa !23
  %146 = call i32 %145(i32 noundef 3, i32 noundef 0)
  br label %147

147:                                              ; preds = %134, %131
  %148 = load ptr, ptr %16, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.I2C_PortResources, ptr %148, i32 0, i32 2
  %150 = load ptr, ptr %149, align 8, !tbaa !16
  %151 = getelementptr inbounds %struct.I2C_PortInfo, ptr %150, i32 0, i32 2
  %152 = call i32 @osSemaphoreRelease(ptr noundef %151)
  br label %154

153:                                              ; preds = %37
  store i32 -1, ptr %12, align 4, !tbaa !9
  br label %154

154:                                              ; preds = %153, %147
  %155 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %155, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %156

156:                                              ; preds = %154, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %157

157:                                              ; preds = %156, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %158 = load i32, ptr %6, align 4
  ret i32 %158
}

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 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"i2c_com", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16}
!13 = !{!"osSemaphore_s", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !14, i64 8, !14, i64 24, !15, i64 40, !15, i64 42, !6, i64 48}
!14 = !{!"queue_s", !6, i64 0, !6, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !6, i64 16}
!17 = !{!"I2C_PortResources", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!19, !6, i64 8}
!19 = !{!"I2C_PortInfo", !20, i64 0, !6, i64 8, !13, i64 16, !21, i64 72}
!20 = !{!"I2C_PortStatus", !10, i64 0, !10, i64 0}
!21 = !{!"osEventFlags_s", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !14, i64 8, !14, i64 24, !10, i64 40, !6, i64 48}
!22 = !{!17, !6, i64 0}
!23 = !{!24, !6, i64 80}
!24 = !{!"_DRIVER_I2C", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!25 = !{!12, !10, i64 12}
!26 = !{!12, !10, i64 8}
!27 = !{!24, !6, i64 40}
!28 = !{!12, !10, i64 4}
!29 = !{!24, !6, i64 48}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; 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 ptr @GetPort(i32 noundef) local_unnamed_addr #0

declare i32 @osSemaphoreRelease(ptr noundef) local_unnamed_addr #1

declare i32 @osSemaphoreAcquire(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @osKernelGetTickCount() local_unnamed_addr #1

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

declare i32 @osDelay(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @I2C_Read(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca i32, align 4
  store i32 %1, ptr %6, align 4, !tbaa !5
  %7 = icmp eq ptr %0, null
  %8 = icmp eq ptr %3, null
  %or.cond = or i1 %7, %8
  %9 = icmp eq i32 %4, 0
  %or.cond3 = or i1 %or.cond, %9
  %10 = icmp ugt i32 %2, 4
  %or.cond5 = or i1 %10, %or.cond3
  br i1 %or.cond5, label %83, label %11

11:                                               ; preds = %5
  %12 = load i32, ptr %0, align 8, !tbaa !9
  %13 = tail call ptr @GetPort(i32 noundef %12)
  %14 = icmp eq ptr %13, null
  br i1 %14, label %83, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %13, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = tail call i32 @osSemaphoreAcquire(ptr noundef nonnull %18, i32 noundef -1) #2
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %83

21:                                               ; preds = %15
  %22 = load ptr, ptr %16, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %.not = icmp eq ptr %24, %0
  br i1 %.not, label %34, label %25

25:                                               ; preds = %21
  %26 = load ptr, ptr %13, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %26, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %0, i64 12
  %30 = load i32, ptr %29, align 4, !tbaa !24
  %31 = tail call i32 %28(i32 noundef 2, i32 noundef %30) #2
  %32 = load ptr, ptr %16, align 8, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  store ptr %0, ptr %33, align 8, !tbaa !17
  br label %34

34:                                               ; preds = %25, %21
  %35 = tail call i32 @osKernelGetTickCount() #2
  %36 = getelementptr inbounds i8, ptr %0, i64 8
  %37 = load i32, ptr %36, align 8, !tbaa !25
  %38 = add i32 %37, %35
  %.not53 = icmp eq i32 %2, 0
  %39 = getelementptr inbounds i8, ptr %0, i64 4
  br i1 %.not53, label %.split.us, label %.split

.split.us:                                        ; preds = %34, %48
  %40 = load ptr, ptr %13, align 8, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %40, i64 48
  %42 = load ptr, ptr %41, align 8, !tbaa !26
  %43 = load i32, ptr %39, align 4, !tbaa !27
  %44 = tail call i32 %42(i32 noundef %43, ptr noundef %3, i32 noundef %4, i1 noundef zeroext false) #2
  %45 = load i32, ptr %36, align 8, !tbaa !25
  %46 = tail call i32 @WaitOperation(ptr noundef nonnull %13, i32 noundef %44, i32 noundef %45)
  %47 = icmp eq i32 %46, -2
  br i1 %47, label %48, label %.thread58

48:                                               ; preds = %.split.us
  %49 = tail call i32 @osDelay(i32 noundef 1) #2
  %50 = tail call i32 @osKernelGetTickCount() #2
  %51 = icmp slt i32 %50, %38
  br i1 %51, label %.split.us, label %.thread, !llvm.loop !28

.split:                                           ; preds = %34, %68
  %52 = load ptr, ptr %13, align 8, !tbaa !21
  %53 = getelementptr inbounds i8, ptr %52, i64 40
  %54 = load ptr, ptr %53, align 8, !tbaa !30
  %55 = load i32, ptr %39, align 4, !tbaa !27
  %56 = call i32 %54(i32 noundef %55, ptr noundef nonnull %6, i32 noundef %2, i1 noundef zeroext true) #2
  %57 = load i32, ptr %36, align 8, !tbaa !25
  %58 = call i32 @WaitOperation(ptr noundef nonnull %13, i32 noundef %56, i32 noundef %57)
  switch i32 %58, label %.thread58 [
    i32 -2, label %68
    i32 0, label %59
  ]

59:                                               ; preds = %.split
  %60 = load ptr, ptr %13, align 8, !tbaa !21
  %61 = getelementptr inbounds i8, ptr %60, i64 48
  %62 = load ptr, ptr %61, align 8, !tbaa !26
  %63 = load i32, ptr %39, align 4, !tbaa !27
  %64 = call i32 %62(i32 noundef %63, ptr noundef %3, i32 noundef %4, i1 noundef zeroext false) #2
  %65 = load i32, ptr %36, align 8, !tbaa !25
  %66 = call i32 @WaitOperation(ptr noundef nonnull %13, i32 noundef %64, i32 noundef %65)
  %67 = icmp eq i32 %66, -2
  br i1 %67, label %68, label %.thread58

68:                                               ; preds = %59, %.split
  %69 = call i32 @osDelay(i32 noundef 1) #2
  %70 = call i32 @osKernelGetTickCount() #2
  %71 = icmp slt i32 %70, %38
  br i1 %71, label %.split, label %.thread, !llvm.loop !28

.thread:                                          ; preds = %68, %48
  %72 = load ptr, ptr %13, align 8, !tbaa !21
  %73 = getelementptr inbounds i8, ptr %72, i64 80
  %74 = load ptr, ptr %73, align 8, !tbaa !22
  %75 = call i32 %74(i32 noundef 4, i32 noundef 0) #2
  %76 = load ptr, ptr %13, align 8, !tbaa !21
  %77 = getelementptr inbounds i8, ptr %76, i64 80
  %78 = load ptr, ptr %77, align 8, !tbaa !22
  %79 = call i32 %78(i32 noundef 3, i32 noundef 0) #2
  br label %.thread58

.thread58:                                        ; preds = %59, %.split, %.split.us, %.thread
  %.14356 = phi i32 [ -2, %.thread ], [ %46, %.split.us ], [ %58, %.split ], [ %66, %59 ]
  %80 = load ptr, ptr %16, align 8, !tbaa !15
  %81 = getelementptr inbounds i8, ptr %80, i64 16
  %82 = call i32 @osSemaphoreRelease(ptr noundef nonnull %81) #2
  br label %83

83:                                               ; preds = %11, %15, %.thread58, %5
  %.1 = phi i32 [ -4, %5 ], [ -1, %11 ], [ %.14356, %.thread58 ], [ -1, %15 ]
  ret i32 %.1
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"i2c_com", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !11, i64 16}
!11 = !{!"osSemaphore_s", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !12, i64 8, !12, i64 24, !14, i64 40, !14, i64 42, !13, i64 48}
!12 = !{!"queue_s", !13, i64 0, !13, i64 8}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !13, i64 16}
!16 = !{!"I2C_PortResources", !13, i64 0, !13, i64 8, !13, i64 16}
!17 = !{!18, !13, i64 8}
!18 = !{!"I2C_PortInfo", !19, i64 0, !13, i64 8, !11, i64 16, !20, i64 72}
!19 = !{!"I2C_PortStatus", !6, i64 0, !6, i64 0}
!20 = !{!"osEventFlags_s", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !12, i64 8, !12, i64 24, !6, i64 40, !13, i64 48}
!21 = !{!16, !13, i64 0}
!22 = !{!23, !13, i64 80}
!23 = !{!"_DRIVER_I2C", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88}
!24 = !{!10, !6, i64 12}
!25 = !{!10, !6, i64 8}
!26 = !{!23, !13, i64 48}
!27 = !{!10, !6, i64 4}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!23, !13, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass