; LLVM IR from t4th/cortex-m3-rtos :: examples/waitForMultipleObjects (main)

; 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.Data = type { [6 x i32] }

@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10order_taskPv(ptr noundef) #0

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

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11worker_taskPv(ptr noundef) #0

declare void @_ZN6kernel8hardware5debug13setBreakpointEv() #2

; Function Attrs: norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.Data, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr %2) #5
  call void @llvm.memset.p0.i64(ptr align 4 %2, i8 0, i64 24, i1 false)
  call void @_ZN6kernel4initEv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 5, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %25, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp ult i32 %9, 5
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %28

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

23:                                               ; preds = %12
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %24

24:                                               ; preds = %23, %12
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = add i32 %26, 1
  store i32 %27, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !13

28:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 5, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  %29 = getelementptr inbounds %struct.Data, ptr %2, i32 0, i32 0
  %30 = getelementptr inbounds [6 x i32], ptr %29, i64 0, i64 5
  %31 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %30, i1 noundef zeroext true, ptr noundef null)
  %32 = zext i1 %31 to i8
  store i8 %32, ptr %7, align 1, !tbaa !9
  %33 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %34 = trunc i8 %33 to i1
  %35 = zext i1 %34 to i32
  %36 = icmp eq i32 0, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %28
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %38

38:                                               ; preds = %37, %28
  %39 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef @_Z10order_taskPv, i32 noundef 2, ptr noundef null, ptr noundef %2, i1 noundef zeroext false)
  %40 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef @_Z11worker_taskPv, i32 noundef 1, ptr noundef null, ptr noundef %2, i1 noundef zeroext false)
  call void @_ZN6kernel5startEv()
  br label %41

41:                                               ; preds = %41, %38
  br label %41
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @_ZN6kernel4initEv() #2

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

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

declare void @_ZN6kernel5startEv() #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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++ 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"

%struct.Data = type { [6 x i32] }

@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10order_taskPv(ptr noundef) #0

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

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11worker_taskPv(ptr noundef) #0

declare void @_ZN6kernel8hardware5debug13setBreakpointEv() local_unnamed_addr #2

; Function Attrs: norecurse noreturn uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %struct.Data, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) %1, i8 0, i64 24, i1 false)
  tail call void @_ZN6kernel4initEv()
  %2 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %1, i1 noundef zeroext false, ptr noundef null)
  br i1 %2, label %4, label %3

3:                                                ; preds = %0
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %4

4:                                                ; preds = %3, %0
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %5, i1 noundef zeroext false, ptr noundef null)
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %8

8:                                                ; preds = %7, %4
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %9, i1 noundef zeroext false, ptr noundef null)
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %12

12:                                               ; preds = %11, %8
  %13 = getelementptr inbounds i8, ptr %1, i64 12
  %14 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %13, i1 noundef zeroext false, ptr noundef null)
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %16

16:                                               ; preds = %15, %12
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %17, i1 noundef zeroext false, ptr noundef null)
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %20

20:                                               ; preds = %19, %16
  %21 = getelementptr inbounds i8, ptr %1, i64 20
  %22 = call noundef zeroext i1 @_ZN6kernel5event6createERNS_6HandleEbPKc(ptr noundef nonnull align 4 dereferenceable(4) %21, i1 noundef zeroext true, ptr noundef null)
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.14)
  call void @_ZN6kernel8hardware5debug13setBreakpointEv()
  br label %24

24:                                               ; preds = %23, %20
  %25 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef nonnull @_Z10order_taskPv, i32 noundef 2, ptr noundef null, ptr noundef nonnull %1, i1 noundef zeroext false)
  %26 = call noundef zeroext i1 @_ZN6kernel4task6createEPFvPvENS0_8PriorityEPNS_6HandleES1_b(ptr noundef nonnull @_Z11worker_taskPv, i32 noundef 1, ptr noundef null, ptr noundef nonnull %1, i1 noundef zeroext false)
  call void @_ZN6kernel5startEv()
  br label %27

27:                                               ; preds = %27, %24
  br label %27
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @_ZN6kernel4initEv() local_unnamed_addr #2

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

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

declare void @_ZN6kernel5startEv() local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { norecurse 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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)"}


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