; LLVM IR from lshil00/Quadruped_robot :: 单片机控制代码/Quadruped_Robot/Drivers/CMSIS/RTOS2/Template (cmsis_os1)

; 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.os_mailQ_def = type { i32, i32, ptr, %struct.osMemoryPoolAttr_t, %struct.osMessageQueueAttr_t }
%struct.osMemoryPoolAttr_t = type { ptr, i32, ptr, i32, ptr, i32 }
%struct.osMessageQueueAttr_t = type { ptr, i32, ptr, i32, ptr, i32 }
%struct.os_mail_queue_s = type { 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @osMemoryPoolNew(i32 noundef, i32 noundef, ptr noundef) #1

declare ptr @osMessageQueueNew(i32 noundef, i32 noundef, ptr noundef) #1

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

11:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.os_mailQ_def, ptr %13, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

19:                                               ; preds = %12
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.os_mailQ_def, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.os_mailQ_def, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.os_mailQ_def, ptr %26, i32 0, i32 3
  %28 = call ptr @osMemoryPoolNew(i32 noundef %22, i32 noundef %25, ptr noundef %27)
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.os_mail_queue_s, ptr %29, i32 0, i32 0
  store ptr %28, ptr %30, align 8, !tbaa !15
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.os_mailQ_def, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.os_mailQ_def, ptr %34, i32 0, i32 4
  %36 = call ptr @osMessageQueueNew(i32 noundef %33, i32 noundef 8, ptr noundef %35)
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.os_mail_queue_s, ptr %37, i32 0, i32 1
  store ptr %36, ptr %38, align 8, !tbaa !17
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.os_mail_queue_s, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = icmp eq ptr %41, null
  br i1 %42, label %48, label %43

43:                                               ; preds = %19
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.os_mail_queue_s, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %69

48:                                               ; preds = %43, %19
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.os_mail_queue_s, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %58

53:                                               ; preds = %48
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.os_mail_queue_s, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = call i32 @osMemoryPoolDelete(ptr noundef %56)
  br label %58

58:                                               ; preds = %53, %48
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.os_mail_queue_s, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %68

63:                                               ; preds = %58
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.os_mail_queue_s, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = call i32 @osMessageQueueDelete(ptr noundef %66)
  br label %68

68:                                               ; preds = %63, %58
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

69:                                               ; preds = %43
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %70, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

71:                                               ; preds = %69, %68, %18, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %72 = load ptr, ptr %3, align 8
  ret ptr %72
}

declare i32 @osMemoryPoolDelete(ptr noundef) #1

declare i32 @osMessageQueueDelete(ptr noundef) #1

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, !6, i64 8}
!10 = !{!"os_mailQ_def", !11, i64 0, !11, i64 4, !6, i64 8, !12, i64 16, !12, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!16, !6, i64 0}
!16 = !{!"os_mail_queue_s", !6, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}


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

declare ptr @osMessageQueueNew(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @osMailCreate(ptr noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %28, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %28, label %8

8:                                                ; preds = %4
  %9 = load i32, ptr %0, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = tail call ptr @osMemoryPoolNew(i32 noundef %9, i32 noundef %11, ptr noundef nonnull %12) #2
  store ptr %13, ptr %6, align 8, !tbaa !14
  %14 = load i32, ptr %0, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  %16 = tail call ptr @osMessageQueueNew(i32 noundef %14, i32 noundef 8, ptr noundef nonnull %15) #2
  %17 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %16, ptr %17, align 8, !tbaa !16
  %18 = load ptr, ptr %6, align 8, !tbaa !14
  %19 = icmp eq ptr %18, null
  %20 = icmp eq ptr %16, null
  %or.cond = select i1 %19, i1 true, i1 %20
  br i1 %or.cond, label %21, label %28

21:                                               ; preds = %8
  br i1 %19, label %24, label %22

22:                                               ; preds = %21
  %23 = tail call i32 @osMemoryPoolDelete(ptr noundef nonnull %18) #2
  %.pre = load ptr, ptr %17, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %22, %21
  %25 = phi ptr [ %.pre, %22 ], [ %16, %21 ]
  %.not23 = icmp eq ptr %25, null
  br i1 %.not23, label %28, label %26

26:                                               ; preds = %24
  %27 = tail call i32 @osMessageQueueDelete(ptr noundef nonnull %25) #2
  br label %28

28:                                               ; preds = %8, %24, %26, %4, %2
  %.0 = phi ptr [ null, %2 ], [ null, %4 ], [ null, %26 ], [ null, %24 ], [ %6, %8 ]
  ret ptr %.0
}

declare i32 @osMemoryPoolDelete(ptr noundef) local_unnamed_addr #0

declare i32 @osMessageQueueDelete(ptr noundef) local_unnamed_addr #0

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, !10, i64 8}
!6 = !{!"os_mailQ_def", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !10, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !7, i64 40}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!15, !10, i64 0}
!15 = !{!"os_mail_queue_s", !10, i64 0, !10, i64 8}
!16 = !{!15, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass