; LLVM IR from joltwallet/jolt_wallet :: components/console/argtable3 (argtable3)

; 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.TRex = type { ptr, ptr, ptr, i32, i32, ptr, i32, i32, i32, ptr, i32, ptr, ptr, i32 }
%struct.tagTRexNode = type { i32, i32, i32, i32 }

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

; 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
declare hidden ptr @trex_matchnode(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @trex_searchrange(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TRex, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 8, !tbaa !9
  store i32 %17, ptr %13, align 4, !tbaa !12
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp uge ptr %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

22:                                               ; preds = %5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.TRex, ptr %24, i32 0, i32 1
  store ptr %23, ptr %25, align 8, !tbaa !13
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TRex, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !14
  br label %29

29:                                               ; preds = %68, %22
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %30, ptr %12, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %49, %29
  %32 = load i32, ptr %13, align 4, !tbaa !12
  %33 = icmp ne i32 %32, -1
  br i1 %33, label %34, label %58

34:                                               ; preds = %31
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TRex, ptr %35, i32 0, i32 10
  store i32 0, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TRex, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load i32, ptr %13, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.tagTRexNode, ptr %40, i64 %42
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = call ptr @trex_matchnode(ptr noundef %37, ptr noundef %43, ptr noundef %44, ptr noundef null)
  store ptr %45, ptr %12, align 8, !tbaa !5
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %49, label %48

48:                                               ; preds = %34
  br label %58

49:                                               ; preds = %34
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.TRex, ptr %50, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %13, align 4, !tbaa !12
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.tagTRexNode, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.tagTRexNode, ptr %55, i32 0, i32 3
  %57 = load i32, ptr %56, align 4, !tbaa !17
  store i32 %57, ptr %13, align 4, !tbaa !12
  br label %31, !llvm.loop !19

58:                                               ; preds = %48, %31
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i32 1
  store ptr %60, ptr %8, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %58
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %68

64:                                               ; preds = %61
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = icmp ne ptr %65, %66
  br label %68

68:                                               ; preds = %64, %61
  %69 = phi i1 [ false, %61 ], [ %67, %64 ]
  br i1 %69, label %29, label %70, !llvm.loop !21

70:                                               ; preds = %68
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

74:                                               ; preds = %70
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i32 -1
  store ptr %76, ptr %8, align 8, !tbaa !5
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %82

79:                                               ; preds = %74
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %80, ptr %81, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %79, %74
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %88

85:                                               ; preds = %82
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %86, ptr %87, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %85, %82
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %73, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %90 = load i32, ptr %6, align 4
  ret i32 %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 24}
!10 = !{!"TRex", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !11, i64 64, !6, i64 72, !6, i64 80, !11, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !11, i64 64}
!16 = !{!10, !6, i64 32}
!17 = !{!18, !11, i64 12}
!18 = !{!"tagTRexNode", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

%struct.tagTRexNode = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare hidden ptr @trex_matchnode(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @trex_searchrange(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef writeonly %3, ptr noundef writeonly %4) local_unnamed_addr #0 {
  %.not = icmp ult ptr %1, %2
  br i1 %.not, label %6, label %29

6:                                                ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %9, align 8, !tbaa !11
  store ptr %2, ptr %0, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  br label %12

12:                                               ; preds = %._crit_edge, %6
  %.032 = phi ptr [ %1, %6 ], [ %21, %._crit_edge ]
  %.0 = phi i32 [ %8, %6 ], [ %.1.lcssa, %._crit_edge ]
  %.not4044 = icmp eq i32 %.0, -1
  br i1 %.not4044, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %12
  %.pre = load ptr, ptr %11, align 8, !tbaa !13
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %13 = phi ptr [ %18, %17 ], [ %.pre, %.lr.ph.preheader ]
  %.146 = phi i32 [ %20, %17 ], [ %.0, %.lr.ph.preheader ]
  %.02945 = phi ptr [ %16, %17 ], [ %.032, %.lr.ph.preheader ]
  store i32 0, ptr %10, align 8, !tbaa !14
  %14 = sext i32 %.146 to i64
  %15 = getelementptr inbounds %struct.tagTRexNode, ptr %13, i64 %14
  %16 = tail call ptr @trex_matchnode(ptr noundef nonnull %0, ptr noundef %15, ptr noundef %.02945, ptr noundef null)
  %.not41 = icmp eq ptr %16, null
  br i1 %.not41, label %._crit_edge, label %17

17:                                               ; preds = %.lr.ph
  %18 = load ptr, ptr %11, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.tagTRexNode, ptr %18, i64 %14, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %.not40 = icmp eq i32 %20, -1
  br i1 %.not40, label %._crit_edge.thread, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %12
  %.1.lcssa = phi i32 [ -1, %12 ], [ %.146, %.lr.ph ]
  %.130 = phi ptr [ %.032, %12 ], [ null, %.lr.ph ]
  %21 = getelementptr inbounds i8, ptr %.032, i64 1
  %22 = icmp eq ptr %.130, null
  %23 = icmp ne ptr %21, %2
  %24 = select i1 %22, i1 %23, i1 false
  br i1 %24, label %12, label %25, !llvm.loop !19

25:                                               ; preds = %._crit_edge
  br i1 %22, label %29, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %17, %25
  %.1305354 = phi ptr [ %.130, %25 ], [ %16, %17 ]
  %.not42 = icmp eq ptr %3, null
  br i1 %.not42, label %27, label %26

26:                                               ; preds = %._crit_edge.thread
  store ptr %.032, ptr %3, align 8, !tbaa !20
  br label %27

27:                                               ; preds = %26, %._crit_edge.thread
  %.not43 = icmp eq ptr %4, null
  br i1 %.not43, label %29, label %28

28:                                               ; preds = %27
  store ptr %.1305354, ptr %4, align 8, !tbaa !20
  br label %29

29:                                               ; preds = %27, %28, %25, %5
  %.031 = phi i32 [ 0, %5 ], [ 0, %25 ], [ 1, %28 ], [ 1, %27 ]
  ret i32 %.031
}

attributes #0 = { 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 24}
!6 = !{!"TRex", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !10, i64 64, !7, i64 72, !7, i64 80, !10, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !10, i64 64}
!15 = !{!16, !10, i64 12}
!16 = !{!"tagTRexNode", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!7, !7, i64 0}


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