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

; 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] }

@__const._Z10order_taskPv.event_name = external hidden unnamed_addr constant [6 x ptr], align 16
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10order_taskPv(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [6 x ptr], align 16
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const._Z10order_taskPv.event_name, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, ptr %4, align 8, !tbaa !5
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.6)
  br label %7

7:                                                ; preds = %26, %1
  br label %8

8:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

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

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %26

13:                                               ; preds = %9
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.7)
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [6 x ptr], ptr %3, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %17)
  call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef @.str.8)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Data, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [6 x i32], ptr %19, i64 0, i64 %21
  call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %22)
  call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  br label %23

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

26:                                               ; preds = %12
  br label %7, !llvm.loop !13
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) #3

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

declare void @_ZN6kernel4task5sleepEj(i32 noundef) #3

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@__const._Z10order_taskPv.event_name = external hidden unnamed_addr constant [6 x ptr], align 16
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_Z10order_taskPv(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.6)
  %.pre = load ptr, ptr @__const._Z10order_taskPv.event_name, align 16, !tbaa !5
  %.pre7 = load ptr, ptr getelementptr inbounds (i8, ptr @__const._Z10order_taskPv.event_name, i64 8), align 8, !tbaa !5
  %.pre8 = load ptr, ptr getelementptr inbounds (i8, ptr @__const._Z10order_taskPv.event_name, i64 16), align 16, !tbaa !5
  %.pre9 = load ptr, ptr getelementptr inbounds (i8, ptr @__const._Z10order_taskPv.event_name, i64 24), align 8, !tbaa !5
  %.pre10 = load ptr, ptr getelementptr inbounds (i8, ptr @__const._Z10order_taskPv.event_name, i64 32), align 16, !tbaa !5
  %.pre11 = load ptr, ptr getelementptr inbounds (i8, ptr @__const._Z10order_taskPv.event_name, i64 40), align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit, %1
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %0)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %2)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre8)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %3)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre9)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %4)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre10)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %5)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.7)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef %.pre11)
  tail call void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef nonnull @.str.8)
  tail call void @_ZN6kernel5event3setERNS_6HandleE(ptr noundef nonnull align 4 dereferenceable(4) %6)
  tail call void @_ZN6kernel4task5sleepEj(i32 noundef 100)
  br label %.loopexit, !llvm.loop !9
}

declare void @_ZN6kernel8hardware5debug5printEPKc(ptr noundef) local_unnamed_addr #1

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

declare void @_ZN6kernel4task5sleepEj(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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