; LLVM IR from adventure-db/adventure :: lib/jsmn (jsmn_test)

; 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_t = type { i32, i32, i32, i32 }

@.str.33 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [17 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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @test_unicode_characters() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.jsmn_parser, align 4
  %3 = alloca [10 x %struct.jsmntok_t], align 16
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 160, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store ptr @.str.33, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call i64 @strlen(ptr noundef %8) #4
  %10 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %11 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %7, i64 noundef %9, ptr noundef %10, i32 noundef 10)
  store i32 %11, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %0
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp sge i32 %13, 0
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 395, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  store ptr @.str.34, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i64 @strlen(ptr noundef %20) #4
  %22 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %23 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %19, i64 noundef %21, ptr noundef %22, i32 noundef 10)
  store i32 %23, ptr %5, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %18
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 400, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

28:                                               ; preds = %24
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  store ptr @.str.35, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call i64 @strlen(ptr noundef %32) #4
  %34 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %35 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %31, i64 noundef %33, ptr noundef %34, i32 noundef 10)
  store i32 %35, ptr %5, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %30
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp sge i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  store i32 405, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

40:                                               ; preds = %36
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  store ptr @.str.36, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = call i64 @strlen(ptr noundef %44) #4
  %46 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %47 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %43, i64 noundef %45, ptr noundef %46, i32 noundef 10)
  store i32 %47, ptr %5, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %42
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = icmp eq i32 %49, -2
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 410, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

52:                                               ; preds = %48
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  store ptr @.str.37, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = call i64 @strlen(ptr noundef %56) #4
  %58 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %59 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %55, i64 noundef %57, ptr noundef %58, i32 noundef 10)
  store i32 %59, ptr %5, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %54
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = icmp eq i32 %61, -2
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  store i32 415, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

64:                                               ; preds = %60
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  store ptr @.str.38, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = call i64 @strlen(ptr noundef %68) #4
  %70 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %71 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %67, i64 noundef %69, ptr noundef %70, i32 noundef 10)
  store i32 %71, ptr %5, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %66
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = icmp eq i32 %73, -2
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  store i32 420, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

76:                                               ; preds = %72
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  store ptr @.str.39, ptr %4, align 8, !tbaa !5
  call void @jsmn_init(ptr noundef %2)
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = call i64 @strlen(ptr noundef %80) #4
  %82 = getelementptr inbounds [10 x %struct.jsmntok_t], ptr %3, i64 0, i64 0
  %83 = call i32 @jsmn_parse(ptr noundef %2, ptr noundef %79, i64 noundef %81, ptr noundef %82, i32 noundef 10)
  store i32 %83, ptr %5, align 4, !tbaa !9
  br label %84

84:                                               ; preds = %78
  %85 = load i32, ptr %5, align 4, !tbaa !9
  %86 = icmp sge i32 %85, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  store i32 425, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

88:                                               ; preds = %84
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %91

91:                                               ; preds = %90, %87, %75, %63, %51, %39, %27, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 160, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %2) #3
  %92 = load i32, ptr %1, align 4
  ret i32 %92
}

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 = !{!"int", !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"

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

@.str.33 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [17 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 426) i32 @test_unicode_characters() local_unnamed_addr #0 {
  %1 = alloca %struct.jsmn_parser, align 4
  %2 = alloca [10 x %struct.jsmntok_t], align 16
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %2) #3
  call void @jsmn_init(ptr noundef nonnull %1)
  %3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.33) #4
  %4 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.33, i64 noundef %3, ptr noundef nonnull %2, i32 noundef 10)
  %5 = icmp sgt i32 %4, -1
  br i1 %5, label %6, label %29

6:                                                ; preds = %0
  call void @jsmn_init(ptr noundef nonnull %1)
  %7 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.34) #4
  %8 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.34, i64 noundef %7, ptr noundef nonnull %2, i32 noundef 10)
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %10, label %29

10:                                               ; preds = %6
  call void @jsmn_init(ptr noundef nonnull %1)
  %11 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.35) #4
  %12 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.35, i64 noundef %11, ptr noundef nonnull %2, i32 noundef 10)
  %13 = icmp sgt i32 %12, -1
  br i1 %13, label %14, label %29

14:                                               ; preds = %10
  call void @jsmn_init(ptr noundef nonnull %1)
  %15 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.36) #4
  %16 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.36, i64 noundef %15, ptr noundef nonnull %2, i32 noundef 10)
  %17 = icmp eq i32 %16, -2
  br i1 %17, label %18, label %29

18:                                               ; preds = %14
  call void @jsmn_init(ptr noundef nonnull %1)
  %19 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.37) #4
  %20 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.37, i64 noundef %19, ptr noundef nonnull %2, i32 noundef 10)
  %21 = icmp eq i32 %20, -2
  br i1 %21, label %22, label %29

22:                                               ; preds = %18
  call void @jsmn_init(ptr noundef nonnull %1)
  %23 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.38) #4
  %24 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.38, i64 noundef %23, ptr noundef nonnull %2, i32 noundef 10)
  %25 = icmp eq i32 %24, -2
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  call void @jsmn_init(ptr noundef nonnull %1)
  %27 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.39) #4
  %28 = call i32 @jsmn_parse(ptr noundef nonnull %1, ptr noundef nonnull @.str.39, i64 noundef %27, ptr noundef nonnull %2, i32 noundef 10)
  %.inv = icmp slt i32 %28, 0
  %. = select i1 %.inv, i32 425, i32 0
  br label %29

29:                                               ; preds = %26, %22, %18, %14, %10, %6, %0
  %.0 = phi i32 [ 395, %0 ], [ 400, %6 ], [ 405, %10 ], [ 410, %14 ], [ 415, %18 ], [ 420, %22 ], [ %., %26 ]
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #3
  ret i32 %.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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass