; LLVM IR from pupnp/pupnp :: upnp/src/threadutil (LinkedList)

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

@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.ListFind = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, 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 ptr @ListFind(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %70

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.LINKEDLIST, ptr %17, i32 0, i32 0
  store ptr %18, ptr %6, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %16, %13
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 282, ptr noundef @__PRETTY_FUNCTION__.ListFind) #4
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.LISTNODE, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  br label %32

31:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 286, ptr noundef @__PRETTY_FUNCTION__.ListFind) #4
  unreachable

32:                                               ; preds = %30
  br label %33

33:                                               ; preds = %65, %32
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LINKEDLIST, ptr %35, i32 0, i32 1
  %37 = icmp ne ptr %34, %36
  br i1 %37, label %38, label %69

38:                                               ; preds = %33
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LINKEDLIST, ptr %39, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %56

43:                                               ; preds = %38
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.LINKEDLIST, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.LISTNODE, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = call i32 %46(ptr noundef %47, ptr noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %43
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %54, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %70

55:                                               ; preds = %43
  br label %65

56:                                               ; preds = %38
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.LISTNODE, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = icmp eq ptr %57, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %56
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %63, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %70

64:                                               ; preds = %56
  br label %65

65:                                               ; preds = %64, %55
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.LISTNODE, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  store ptr %68, ptr %8, align 8, !tbaa !5
  br label %33, !llvm.loop !17

69:                                               ; preds = %33
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %70

70:                                               ; preds = %69, %62, %53, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %71 = load ptr, ptr %4, align 8
  ret ptr %71
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }
attributes #4 = { noreturn 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, !6, i64 8}
!10 = !{!"LISTNODE", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!12, !6, i64 88}
!12 = !{!"LINKEDLIST", !10, i64 0, !10, i64 24, !13, i64 48, !14, i64 56, !6, i64 80, !6, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!"FREELIST", !6, i64 0, !13, i64 8, !15, i64 16, !15, i64 20}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"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.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__.ListFind = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ListFind(ptr noundef readonly %0, ptr noundef readonly %1, ptr noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %4

4:                                                ; preds = %3
  %.not24 = icmp eq ptr %1, null
  %spec.select = select i1 %.not24, ptr %0, ptr %1
  %5 = getelementptr inbounds i8, ptr %spec.select, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not25 = icmp eq ptr %6, null
  br i1 %.not25, label %17, label %.preheader

.preheader:                                       ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %.not2629 = icmp eq ptr %6, %7
  br i1 %.not2629, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %10 = icmp eq ptr %9, null
  br i1 %10, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %14
  %.030.us = phi ptr [ %16, %14 ], [ %6, %.lr.ph ]
  %11 = getelementptr inbounds i8, ptr %.030.us, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = icmp eq ptr %12, %2
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %.lr.ph.split.us
  %15 = getelementptr inbounds i8, ptr %.030.us, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %.not26.us = icmp eq ptr %16, %7
  br i1 %.not26.us, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !16

17:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 286, ptr noundef nonnull @__PRETTY_FUNCTION__.ListFind) #2
  unreachable

.lr.ph.splitthread-pre-split:                     ; preds = %25
  %.pr = load ptr, ptr %8, align 8, !tbaa !10
  br label %.lr.ph.split

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.splitthread-pre-split
  %18 = phi ptr [ %.pr, %.lr.ph.splitthread-pre-split ], [ %9, %.lr.ph ]
  %.030 = phi ptr [ %27, %.lr.ph.splitthread-pre-split ], [ %6, %.lr.ph ]
  %.not27 = icmp eq ptr %18, null
  %19 = getelementptr inbounds i8, ptr %.030, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  br i1 %.not27, label %23, label %21

21:                                               ; preds = %.lr.ph.split
  %22 = tail call i32 %18(ptr noundef %2, ptr noundef %20) #3
  %.not28 = icmp eq i32 %22, 0
  br i1 %.not28, label %25, label %.loopexit

23:                                               ; preds = %.lr.ph.split
  %24 = icmp eq ptr %20, %2
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %23, %21
  %26 = getelementptr inbounds i8, ptr %.030, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %.not26 = icmp eq ptr %27, %7
  br i1 %.not26, label %.loopexit, label %.lr.ph.splitthread-pre-split, !llvm.loop !18

.loopexit:                                        ; preds = %21, %23, %25, %.lr.ph.split.us, %14, %.preheader, %3
  %.018 = phi ptr [ null, %3 ], [ null, %.preheader ], [ %.030.us, %.lr.ph.split.us ], [ null, %14 ], [ %.030, %21 ], [ %.030, %23 ], [ null, %25 ]
  ret ptr %.018
}

attributes #0 = { 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 #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 = { noreturn nounwind }
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, !7, i64 8}
!6 = !{!"LISTNODE", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 88}
!11 = !{!"LINKEDLIST", !6, i64 0, !6, i64 24, !12, i64 48, !13, i64 56, !7, i64 80, !7, i64 88}
!12 = !{!"long", !8, i64 0}
!13 = !{!"FREELIST", !7, i64 0, !12, i64 8, !14, i64 16, !14, i64 20}
!14 = !{!"int", !8, i64 0}
!15 = !{!6, !7, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17, !19}
!19 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass