; LLVM IR from Eclipse-SDV-Hackathon-Chapter-Two/challenge-threadx-and-beyond :: shared/lib/jsmn/src/test (tests)

; 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.jsmn_parser = type { i32, i32, i32 }
%struct.jsmntok = type { i32, i32, i32, i32 }

@.str.52 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; 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 dso_local void @jsmn_init(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @test_partial_string() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca %struct.jsmn_parser, align 4
  %5 = alloca [5 x %struct.jsmntok], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr @.str.52, ptr %6, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %4)
  store i64 1, ptr %3, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %48, %0
  %9 = load i64, ptr %3, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = call i64 @strlen(ptr noundef %10) #4
  %12 = icmp ule i64 %9, %11
  br i1 %12, label %13, label %51

13:                                               ; preds = %8
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i64, ptr %3, align 8, !tbaa !9
  %16 = getelementptr inbounds [5 x %struct.jsmntok], ptr %5, i64 0, i64 0
  %17 = call i32 @jsmn_parse(ptr noundef %4, ptr noundef %14, i64 noundef %15, ptr noundef %16, i32 noundef 5)
  store i32 %17, ptr %2, align 4, !tbaa !11
  %18 = load i64, ptr %3, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i64 @strlen(ptr noundef %19) #4
  %21 = icmp eq i64 %18, %20
  br i1 %21, label %22, label %39

22:                                               ; preds = %13
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %2, align 4, !tbaa !11
  %25 = icmp eq i32 %24, 5
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 110, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %52

27:                                               ; preds = %23
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds [5 x %struct.jsmntok], ptr %5, i64 0, i64 0
  %33 = call i32 (ptr, ptr, i64, ...) @tokeq(ptr noundef %31, ptr noundef %32, i64 noundef 5, i32 noundef 1, i32 noundef -1, i32 noundef -1, i32 noundef 2, i32 noundef 3, ptr noundef @.str.53, i32 noundef 1, i32 noundef 3, ptr noundef @.str.54, i32 noundef 0, i32 noundef 3, ptr noundef @.str.55, i32 noundef 1, i32 noundef 3, ptr noundef @.str.56, i32 noundef 0)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %30
  store i32 113, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %52

36:                                               ; preds = %30
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %47

39:                                               ; preds = %13
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %2, align 4, !tbaa !11
  %42 = icmp eq i32 %41, -3
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 115, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %52

44:                                               ; preds = %40
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46, %38
  br label %48

48:                                               ; preds = %47
  %49 = load i64, ptr %3, align 8, !tbaa !9
  %50 = add i64 %49, 1
  store i64 %50, ptr %3, align 8, !tbaa !9
  br label %8, !llvm.loop !13

51:                                               ; preds = %8
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %52

52:                                               ; preds = %51, %43, %35, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %53 = load i32, ptr %1, align 4
  ret i32 %53
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @tokeq(ptr noundef, ptr noundef, i64 noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%struct.jsmn_parser = type { i32, i32, i32 }
%struct.jsmntok = type { i32, i32, i32, i32 }

@.str.52 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 116) i32 @test_partial_string() local_unnamed_addr #0 {
  %1 = alloca %struct.jsmn_parser, align 4
  %2 = alloca [5 x %struct.jsmntok], align 16
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #3
  call void @jsmn_init(ptr noundef nonnull %1)
  %3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.52) #4
  %.not12 = icmp eq i64 %3, 0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %12
  %.01013 = phi i64 [ %13, %12 ], [ 1, %0 ]
  %4 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.52, i64 noundef %.01013, ptr noundef nonnull %2, i32 noundef 5)
  %5 = icmp eq i64 %.01013, %3
  br i1 %5, label %6, label %10

6:                                                ; preds = %.lr.ph
  %7 = icmp eq i32 %4, 5
  br i1 %7, label %8, label %._crit_edge

8:                                                ; preds = %6
  %9 = call i32 (ptr, ptr, i64, ...) @tokeq(ptr noundef nonnull @.str.52, ptr noundef nonnull %2, i64 noundef 5, i32 noundef 1, i32 noundef -1, i32 noundef -1, i32 noundef 2, i32 noundef 3, ptr noundef nonnull @.str.53, i32 noundef 1, i32 noundef 3, ptr noundef nonnull @.str.54, i32 noundef 0, i32 noundef 3, ptr noundef nonnull @.str.55, i32 noundef 1, i32 noundef 3, ptr noundef nonnull @.str.56, i32 noundef 0)
  %.not11 = icmp eq i32 %9, 0
  br i1 %.not11, label %._crit_edge, label %12

10:                                               ; preds = %.lr.ph
  %11 = icmp eq i32 %4, -3
  br i1 %11, label %12, label %._crit_edge

12:                                               ; preds = %8, %10
  %13 = add i64 %.01013, 1
  %.not = icmp ugt i64 %13, %3
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %6, %8, %10, %12, %0
  %.0 = phi i32 [ 0, %0 ], [ 0, %12 ], [ 115, %10 ], [ 113, %8 ], [ 110, %6 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #3
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @tokeq(ptr noundef, ptr noundef, i64 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass