; LLVM IR from openappsec/openappsec :: external/yajl/src (yajl_tree)

; 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.yajl_val_s = type { i32, %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { i64, double, ptr, i32 }
%struct.anon.0 = type { ptr, ptr, i64 }

; 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
define dso_local ptr @yajl_tree_get(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %89

14:                                               ; preds = %3
  br label %15

15:                                               ; preds = %73, %14
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br label %22

22:                                               ; preds = %18, %15
  %23 = phi i1 [ false, %15 ], [ %21, %18 ]
  br i1 %23, label %24, label %74

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.yajl_val_s, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp ne i32 %27, 3
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %71

30:                                               ; preds = %24
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.yajl_val_s, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.anon.0, ptr %32, i32 0, i32 2
  %34 = load i64, ptr %33, align 8, !tbaa !13
  store i64 %34, ptr %9, align 8, !tbaa !14
  store i64 0, ptr %8, align 8, !tbaa !14
  br label %35

35:                                               ; preds = %60, %30
  %36 = load i64, ptr %8, align 8, !tbaa !14
  %37 = load i64, ptr %9, align 8, !tbaa !14
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %39, label %63

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.yajl_val_s, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.anon.0, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load i64, ptr %8, align 8, !tbaa !14
  %47 = getelementptr inbounds ptr, ptr %45, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = call i32 @strcmp(ptr noundef %41, ptr noundef %48) #4
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %59, label %51

51:                                               ; preds = %39
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.yajl_val_s, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.anon.0, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = load i64, ptr %8, align 8, !tbaa !14
  %57 = getelementptr inbounds ptr, ptr %55, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  store ptr %58, ptr %5, align 8, !tbaa !5
  br label %63

59:                                               ; preds = %39
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %8, align 8, !tbaa !14
  %62 = add i64 %61, 1
  store i64 %62, ptr %8, align 8, !tbaa !14
  br label %35, !llvm.loop !16

63:                                               ; preds = %51, %35
  %64 = load i64, ptr %8, align 8, !tbaa !14
  %65 = load i64, ptr %9, align 8, !tbaa !14
  %66 = icmp eq i64 %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %63
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %71

68:                                               ; preds = %63
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds ptr, ptr %69, i32 1
  store ptr %70, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %71

71:                                               ; preds = %68, %67, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %72 = load i32, ptr %10, align 4
  switch i32 %72, label %91 [
    i32 0, label %73
    i32 1, label %89
  ]

73:                                               ; preds = %71
  br label %15, !llvm.loop !18

74:                                               ; preds = %22
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %87

77:                                               ; preds = %74
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = icmp ne i32 %78, 8
  br i1 %79, label %80, label %87

80:                                               ; preds = %77
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.yajl_val_s, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !11
  %85 = icmp ne i32 %81, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %80
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %86, %80, %77, %74
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %88, ptr %4, align 8
  br label %89

89:                                               ; preds = %87, %71, %13
  %90 = load ptr, ptr %4, align 8
  ret ptr %90

91:                                               ; preds = %71
  unreachable
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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 willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"yajl_val_s", !10, i64 0, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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: nofree nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @yajl_tree_get(ptr noundef readonly %0, ptr noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.critedge.thread, label %.preheader

.preheader:                                       ; preds = %3, %.loopexit
  %.028 = phi ptr [ %24, %.loopexit ], [ %1, %3 ]
  %.025 = phi ptr [ %.126, %.loopexit ], [ %0, %3 ]
  %.not47 = icmp eq ptr %.025, null
  br i1 %.not47, label %.critedge.thread, label %4

4:                                                ; preds = %.preheader
  %5 = load ptr, ptr %.028, align 8, !tbaa !5
  %.not32 = icmp eq ptr %5, null
  br i1 %.not32, label %.critedge, label %6

6:                                                ; preds = %4
  %7 = load i32, ptr %.025, align 8, !tbaa !9
  %.not34 = icmp eq i32 %7, 3
  br i1 %.not34, label %8, label %.critedge.thread

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %.025, i64 24
  %10 = load i64, ptr %9, align 8, !tbaa !12
  %.not48 = icmp eq i64 %10, 0
  br i1 %.not48, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %11 = getelementptr inbounds i8, ptr %.025, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  br label %13

13:                                               ; preds = %.lr.ph, %22
  %.02446 = phi i64 [ 0, %.lr.ph ], [ %23, %22 ]
  %14 = getelementptr inbounds ptr, ptr %12, i64 %.02446
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %15) #2
  %.not35 = icmp eq i32 %16, 0
  br i1 %.not35, label %17, label %22

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %.025, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.02446
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  br label %.loopexit

22:                                               ; preds = %13
  %23 = add nuw i64 %.02446, 1
  %exitcond.not = icmp eq i64 %23, %10
  br i1 %exitcond.not, label %.critedge.thread, label %13, !llvm.loop !13

.loopexit:                                        ; preds = %8, %17
  %.02444 = phi i64 [ %.02446, %17 ], [ 0, %8 ]
  %.126 = phi ptr [ %21, %17 ], [ %.025, %8 ]
  %.not42 = icmp eq i64 %.02444, %10
  %24 = getelementptr inbounds i8, ptr %.028, i64 8
  br i1 %.not42, label %.critedge.thread, label %.preheader

.critedge:                                        ; preds = %4
  %.not49 = icmp eq i32 %2, 8
  br i1 %.not49, label %.critedge.thread, label %25

25:                                               ; preds = %.critedge
  %26 = load i32, ptr %.025, align 8, !tbaa !9
  %.not33 = icmp eq i32 %26, %2
  %spec.store.select = select i1 %.not33, ptr %.025, ptr null
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %6, %.preheader, %.loopexit, %22, %.critedge, %25, %3
  %.2 = phi ptr [ null, %3 ], [ %spec.store.select, %25 ], [ %.025, %.critedge ], [ null, %22 ], [ null, %.loopexit ], [ null, %.preheader ], [ null, %6 ]
  ret ptr %.2
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(read, inaccessiblemem: none) 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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!"yajl_val_s", !11, i64 0, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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