; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

; 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.sig_List = type { ptr, i64, i64 }

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @sig_Status_reportResult(ptr noundef, i32 noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @sig_List_pop(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @sig_List_remove(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.sig_List, ptr %12, i32 0, i32 2
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = icmp uge i64 %11, %14
  br i1 %15, label %19, label %16

16:                                               ; preds = %3
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = icmp ult i64 %17, 1
  br i1 %18, label %19, label %21

19:                                               ; preds = %16, %3
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sig_Status_reportResult(ptr noundef %20, i32 noundef 2)
  store ptr null, ptr %4, align 8
  br label %81

21:                                               ; preds = %16
  %22 = load i64, ptr %6, align 8, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.sig_List, ptr %23, i32 0, i32 2
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = sub i64 %25, 1
  %27 = icmp eq i64 %22, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call ptr @sig_List_pop(ptr noundef %29, ptr noundef %30)
  store ptr %31, ptr %4, align 8
  br label %81

32:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.sig_List, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %35, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  store ptr %38, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %9, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %63, %32
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.sig_List, ptr %43, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = sub i64 %45, 1
  %47 = icmp ult i64 %42, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %66

49:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sig_List, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  store ptr %55, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sig_List, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !13
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = sub i64 %60, 1
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  store ptr %56, ptr %62, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %63

63:                                               ; preds = %49
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = add i64 %64, 1
  store i64 %65, ptr %9, align 8, !tbaa !9
  br label %41, !llvm.loop !14

66:                                               ; preds = %48
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.sig_List, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.sig_List, ptr %70, i32 0, i32 2
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = sub i64 %72, 1
  %74 = getelementptr inbounds ptr, ptr %69, i64 %73
  store ptr null, ptr %74, align 8, !tbaa !5
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.sig_List, ptr %75, i32 0, i32 2
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = add i64 %77, -1
  store i64 %78, ptr %76, align 8, !tbaa !11
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sig_Status_reportResult(ptr noundef %79, i32 noundef 1)
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %80, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %81

81:                                               ; preds = %66, %28, %19
  %82 = load ptr, ptr %4, align 8
  ret ptr %82
}

attributes #0 = { inlinehint 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"sig_List", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @sig_Status_reportResult(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sig_List_pop(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @sig_List_remove(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp ule i64 %5, %1
  %7 = icmp eq i64 %1, 0
  %or.cond = or i1 %7, %6
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %3
  tail call void @sig_Status_reportResult(ptr noundef %2, i32 noundef 2)
  br label %46

9:                                                ; preds = %3
  %10 = add i64 %5, -1
  %11 = icmp eq i64 %10, %1
  br i1 %11, label %12, label %14

12:                                               ; preds = %9
  %13 = tail call ptr @sig_List_pop(ptr noundef nonnull %0, ptr noundef %2)
  br label %46

14:                                               ; preds = %9
  %15 = load ptr, ptr %0, align 8, !tbaa !11
  %16 = getelementptr inbounds ptr, ptr %15, i64 %1
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %.02529 = add nuw i64 %1, 1
  %18 = icmp ult i64 %.02529, %10
  br i1 %18, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %14
  %19 = xor i64 %5, 2
  %20 = sub i64 %19, %1
  %21 = add i64 %5, -3
  %22 = sub i64 %21, %1
  %xtraiter = and i64 %20, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.02531.prol = phi i64 [ %.025.prol, %.lr.ph.prol ], [ %.02529, %.lr.ph.preheader ]
  %.025.in30.prol = phi i64 [ %.02531.prol, %.lr.ph.prol ], [ %1, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %23 = load ptr, ptr %0, align 8, !tbaa !11
  %24 = getelementptr inbounds ptr, ptr %23, i64 %.02531.prol
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds ptr, ptr %23, i64 %.025.in30.prol
  store ptr %25, ptr %26, align 8, !tbaa !12
  %.025.prol = add nuw i64 %.02531.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !13

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.02531.unr = phi i64 [ %.02529, %.lr.ph.preheader ], [ %.025.prol, %.lr.ph.prol ]
  %.025.in30.unr = phi i64 [ %1, %.lr.ph.preheader ], [ %.02531.prol, %.lr.ph.prol ]
  %27 = icmp ult i64 %22, 3
  br i1 %27, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph, %.lr.ph.prol.loopexit
  %.pre = load ptr, ptr %0, align 8, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %14
  %28 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %15, %14 ]
  %29 = getelementptr inbounds ptr, ptr %28, i64 %10
  store ptr null, ptr %29, align 8, !tbaa !12
  store i64 %10, ptr %4, align 8, !tbaa !5
  tail call void @sig_Status_reportResult(ptr noundef %2, i32 noundef 1)
  br label %46

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.02531 = phi i64 [ %.025.3, %.lr.ph ], [ %.02531.unr, %.lr.ph.prol.loopexit ]
  %.025.in30 = phi i64 [ %.025.2, %.lr.ph ], [ %.025.in30.unr, %.lr.ph.prol.loopexit ]
  %30 = load ptr, ptr %0, align 8, !tbaa !11
  %31 = getelementptr inbounds ptr, ptr %30, i64 %.02531
  %32 = load ptr, ptr %31, align 8, !tbaa !12
  %33 = getelementptr inbounds ptr, ptr %30, i64 %.025.in30
  store ptr %32, ptr %33, align 8, !tbaa !12
  %.025 = add nuw i64 %.02531, 1
  %34 = load ptr, ptr %0, align 8, !tbaa !11
  %35 = getelementptr inbounds ptr, ptr %34, i64 %.025
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = getelementptr inbounds ptr, ptr %34, i64 %.02531
  store ptr %36, ptr %37, align 8, !tbaa !12
  %.025.1 = add nuw i64 %.02531, 2
  %38 = load ptr, ptr %0, align 8, !tbaa !11
  %39 = getelementptr inbounds ptr, ptr %38, i64 %.025.1
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = getelementptr inbounds ptr, ptr %38, i64 %.025
  store ptr %40, ptr %41, align 8, !tbaa !12
  %.025.2 = add nuw i64 %.02531, 3
  %42 = load ptr, ptr %0, align 8, !tbaa !11
  %43 = getelementptr inbounds ptr, ptr %42, i64 %.025.2
  %44 = load ptr, ptr %43, align 8, !tbaa !12
  %45 = getelementptr inbounds ptr, ptr %42, i64 %.025.1
  store ptr %44, ptr %45, align 8, !tbaa !12
  %.025.3 = add nuw i64 %.02531, 4
  %exitcond.not.3 = icmp eq i64 %.025.3, %10
  br i1 %exitcond.not.3, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !15

46:                                               ; preds = %._crit_edge, %12, %8
  %.0 = phi ptr [ null, %8 ], [ %13, %12 ], [ %17, %._crit_edge ]
  ret ptr %.0
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass