; LLVM IR from yinqiwen/ardb :: deps/cJSON (cJSON_Utils)

; 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.cJSON = type { ptr, ptr, ptr, i32, ptr, i32, double, ptr }

@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

19:                                               ; preds = %2
  %20 = call noalias ptr @strdup(ptr noundef @.str) #5
  store ptr %20, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %87

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.cJSON, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  store ptr %24, ptr %8, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %80, %21
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %86

28:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef %29, ptr noundef %30)
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %76

34:                                               ; preds = %28
  %35 = load i32, ptr %6, align 4, !tbaa !13
  %36 = icmp eq i32 %35, 32
  br i1 %36, label %37, label %48

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = call i64 @strlen(ptr noundef %38) #6
  %40 = add i64 %39, 23
  %41 = call noalias ptr @malloc(i64 noundef %40) #7
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !13
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %42, ptr noundef @.str.1, i32 noundef %43, ptr noundef %44) #5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %46) #5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %47, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %77

48:                                               ; preds = %34
  %49 = load i32, ptr %6, align 4, !tbaa !13
  %50 = icmp eq i32 %49, 64
  br i1 %50, label %51, label %73

51:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = call i64 @strlen(ptr noundef %52) #6
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.cJSON, ptr %54, i32 0, i32 7
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = call i32 @cJSONUtils_PointerEncodedstrlen(ptr noundef %56)
  %58 = sext i32 %57 to i64
  %59 = add i64 %53, %58
  %60 = add i64 %59, 2
  %61 = call noalias ptr @malloc(i64 noundef %60) #7
  store ptr %61, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  store i8 47, ptr %62, align 1, !tbaa !16
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 1
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.cJSON, ptr %65, i32 0, i32 7
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  call void @cJSONUtils_PointerEncodedstrcpy(ptr noundef %64, ptr noundef %67)
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = call ptr @strcat(ptr noundef %68, ptr noundef %69) #5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %71) #5
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %72, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %77

73:                                               ; preds = %48
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %75) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %77

76:                                               ; preds = %28
  store i32 0, ptr %9, align 4
  br label %77

77:                                               ; preds = %76, %74, %51, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %78 = load i32, ptr %9, align 4
  switch i32 %78, label %87 [
    i32 0, label %79
  ]

79:                                               ; preds = %77
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.cJSON, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  store ptr %83, ptr %8, align 8, !tbaa !5
  %84 = load i32, ptr %7, align 4, !tbaa !13
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %7, align 4, !tbaa !13
  br label %25, !llvm.loop !18

86:                                               ; preds = %25
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %87

87:                                               ; preds = %86, %77, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %88 = load ptr, ptr %3, align 8
  ret ptr %88
}

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; 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 hidden i32 @cJSONUtils_PointerEncodedstrlen(ptr noundef) #0

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

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind allocsize(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"cJSON", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !12, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 56}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %0, %1
  br i1 %5, label %6, label %8

6:                                                ; preds = %2
  %7 = tail call noalias ptr @strdup(ptr noundef nonnull @.str) #7
  br label %.thread

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %.03040 = load ptr, ptr %9, align 8, !tbaa !12
  %.not41 = icmp eq ptr %.03040, null
  br i1 %.not41, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %8, %30
  %.03043 = phi ptr [ %.030, %30 ], [ %.03040, %8 ]
  %.02942 = phi i32 [ %31, %30 ], [ 0, %8 ]
  %10 = tail call ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef nonnull %.03043, ptr noundef %1)
  %.not36 = icmp eq ptr %10, null
  br i1 %.not36, label %30, label %11

11:                                               ; preds = %.lr.ph
  switch i32 %4, label %29 [
    i32 32, label %12
    i32 64, label %17
  ]

12:                                               ; preds = %11
  %13 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %10) #8
  %14 = add i64 %13, 23
  %15 = tail call noalias ptr @malloc(i64 noundef %14) #9
  %16 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %15, ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.02942, ptr noundef nonnull %10) #7
  tail call void @free(ptr noundef nonnull %10) #7
  br label %.thread

17:                                               ; preds = %11
  %18 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %10) #8
  %19 = getelementptr inbounds i8, ptr %.03043, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = tail call i32 @cJSONUtils_PointerEncodedstrlen(ptr noundef %20)
  %22 = sext i32 %21 to i64
  %23 = add i64 %18, 2
  %24 = add i64 %23, %22
  %25 = tail call noalias ptr @malloc(i64 noundef %24) #9
  store i8 47, ptr %25, align 1, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %25, i64 1
  %27 = load ptr, ptr %19, align 8, !tbaa !13
  tail call void @cJSONUtils_PointerEncodedstrcpy(ptr noundef nonnull %26, ptr noundef %27)
  %28 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %25, ptr noundef nonnull dereferenceable(1) %10) #7
  tail call void @free(ptr noundef nonnull %10) #7
  br label %.thread

29:                                               ; preds = %11
  tail call void @free(ptr noundef nonnull %10) #7
  br label %.thread

30:                                               ; preds = %.lr.ph
  %31 = add nuw nsw i32 %.02942, 1
  %.030 = load ptr, ptr %.03043, align 8, !tbaa !12
  %.not = icmp eq ptr %.030, null
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !15

.thread:                                          ; preds = %30, %8, %12, %17, %29, %6
  %.2 = phi ptr [ %7, %6 ], [ null, %29 ], [ %25, %17 ], [ %15, %12 ], [ null, %8 ], [ null, %30 ]
  ret ptr %.2
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #6

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: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #4 = { nofree 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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0) }

!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 = !{!"cJSON", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !11, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 56}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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