; LLVM IR from yinqiwen/ardb :: src/common/channel/redis (ae)

; 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.aeEventLoop = type { i32, i32, i64, ptr, ptr, ptr, i32, ptr, ptr }
%struct.aeTimeEvent = type { i64, i64, i64, ptr, ptr, ptr, ptr }

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

declare void @zfree(ptr noundef) #1

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

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

12:                                               ; preds = %51, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %56

15:                                               ; preds = %12
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.aeTimeEvent, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !14
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = icmp eq i64 %18, %19
  br i1 %20, label %21, label %51

21:                                               ; preds = %15
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %30

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.aeTimeEvent, ptr %25, i32 0, i32 6
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.aeEventLoop, ptr %28, i32 0, i32 5
  store ptr %27, ptr %29, align 8, !tbaa !11
  br label %36

30:                                               ; preds = %21
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.aeTimeEvent, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.aeTimeEvent, ptr %34, i32 0, i32 6
  store ptr %33, ptr %35, align 8, !tbaa !17
  br label %36

36:                                               ; preds = %30, %24
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.aeTimeEvent, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %49

41:                                               ; preds = %36
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.aeTimeEvent, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.aeTimeEvent, ptr %46, i32 0, i32 5
  %48 = load ptr, ptr %47, align 8, !tbaa !19
  call void %44(ptr noundef %45, ptr noundef %48)
  br label %49

49:                                               ; preds = %41, %36
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  call void @zfree(ptr noundef %50)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %57

51:                                               ; preds = %15
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %52, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.aeTimeEvent, ptr %53, i32 0, i32 6
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  store ptr %55, ptr %6, align 8, !tbaa !5
  br label %12, !llvm.loop !20

56:                                               ; preds = %12
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %57

57:                                               ; preds = %56, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %58 = load i32, ptr %3, align 4
  ret i32 %58
}

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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"aeEventLoop", !13, i64 0, !13, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"aeTimeEvent", !10, i64 0, !16, i64 8, !16, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!16 = !{!"long", !7, i64 0}
!17 = !{!15, !6, i64 48}
!18 = !{!15, !6, i64 32}
!19 = !{!15, !6, i64 40}
!20 = distinct !{!20, !21}
!21 = !{!"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"

declare void @zfree(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @aeDeleteTimeEvent(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %.01622 = load ptr, ptr %3, align 8, !tbaa !5
  %.not23 = icmp eq ptr %.01622, null
  br i1 %.not23, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %4 = load i64, ptr %.01622, align 8, !tbaa !9
  %5 = icmp eq i64 %4, %1
  br i1 %5, label %.lr.ph._crit_edge, label %.lr.ph33

.lr.ph:                                           ; preds = %.lr.ph33
  %6 = load i64, ptr %.016, align 8, !tbaa !9
  %7 = icmp eq i64 %6, %1
  br i1 %7, label %.lr.ph._crit_edge, label %.lr.ph33, !llvm.loop !13

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %.lr.ph.preheader
  %.01625.lcssa = phi ptr [ %.01622, %.lr.ph.preheader ], [ %.016, %.lr.ph ]
  %.024.lcssa = phi ptr [ null, %.lr.ph.preheader ], [ %.0162532, %.lr.ph ]
  %8 = icmp eq ptr %.024.lcssa, null
  %9 = getelementptr inbounds i8, ptr %.01625.lcssa, i64 48
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %.024.lcssa, i64 48
  %.sink = select i1 %8, ptr %3, ptr %11
  store ptr %10, ptr %.sink, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %.01625.lcssa, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %.not19 = icmp eq ptr %13, null
  br i1 %.not19, label %17, label %14

14:                                               ; preds = %.lr.ph._crit_edge
  %15 = getelementptr inbounds i8, ptr %.01625.lcssa, i64 40
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  tail call void %13(ptr noundef %0, ptr noundef %16) #2
  br label %17

17:                                               ; preds = %14, %.lr.ph._crit_edge
  tail call void @zfree(ptr noundef nonnull %.01625.lcssa) #2
  br label %.loopexit

.lr.ph33:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0162532 = phi ptr [ %.016, %.lr.ph ], [ %.01622, %.lr.ph.preheader ]
  %18 = getelementptr inbounds i8, ptr %.0162532, i64 48
  %.016 = load ptr, ptr %18, align 8, !tbaa !5
  %.not = icmp eq ptr %.016, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph33, %2, %17
  %.017 = phi i32 [ 0, %17 ], [ -1, %2 ], [ -1, %.lr.ph33 ]
  ret i32 %.017
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"aeTimeEvent", !11, i64 0, !12, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !6, i64 40}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass