; LLVM IR from t4th/cortex-m3-rtos :: examples/waitForSingleObject/main.ll (Z5task0Pv)

; 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.Events = type { i32 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

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

declare noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5task0Pv(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %3, align 8, !tbaa !5
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef @_Z5task1Pv, i32 noundef 1, ptr noundef %4, ptr noundef %8, i1 noundef zeroext true)
  %10 = zext i1 %9 to i8
  store i8 %10, ptr %5, align 1, !tbaa !9
  %11 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  %13 = zext i1 %12 to i32
  %14 = icmp eq i32 1, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.1)
  br label %16

16:                                               ; preds = %15, %1
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Events, ptr %17, i32 0, i32 0
  %19 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %18, i1 noundef zeroext false, ptr noundef null)
  %20 = zext i1 %19 to i8
  store i8 %20, ptr %6, align 1, !tbaa !9
  %21 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %22 = trunc i8 %21 to i1
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.2)
  br label %25

24:                                               ; preds = %16
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.3)
  br label %25

25:                                               ; preds = %24, %23
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.4)
  call void @_ZN6kernel4task6resumeERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %4)
  br label %26

26:                                               ; preds = %27, %25
  br label %27

27:                                               ; preds = %26
  call void @_ZN6kernel4task5sleepEj(i32 noundef 1000)
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.5)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Events, ptr %28, i32 0, i32 0
  call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %29)
  br label %26, !llvm.loop !13
}

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5task1Pv(ptr noundef) #2

declare noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4), i1 noundef zeroext, ptr noundef) #1

declare void @_ZN6kernel4task6resumeERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4)) #1

declare void @_ZN6kernel4task5sleepEj(i32 noundef) #1

declare void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4)) #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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

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

declare noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_Z5task0Pv(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef nonnull @_Z5task1Pv, i32 noundef 1, ptr noundef nonnull %2, ptr noundef %0, i1 noundef zeroext true)
  br i1 %3, label %4, label %5

4:                                                ; preds = %1
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.1)
  br label %5

5:                                                ; preds = %4, %1
  %6 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %0, i1 noundef zeroext false, ptr noundef null)
  %.str.2..str.3 = select i1 %6, ptr @.str.2, ptr @.str.3
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull %.str.2..str.3)
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.4)
  call void @_ZN6kernel4task6resumeERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %7

7:                                                ; preds = %7, %5
  call void @_ZN6kernel4task5sleepEj(i32 noundef 1000)
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.5)
  call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %0)
  br label %7, !llvm.loop !5
}

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5task1Pv(ptr noundef) #3

declare noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4), i1 noundef zeroext, ptr noundef) local_unnamed_addr #1

declare void @_ZN6kernel4task6resumeERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

declare void @_ZN6kernel4task5sleepEj(i32 noundef) local_unnamed_addr #1

declare void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { mustprogress noreturn 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 = { mustprogress 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 #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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