; 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"

%struct.ossl_json_enc_st = type { i32, i8, i8, i8, ptr, i8, [16 x i8], %struct.json_write_buf, i64, i64 }
%struct.json_write_buf = type { ptr, ptr, i64, i64 }

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

; Function Attrs: nounwind uwtable
define dso_local void @ossl_json_key(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = call i32 @ossl_json_in_error(ptr noundef %5)
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %51

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @json_peek(ptr noundef %10)
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_raise_error(ptr noundef %14)
  br label %51

15:                                               ; preds = %9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ossl_json_enc_st, ptr %16, i32 0, i32 3
  %18 = load i8, ptr %17, align 2, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %25

21:                                               ; preds = %15
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %22, i8 noundef signext 44)
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ossl_json_enc_st, ptr %23, i32 0, i32 3
  store i8 0, ptr %24, align 2, !tbaa !9
  br label %25

25:                                               ; preds = %21, %15
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_indent(ptr noundef %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ossl_json_enc_st, ptr %27, i32 0, i32 3
  %29 = load i8, ptr %28, align 2, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %25
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_raise_error(ptr noundef %33)
  br label %51

34:                                               ; preds = %25
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  call void @json_write_qstring(ptr noundef %35, ptr noundef %36)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = call i32 @ossl_json_in_error(ptr noundef %37)
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  br label %51

41:                                               ; preds = %34
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %42, i8 noundef signext 58)
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = call i32 @in_pretty(ptr noundef %43)
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %41
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  call void @json_write_char(ptr noundef %47, i8 noundef signext 32)
  br label %48

48:                                               ; preds = %46, %41
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ossl_json_enc_st, ptr %49, i32 0, i32 3
  store i8 1, ptr %50, align 2, !tbaa !9
  br label %51

51:                                               ; preds = %48, %40, %32, %13, %8
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @json_raise_error(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden void @json_indent(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @json_write_qstring(ptr noundef, ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @in_pretty(ptr noundef) #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 6}
!10 = !{!"ossl_json_enc_st", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !6, i64 8, !7, i64 16, !7, i64 17, !12, i64 40, !13, i64 72, !13, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"json_write_buf", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 24}
!13 = !{!"long", !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
define dso_local void @ossl_json_key(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @ossl_json_in_error(ptr noundef %0)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %21

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

6:                                                ; preds = %4
  tail call void @json_raise_error(ptr noundef %0)
  br label %21

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 6
  %9 = load i8, ptr %8, align 2, !tbaa !5
  %10 = icmp eq i8 %9, 2
  br i1 %10, label %11, label %12

11:                                               ; preds = %7
  tail call void @json_write_char(ptr noundef nonnull %0, i8 noundef signext 44)
  store i8 0, ptr %8, align 2, !tbaa !5
  br label %12

12:                                               ; preds = %11, %7
  tail call void @json_indent(ptr noundef nonnull %0)
  %13 = load i8, ptr %8, align 2, !tbaa !5
  %.not17 = icmp eq i8 %13, 0
  br i1 %.not17, label %15, label %14

14:                                               ; preds = %12
  tail call void @json_raise_error(ptr noundef nonnull %0)
  br label %21

15:                                               ; preds = %12
  tail call void @json_write_qstring(ptr noundef nonnull %0, ptr noundef %1)
  %16 = tail call i32 @ossl_json_in_error(ptr noundef nonnull %0)
  %.not18 = icmp eq i32 %16, 0
  br i1 %.not18, label %17, label %21

17:                                               ; preds = %15
  tail call void @json_write_char(ptr noundef nonnull %0, i8 noundef signext 58)
  %18 = tail call i32 @in_pretty(ptr noundef nonnull %0)
  %.not19 = icmp eq i32 %18, 0
  br i1 %.not19, label %20, label %19

19:                                               ; preds = %17
  tail call void @json_write_char(ptr noundef nonnull %0, i8 noundef signext 32)
  br label %20

20:                                               ; preds = %19, %17
  store i8 1, ptr %8, align 2, !tbaa !5
  br label %21

21:                                               ; preds = %15, %2, %20, %14, %6
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @json_raise_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 void @json_indent(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @in_pretty(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)"}
!5 = !{!6, !8, i64 6}
!6 = !{!"ossl_json_enc_st", !7, i64 0, !8, i64 4, !8, i64 5, !8, i64 6, !10, i64 8, !8, i64 16, !8, i64 17, !11, i64 40, !12, i64 72, !12, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"json_write_buf", !10, i64 0, !10, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"long", !8, i64 0}


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