; LLVM IR from thomasfla/Linux-ESPNOW :: ESPNOW_lib/src (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"

@handler = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [23 x i8], align 1
@_ZL6my_mac = external hidden global [6 x i8], align 1
@_ZL8dest_mac = external hidden global [6 x i8], align 1
@_ZL7ESP_mac = external hidden global [6 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %13

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 35, ptr noundef @__PRETTY_FUNCTION__.main) #8
  unreachable

12:                                               ; No predecessors!
  br label %13

13:                                               ; preds = %12, %10
  %14 = call i32 @nice(i32 noundef -20) #9
  %15 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 368) #10
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds ptr, ptr %16, i64 1
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  invoke void @_ZN14ESPNOW_managerC2EPchtPhS1_b(ptr noundef nonnull align 8 dereferenceable(368) %15, ptr noundef %18, i8 noundef zeroext 48, i16 noundef zeroext 2452, ptr noundef @_ZL6my_mac, ptr noundef @_ZL8dest_mac, i1 noundef zeroext false)
          to label %19 unwind label %24

19:                                               ; preds = %13
  store ptr %15, ptr @handler, align 8, !tbaa !9
  %20 = load ptr, ptr @handler, align 8, !tbaa !9
  call void @_ZN14ESPNOW_manager10set_filterEPhS0_(ptr noundef nonnull align 8 dereferenceable(368) %20, ptr noundef @_ZL7ESP_mac, ptr noundef @_ZL8dest_mac)
  %21 = load ptr, ptr @handler, align 8, !tbaa !9
  call void @_ZN14ESPNOW_manager17set_recv_callbackEPFvPhS0_iE(ptr noundef nonnull align 8 dereferenceable(368) %21, ptr noundef @_Z8callbackPhS_i)
  %22 = load ptr, ptr @handler, align 8, !tbaa !9
  call void @_ZN14ESPNOW_manager5startEv(ptr noundef nonnull align 8 dereferenceable(368) %22)
  br label %23

23:                                               ; preds = %23, %19
  call void @_ZNSt11this_thread5yieldEv() #9
  br label %23, !llvm.loop !11

24:                                               ; preds = %13
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %15, i64 noundef 368) #11
  br label %28

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8
  %30 = load i32, ptr %7, align 4
  %31 = insertvalue { ptr, i32 } poison, ptr %29, 0
  %32 = insertvalue { ptr, i32 } %31, i32 %30, 1
  resume { ptr, i32 } %32
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @nice(i32 noundef) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ESPNOW_managerC2EPchtPhS1_b(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef, i8 noundef zeroext, i16 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

declare void @_ZN14ESPNOW_manager10set_filterEPhS0_(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef, ptr noundef) #6

declare void @_ZN14ESPNOW_manager17set_recv_callbackEPFvPhS0_iE(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef) #6

declare void @_ZN14ESPNOW_manager5startEv(ptr noundef nonnull align 8 dereferenceable(368)) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt11this_thread5yieldEv() #7

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 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 #2 = { noreturn nounwind "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 "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 = { nobuiltin allocsize(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 #5 = { nobuiltin nounwind "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 #6 = { "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 #7 = { inlinehint mustprogress 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 #8 = { noreturn nounwind }
attributes #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@handler = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [23 x i8], align 1
@_ZL6my_mac = external hidden global [6 x i8], align 1
@_ZL8dest_mac = external hidden global [6 x i8], align 1
@_ZL7ESP_mac = external hidden global [6 x i8], align 1

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

; Function Attrs: mustprogress norecurse noreturn uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %5, label %4

4:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 35, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #8
  unreachable

5:                                                ; preds = %2
  %6 = tail call i32 @nice(i32 noundef -20) #9
  %7 = tail call noalias noundef nonnull dereferenceable(368) ptr @_Znwm(i64 noundef 368) #10
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN14ESPNOW_managerC2EPchtPhS1_b(ptr noundef nonnull align 8 dereferenceable(368) %7, ptr noundef %9, i8 noundef zeroext 48, i16 noundef zeroext 2452, ptr noundef nonnull @_ZL6my_mac, ptr noundef nonnull @_ZL8dest_mac, i1 noundef zeroext false)
          to label %10 unwind label %14

10:                                               ; preds = %5
  store ptr %7, ptr @handler, align 8, !tbaa !5
  tail call void @_ZN14ESPNOW_manager10set_filterEPhS0_(ptr noundef nonnull align 8 dereferenceable(368) %7, ptr noundef nonnull @_ZL7ESP_mac, ptr noundef nonnull @_ZL8dest_mac)
  %11 = load ptr, ptr @handler, align 8, !tbaa !5
  tail call void @_ZN14ESPNOW_manager17set_recv_callbackEPFvPhS0_iE(ptr noundef nonnull align 8 dereferenceable(368) %11, ptr noundef nonnull @_Z8callbackPhS_i)
  %12 = load ptr, ptr @handler, align 8, !tbaa !5
  tail call void @_ZN14ESPNOW_manager5startEv(ptr noundef nonnull align 8 dereferenceable(368) %12)
  br label %13

13:                                               ; preds = %13, %10
  tail call void @_ZNSt11this_thread5yieldEv() #9
  br label %13, !llvm.loop !9

14:                                               ; preds = %5
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 368) #11
  resume { ptr, i32 } %15
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @nice(i32 noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ESPNOW_managerC2EPchtPhS1_b(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef, i8 noundef zeroext, i16 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

declare void @_ZN14ESPNOW_manager10set_filterEPhS0_(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef, ptr noundef) local_unnamed_addr #6

declare void @_ZN14ESPNOW_manager17set_recv_callbackEPFvPhS0_iE(ptr noundef nonnull align 8 dereferenceable(368), ptr noundef) local_unnamed_addr #6

declare void @_ZN14ESPNOW_manager5startEv(ptr noundef nonnull align 8 dereferenceable(368)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt11this_thread5yieldEv() local_unnamed_addr #7

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 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 #2 = { noreturn nounwind "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 "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 = { nobuiltin allocsize(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 #5 = { nobuiltin nounwind "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 #6 = { "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 #7 = { inlinehint mustprogress 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 #8 = { noreturn nounwind }
attributes #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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