; LLVM IR from Slingshot-Physics/slingshot-community :: common/json/src (json_verify)

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

@transitions = external hidden global [16 x [24 x i32]], align 16
@.str.17 = external hidden unnamed_addr constant [16 x i8], align 1

; 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
declare dso_local void @json_parse_stack_append(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_parse_stack_pop_last(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_verify_state_termination(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_verify_goto_parent_container(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @json_verify_goto_parent_type(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @json_verify_char_type(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.json_parse_stack_s, ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.json_parse_stack_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = sub nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i32, ptr %11, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %18, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [16 x [24 x i32]], ptr @transitions, i64 0, i64 %20
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [24 x i32], ptr %21, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %25, ptr %7, align 4, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp eq i32 %26, -9
  br i1 %27, label %28, label %30

28:                                               ; preds = %2
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

30:                                               ; preds = %2
  %31 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %31, label %69 [
    i32 -5, label %32
    i32 -1, label %38
    i32 -2, label %49
  ]

32:                                               ; preds = %30
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @json_verify_goto_parent_type(ptr noundef %33)
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

37:                                               ; preds = %32
  br label %78

38:                                               ; preds = %30
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call i32 @json_verify_goto_parent_container(ptr noundef %39)
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %47, label %42

42:                                               ; preds = %38
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = call i32 @json_verify_state_termination(i32 noundef %43, i32 noundef %44)
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %42, %38
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

48:                                               ; preds = %42
  br label %78

49:                                               ; preds = %30
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call i32 @json_verify_goto_parent_container(ptr noundef %50)
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %67, label %53

53:                                               ; preds = %49
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = call i32 @json_verify_state_termination(i32 noundef %54, i32 noundef %55)
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %67, label %58

58:                                               ; preds = %53
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call i32 @json_verify_goto_parent_container(ptr noundef %59)
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %67, label %62

62:                                               ; preds = %58
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = call i32 @json_verify_state_termination(i32 noundef %63, i32 noundef %64)
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %62, %58, %53, %49
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

68:                                               ; preds = %62
  br label %78

69:                                               ; preds = %30
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 7
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = call i32 @json_parse_stack_pop_last(ptr noundef %73)
  br label %75

75:                                               ; preds = %72, %69
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !9
  call void @json_parse_stack_append(ptr noundef %76, i32 noundef %77)
  br label %78

78:                                               ; preds = %75, %68, %48, %37
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

79:                                               ; preds = %78, %67, %47, %36, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

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 = { "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 }

!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}
!11 = !{!12, !6, i64 8}
!12 = !{!"json_parse_stack_s", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !10, 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"

@transitions = external hidden local_unnamed_addr global [16 x [24 x i32]], align 16
@.str.17 = external hidden unnamed_addr constant [16 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @json_verify_char_type(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i32, ptr %0, align 8, !tbaa !11
  %6 = sext i32 %5 to i64
  %7 = getelementptr i32, ptr %4, i64 %6
  %8 = getelementptr i8, ptr %7, i64 -4
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = sext i32 %9 to i64
  %11 = sext i32 %1 to i64
  %12 = getelementptr inbounds [16 x [24 x i32]], ptr @transitions, i64 0, i64 %10, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !12
  switch i32 %13, label %37 [
    i32 -9, label %14
    i32 -5, label %16
    i32 -1, label %19
    i32 -2, label %25
  ]

14:                                               ; preds = %2
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  br label %43

16:                                               ; preds = %2
  %17 = tail call i32 @json_verify_goto_parent_type(ptr noundef nonnull %0)
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %43, label %42

19:                                               ; preds = %2
  %20 = tail call i32 @json_verify_goto_parent_container(ptr noundef nonnull %0)
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %43, label %22

22:                                               ; preds = %19
  %23 = tail call i32 @json_verify_state_termination(i32 noundef %9, i32 noundef %1)
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %43, label %42

25:                                               ; preds = %2
  %26 = tail call i32 @json_verify_goto_parent_container(ptr noundef nonnull %0)
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %43, label %28

28:                                               ; preds = %25
  %29 = tail call i32 @json_verify_state_termination(i32 noundef %9, i32 noundef %1)
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %43, label %31

31:                                               ; preds = %28
  %32 = tail call i32 @json_verify_goto_parent_container(ptr noundef nonnull %0)
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %43, label %34

34:                                               ; preds = %31
  %35 = tail call i32 @json_verify_state_termination(i32 noundef %9, i32 noundef %1)
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %43, label %42

37:                                               ; preds = %2
  %38 = icmp eq i32 %9, 7
  br i1 %38, label %39, label %41

39:                                               ; preds = %37
  %40 = tail call i32 @json_parse_stack_pop_last(ptr noundef nonnull %0)
  br label %41

41:                                               ; preds = %39, %37
  tail call void @json_parse_stack_append(ptr noundef nonnull %0, i32 noundef %13)
  br label %42

42:                                               ; preds = %34, %22, %16, %41
  br label %43

43:                                               ; preds = %25, %28, %31, %34, %19, %22, %16, %42, %14
  %.0 = phi i32 [ -1, %14 ], [ 1, %42 ], [ -1, %16 ], [ -1, %22 ], [ -1, %19 ], [ -1, %34 ], [ -1, %31 ], [ -1, %28 ], [ -1, %25 ]
  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 = { 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" }

!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 8}
!6 = !{!"json_parse_stack_s", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}


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