; LLVM IR from specinfo-ua/UAPKI :: library/common/json (parson)

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

; 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 @json_object_getn_value(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_value_get_object(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_value_get_type(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @json_value_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_value_init_object() #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @json_object_dotset_value(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 i64, align 8
  %15 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 -1, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %24, label %18

18:                                               ; preds = %3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %24, label %21

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

24:                                               ; preds = %21, %18, %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

25:                                               ; preds = %21
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call ptr @strchr(ptr noundef %26, i32 noundef 46) #4
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %35

30:                                               ; preds = %25
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call i32 @json_object_set_value(ptr noundef %31, ptr noundef %32, ptr noundef %33)
  store i32 %34, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

35:                                               ; preds = %25
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = ptrtoint ptr %36 to i64
  %39 = ptrtoint ptr %37 to i64
  %40 = sub i64 %38, %39
  store i64 %40, ptr %14, align 8, !tbaa !11
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i64, ptr %14, align 8, !tbaa !11
  %44 = call ptr @json_object_getn_value(ptr noundef %41, ptr noundef %42, i64 noundef %43)
  store ptr %44, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %60

47:                                               ; preds = %35
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = call i32 @json_value_get_type(ptr noundef %48)
  %50 = icmp ne i32 %49, 4
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

52:                                               ; preds = %47
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call ptr @json_value_get_object(ptr noundef %53)
  store ptr %54, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 1
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call i32 @json_object_dotset_value(ptr noundef %55, ptr noundef %57, ptr noundef %58)
  store i32 %59, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

60:                                               ; preds = %35
  %61 = call ptr @json_value_init_object()
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %60
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

65:                                               ; preds = %60
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = call ptr @json_value_get_object(ptr noundef %66)
  store ptr %67, ptr %12, align 8, !tbaa !5
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 1
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call i32 @json_object_dotset_value(ptr noundef %68, ptr noundef %70, ptr noundef %71)
  store i32 %72, ptr %13, align 4, !tbaa !9
  %73 = load i32, ptr %13, align 4, !tbaa !9
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %65
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  call void @json_value_free(ptr noundef %76)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

77:                                               ; preds = %65
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = load i64, ptr %14, align 8, !tbaa !11
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = call i32 @json_object_addn(ptr noundef %78, ptr noundef %79, i64 noundef %80, ptr noundef %81)
  store i32 %82, ptr %13, align 4, !tbaa !9
  %83 = load i32, ptr %13, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %91

85:                                               ; preds = %77
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 1
  %89 = call i32 @json_object_dotremove_internal(ptr noundef %86, ptr noundef %88, i32 noundef 0)
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  call void @json_value_free(ptr noundef %90)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

91:                                               ; preds = %77
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %92

92:                                               ; preds = %91, %85, %75, %64, %52, %51, %30, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %93 = load i32, ptr %4, align 4
  ret i32 %93
}

; Function Attrs: nounwind uwtable
declare hidden i32 @json_object_addn(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @json_object_dotremove_internal(ptr noundef, ptr noundef, i32 noundef) #1

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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; 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: nounwind uwtable
declare hidden ptr @json_object_getn_value(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_value_get_object(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_value_get_type(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @json_value_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @json_value_init_object() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @json_object_dotset_value(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  %5 = icmp eq ptr %0, null
  %6 = icmp eq ptr %1, null
  %or.cond54 = or i1 %5, %6
  %or.cond355 = or i1 %4, %or.cond54
  br i1 %or.cond355, label %.loopexit, label %.lr.ph.split

.lr.ph.split:                                     ; preds = %3, %tailrecurse
  %.tr4657 = phi ptr [ %18, %tailrecurse ], [ %1, %3 ]
  %.tr56 = phi ptr [ %17, %tailrecurse ], [ %0, %3 ]
  %7 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %.tr4657, i32 noundef 46) #2
  %8 = icmp eq ptr %7, null
  br i1 %8, label %.split, label %10

.split:                                           ; preds = %.lr.ph.split
  %9 = tail call i32 @json_object_set_value(ptr noundef nonnull %.tr56, ptr noundef nonnull %.tr4657, ptr noundef nonnull %2)
  br label %.loopexit

10:                                               ; preds = %.lr.ph.split
  %11 = ptrtoint ptr %7 to i64
  %12 = ptrtoint ptr %.tr4657 to i64
  %13 = sub i64 %11, %12
  %14 = tail call ptr @json_object_getn_value(ptr noundef nonnull %.tr56, ptr noundef nonnull %.tr4657, i64 noundef %13)
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %.split60, label %15

15:                                               ; preds = %10
  %16 = tail call i32 @json_value_get_type(ptr noundef nonnull %14)
  %.not45 = icmp eq i32 %16, 4
  br i1 %.not45, label %tailrecurse, label %.loopexit

tailrecurse:                                      ; preds = %15
  %17 = tail call ptr @json_value_get_object(ptr noundef nonnull %14)
  %18 = getelementptr inbounds i8, ptr %7, i64 1
  %19 = icmp eq ptr %17, null
  br i1 %19, label %.loopexit, label %.lr.ph.split

.split60:                                         ; preds = %10
  %20 = tail call ptr @json_value_init_object()
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.loopexit, label %22

22:                                               ; preds = %.split60
  %23 = tail call ptr @json_value_get_object(ptr noundef nonnull %20)
  %24 = getelementptr inbounds i8, ptr %7, i64 1
  %25 = tail call i32 @json_object_dotset_value(ptr noundef %23, ptr noundef nonnull %24, ptr noundef nonnull %2)
  %.not43 = icmp eq i32 %25, 0
  br i1 %.not43, label %27, label %26

26:                                               ; preds = %22
  tail call void @json_value_free(ptr noundef nonnull %20)
  br label %.loopexit

27:                                               ; preds = %22
  %28 = tail call i32 @json_object_addn(ptr noundef nonnull %.tr56, ptr noundef nonnull %.tr4657, i64 noundef %13, ptr noundef nonnull %20)
  %.not44 = icmp eq i32 %28, 0
  br i1 %.not44, label %.loopexit, label %29

29:                                               ; preds = %27
  %30 = tail call i32 @json_object_dotremove_internal(ptr noundef %23, ptr noundef nonnull %24, i32 noundef 0)
  tail call void @json_value_free(ptr noundef nonnull %20)
  br label %.loopexit

.loopexit:                                        ; preds = %tailrecurse, %15, %3, %27, %.split60, %29, %26, %.split
  %.0 = phi i32 [ %9, %.split ], [ -1, %26 ], [ -1, %29 ], [ -1, %.split60 ], [ 0, %27 ], [ -1, %3 ], [ -1, %15 ], [ -1, %tailrecurse ]
  ret i32 %.0
}

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

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

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" }
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)"}


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