; LLVM IR from openssl/openssl :: ssl/quic (json_enc)

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

; Function Attrs: nounwind uwtable
declare hidden void @json_write_char(ptr noundef, i8 noundef signext) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_json_u64(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @ossl_json_i64(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %8 = load i64, ptr %4, align 8, !tbaa !9
  %9 = icmp sge i64 %8, 0
  br i1 %9, label %10, label %13

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i64, ptr %4, align 8, !tbaa !9
  call void @ossl_json_u64(ptr noundef %11, i64 noundef %12)
  store i32 1, ptr %7, align 4
  br label %58

13:                                               ; preds = %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call i32 @json_pre_item(ptr noundef %14)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  store i32 1, ptr %7, align 4
  br label %58

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @in_ijson(ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %30

22:                                               ; preds = %18
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = icmp sgt i64 %23, 9007199254740991
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = load i64, ptr %4, align 8, !tbaa !9
  %27 = icmp slt i64 %26, -9007199254740991
  br label %28

28:                                               ; preds = %25, %22
  %29 = phi i1 [ true, %22 ], [ %27, %25 ]
  br label %30

30:                                               ; preds = %28, %18
  %31 = phi i1 [ false, %18 ], [ %29, %28 ]
  %32 = zext i1 %31 to i32
  store i32 %32, ptr %6, align 4, !tbaa !11
  %33 = load i32, ptr %6, align 4, !tbaa !11
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %30
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %36, i8 noundef signext 34)
  br label %37

37:                                               ; preds = %35, %30
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %38, i8 noundef signext 45)
  %39 = load i64, ptr %4, align 8, !tbaa !9
  %40 = icmp eq i64 %39, -9223372036854775808
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  br label %45

42:                                               ; preds = %37
  %43 = load i64, ptr %4, align 8, !tbaa !9
  %44 = sub nsw i64 0, %43
  br label %45

45:                                               ; preds = %42, %41
  %46 = phi i64 [ -9223372036854775808, %41 ], [ %44, %42 ]
  store i64 %46, ptr %5, align 8, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i64, ptr %5, align 8, !tbaa !9
  call void @json_u64(ptr noundef %47, i64 noundef %48, i32 noundef 1)
  %49 = load i32, ptr %6, align 4, !tbaa !11
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %57

51:                                               ; preds = %45
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = call i32 @ossl_json_in_error(ptr noundef %52)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %57, label %55

55:                                               ; preds = %51
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %56, i8 noundef signext 34)
  br label %57

57:                                               ; preds = %55, %51, %45
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %57, %17, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %61 [
    i32 0, label %60
    i32 1, label %60
  ]

60:                                               ; preds = %58, %58
  ret void

61:                                               ; preds = %58
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @in_ijson(ptr noundef) #2

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 = { inlinehint 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

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

; Function Attrs: nounwind uwtable
declare hidden void @json_write_char(ptr noundef, i8 noundef signext) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare hidden void @json_u64(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @ossl_json_i64(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i64 %1, -1
  br i1 %3, label %4, label %5

4:                                                ; preds = %2
  tail call void @ossl_json_u64(ptr noundef %0, i64 noundef %1)
  br label %15

5:                                                ; preds = %2
  %6 = tail call i32 @json_pre_item(ptr noundef %0)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %15, label %7

7:                                                ; preds = %5
  %8 = tail call i32 @in_ijson(ptr noundef %0)
  %.not16 = icmp ne i32 %8, 0
  %9 = icmp ult i64 %1, -9007199254740991
  %spec.select = and i1 %9, %.not16
  br i1 %spec.select, label %10, label %.critedge

10:                                               ; preds = %7
  tail call void @json_write_char(ptr noundef %0, i8 noundef signext 34)
  tail call void @json_write_char(ptr noundef %0, i8 noundef signext 45)
  %11 = sub i64 0, %1
  tail call void @json_u64(ptr noundef %0, i64 noundef %11, i32 noundef 1)
  %12 = tail call i32 @ossl_json_in_error(ptr noundef %0)
  %.not17 = icmp eq i32 %12, 0
  br i1 %.not17, label %13, label %15

13:                                               ; preds = %10
  tail call void @json_write_char(ptr noundef %0, i8 noundef signext 34)
  br label %15

.critedge:                                        ; preds = %7
  tail call void @json_write_char(ptr noundef %0, i8 noundef signext 45)
  %14 = sub i64 0, %1
  tail call void @json_u64(ptr noundef %0, i64 noundef %14, i32 noundef 1)
  br label %15

15:                                               ; preds = %10, %13, %.critedge, %5, %4
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @in_ijson(ptr noundef) local_unnamed_addr #1

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

!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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass