; LLVM IR from ybj366533/YY-Camera :: yy_videolib/src/main/jni/yysticker/lib-sticker-core/json (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 [7 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 i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = 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 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %17, label %14

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

17:                                               ; preds = %14, %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %98

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = icmp eq ptr %19, %20
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = call ptr @cJSONUtils_strdup(ptr noundef @.str)
  store ptr %23, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %98

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.cJSON, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  store ptr %27, ptr %7, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %91, %24
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %97

31:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef %32, ptr noundef %33)
  store ptr %34, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %87

37:                                               ; preds = %31
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call i32 @cJSON_IsArray(ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %59

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = call i64 @strlen(ptr noundef %42) #6
  %44 = add i64 %43, 20
  %45 = add i64 %44, 2
  %46 = call ptr @cJSON_malloc(i64 noundef %45)
  store ptr %46, ptr %10, align 8, !tbaa !5
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = icmp ugt i64 %47, -1
  br i1 %48, label %49, label %51

49:                                               ; preds = %41
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cJSON_free(ptr noundef %50)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %58

51:                                               ; preds = %41
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %52, ptr noundef @.str.1, i64 noundef %53, ptr noundef %54) #5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cJSON_free(ptr noundef %56)
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %57, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %58

58:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %88

59:                                               ; preds = %37
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = call i32 @cJSON_IsObject(ptr noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %85

63:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = call i64 @strlen(ptr noundef %64) #6
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.cJSON, ptr %66, i32 0, i32 7
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = call i64 @pointer_encoded_length(ptr noundef %68)
  %70 = add i64 %65, %69
  %71 = add i64 %70, 2
  %72 = call ptr @cJSON_malloc(i64 noundef %71)
  store ptr %72, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 0
  store i8 47, ptr %74, align 1, !tbaa !16
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 1
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.cJSON, ptr %77, i32 0, i32 7
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  call void @encode_string_as_pointer(ptr noundef %76, ptr noundef %79)
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = call ptr @strcat(ptr noundef %80, ptr noundef %81) #5
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cJSON_free(ptr noundef %83)
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %84, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %88

85:                                               ; preds = %59
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cJSON_free(ptr noundef %86)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %88

87:                                               ; preds = %31
  store i32 0, ptr %8, align 4
  br label %88

88:                                               ; preds = %87, %85, %63, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %89 = load i32, ptr %8, align 4
  switch i32 %89, label %98 [
    i32 0, label %90
  ]

90:                                               ; preds = %88
  br label %91

91:                                               ; preds = %90
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.cJSON, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  store ptr %94, ptr %7, align 8, !tbaa !5
  %95 = load i64, ptr %6, align 8, !tbaa !9
  %96 = add i64 %95, 1
  store i64 %96, ptr %6, align 8, !tbaa !9
  br label %28, !llvm.loop !18

97:                                               ; preds = %28
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %98

98:                                               ; preds = %97, %88, %22, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %99 = load ptr, ptr %3, align 8
  ret ptr %99
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @cJSONUtils_strdup(ptr noundef) #0

declare i32 @cJSON_IsArray(ptr noundef) #2

declare ptr @cJSON_malloc(i64 noundef) #2

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

declare void @cJSON_free(ptr noundef) #2

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

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

declare i32 @cJSON_IsObject(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @pointer_encoded_length(ptr noundef) #0

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

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

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 = { "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 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 #4 = { 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 = { nounwind }
attributes #6 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"cJSON", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !13, i64 40, !14, i64 48, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !6, i64 56}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %.thread, label %5

5:                                                ; preds = %2
  %6 = icmp eq ptr %0, %1
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call ptr @cJSONUtils_strdup(ptr noundef nonnull @.str)
  br label %.thread

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %.03446 = load ptr, ptr %10, align 8, !tbaa !5
  %.not47 = icmp eq ptr %.03446, null
  br i1 %.not47, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %9, %33
  %.03449 = phi ptr [ %.034, %33 ], [ %.03446, %9 ]
  %.03348 = phi i64 [ %34, %33 ], [ 0, %9 ]
  %11 = tail call ptr @cJSONUtils_FindPointerFromObjectTo(ptr noundef nonnull %.03449, ptr noundef %1)
  %.not40 = icmp eq ptr %11, null
  br i1 %.not40, label %33, label %12

12:                                               ; preds = %.lr.ph
  %13 = tail call i32 @cJSON_IsArray(ptr noundef %0) #5
  %.not41 = icmp eq i32 %13, 0
  br i1 %.not41, label %19, label %14

14:                                               ; preds = %12
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %11) #6
  %16 = add i64 %15, 22
  %17 = tail call ptr @cJSON_malloc(i64 noundef %16) #5
  %18 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %17, ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.03348, ptr noundef nonnull %11) #5
  tail call void @cJSON_free(ptr noundef nonnull %11) #5
  br label %.thread

19:                                               ; preds = %12
  %20 = tail call i32 @cJSON_IsObject(ptr noundef %0) #5
  %.not42 = icmp eq i32 %20, 0
  br i1 %.not42, label %32, label %21

21:                                               ; preds = %19
  %22 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %11) #6
  %23 = getelementptr inbounds i8, ptr %.03449, i64 56
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = tail call i64 @pointer_encoded_length(ptr noundef %24)
  %26 = add i64 %22, 2
  %27 = add i64 %26, %25
  %28 = tail call ptr @cJSON_malloc(i64 noundef %27) #5
  store i8 47, ptr %28, align 1, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = load ptr, ptr %23, align 8, !tbaa !9
  tail call void @encode_string_as_pointer(ptr noundef nonnull %29, ptr noundef %30)
  %31 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) %11) #5
  tail call void @cJSON_free(ptr noundef nonnull %11) #5
  br label %.thread

32:                                               ; preds = %19
  tail call void @cJSON_free(ptr noundef nonnull %11) #5
  br label %.thread

33:                                               ; preds = %.lr.ph
  %34 = add i64 %.03348, 1
  %.034 = load ptr, ptr %.03449, align 8, !tbaa !5
  %.not = icmp eq ptr %.034, null
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !14

.thread:                                          ; preds = %33, %9, %14, %21, %32, %2, %7
  %.3 = phi ptr [ %8, %7 ], [ null, %2 ], [ null, %32 ], [ %28, %21 ], [ %17, %14 ], [ null, %9 ], [ null, %33 ]
  ret ptr %.3
}

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

declare i32 @cJSON_IsArray(ptr noundef) local_unnamed_addr #1

declare ptr @cJSON_malloc(i64 noundef) local_unnamed_addr #1

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

declare void @cJSON_free(ptr noundef) local_unnamed_addr #1

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

declare i32 @cJSON_IsObject(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden void @encode_string_as_pointer(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 #4

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 = { "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 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !6, i64 56}
!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 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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