; LLVM IR from ahiralesc/RTOS :: F767ZIT6/1_Task_management/Task_mgmt_vc_F7/Core/Src (core_json)

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

20:                                               ; preds = %7
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %29, label %23

23:                                               ; preds = %20
  %24 = load ptr, ptr %12, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %29, label %26

26:                                               ; preds = %23
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %26, %23, %20, %7
  store i32 5, ptr %15, align 4, !tbaa !11
  br label %45

30:                                               ; preds = %26
  %31 = load i64, ptr %9, align 8, !tbaa !9
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %36, label %33

33:                                               ; preds = %30
  %34 = load i64, ptr %11, align 8, !tbaa !9
  %35 = icmp eq i64 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %33, %30
  store i32 6, ptr %15, align 4, !tbaa !11
  br label %44

37:                                               ; preds = %33
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %9, align 8, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = call i32 @multiSearch(ptr noundef %38, i64 noundef %39, ptr noundef %40, i64 noundef %41, ptr noundef %16, ptr noundef %42)
  store i32 %43, ptr %15, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %37, %36
  br label %45

45:                                               ; preds = %44, %29
  %46 = load i32, ptr %15, align 4, !tbaa !11
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %73

48:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i64, ptr %16, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = call i32 @getType(i8 noundef signext %52)
  store i32 %53, ptr %17, align 4, !tbaa !11
  %54 = load i32, ptr %17, align 4, !tbaa !11
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %62

56:                                               ; preds = %48
  %57 = load i64, ptr %16, align 8, !tbaa !9
  %58 = add i64 %57, 1
  store i64 %58, ptr %16, align 8, !tbaa !9
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = sub i64 %60, 2
  store i64 %61, ptr %59, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %56, %48
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i64, ptr %16, align 8, !tbaa !9
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %65, ptr %66, align 8, !tbaa !5
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %72

69:                                               ; preds = %62
  %70 = load i32, ptr %17, align 4, !tbaa !11
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 %70, ptr %71, align 4, !tbaa !11
  br label %72

72:                                               ; preds = %69, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  br label %73

73:                                               ; preds = %72, %45
  %74 = load i32, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  ret i32 %74
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @getType(i8 noundef signext) #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 }

!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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 i32 @JSON_SearchConst(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef writeonly %4, ptr noundef %5, ptr noundef writeonly %6) local_unnamed_addr #1 {
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #2
  store i64 0, ptr %8, align 8, !tbaa !5
  %9 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %10 = insertelement <4 x ptr> %9, ptr %2, i64 1
  %11 = insertelement <4 x ptr> %10, ptr %4, i64 2
  %12 = insertelement <4 x ptr> %11, ptr %5, i64 3
  %13 = icmp eq <4 x ptr> %12, zeroinitializer
  %14 = bitcast <4 x i1> %13 to i4
  %.not35 = icmp eq i4 %14, 0
  br i1 %.not35, label %15, label %.thread

15:                                               ; preds = %7
  %16 = icmp eq i64 %1, 0
  %17 = icmp eq i64 %3, 0
  %or.cond7 = or i1 %16, %17
  br i1 %or.cond7, label %.thread, label %18

18:                                               ; preds = %15
  %19 = call i32 @multiSearch(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2, i64 noundef %3, ptr noundef nonnull %8, ptr noundef nonnull %5)
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %.thread

21:                                               ; preds = %18
  %22 = load i64, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = call i32 @getType(i8 noundef signext %24)
  %26 = icmp eq i32 %25, 1
  %.pre = load i64, ptr %8, align 8, !tbaa !5
  br i1 %26, label %27, label %31

27:                                               ; preds = %21
  %28 = add i64 %.pre, 1
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = add i64 %29, -2
  store i64 %30, ptr %5, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %27, %21
  %32 = phi i64 [ %28, %27 ], [ %.pre, %21 ]
  %33 = getelementptr inbounds i8, ptr %0, i64 %32
  store ptr %33, ptr %4, align 8, !tbaa !10
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %.thread, label %34

34:                                               ; preds = %31
  store i32 %25, ptr %6, align 4, !tbaa !12
  br label %.thread

.thread:                                          ; preds = %15, %7, %31, %34, %18
  %.034 = phi i32 [ 1, %31 ], [ 1, %34 ], [ %19, %18 ], [ 6, %15 ], [ 5, %7 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #2
  ret i32 %.034
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @getType(i8 noundef signext) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass