; LLVM IR from Softmotions/iowow :: src/json (iwjson)

; 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.jbl_vctx = type { ptr, ptr, ptr, ptr, i32, i8, i8 }
%struct.jbl_ptr = type { i64, i32, i32, [1 x ptr] }
%struct.jbl = type { %struct.binn_struct, ptr }
%struct.binn_struct = type { i32, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, %union.anon }
%union.anon = type { i64 }

; 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

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbl_at2(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.jbl_vctx, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.jbl_ptr, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %39

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %17 = call noalias ptr @malloc(i64 noundef 96) #7
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %23, label %19

19:                                               ; preds = %16
  %20 = call ptr @__errno_location() #8
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %21)
  store i64 %22, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %38

23:                                               ; preds = %16
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.jbl, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.jbl, ptr %26, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %27, i64 88, i1 false)
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.jbl, ptr %28, i32 0, i32 1
  store ptr null, ptr %29, align 8, !tbaa !14
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.jbl, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.binn_struct, ptr %31, i32 0, i32 1
  store i32 0, ptr %32, align 4, !tbaa !17
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.jbl, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.binn_struct, ptr %34, i32 0, i32 12
  store ptr null, ptr %35, align 8, !tbaa !18
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %36, ptr %37, align 8, !tbaa !5
  store i64 0, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %38

38:                                               ; preds = %23, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %68

39:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #6
  %40 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 0
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.jbl, ptr %41, i32 0, i32 0
  store ptr %42, ptr %40, align 8, !tbaa !19
  %43 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 1
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %44, ptr %43, align 8, !tbaa !22
  %45 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 2
  store ptr null, ptr %45, align 8, !tbaa !23
  %46 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 3
  store ptr null, ptr %46, align 8, !tbaa !24
  %47 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 4
  store i32 -1, ptr %47, align 8, !tbaa !25
  %48 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 5
  store i8 0, ptr %48, align 4, !tbaa !26
  %49 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 6
  store i8 0, ptr %49, align 1, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %50 = call i64 @_jbl_visit(ptr noundef null, i32 noundef 0, ptr noundef %10, ptr noundef @_jbl_get_visitor)
  store i64 %50, ptr %11, align 8, !tbaa !28
  %51 = load i64, ptr %11, align 8, !tbaa !28
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %39
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %54, align 8, !tbaa !5
  br label %66

55:                                               ; preds = %39
  %56 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  %58 = icmp ne ptr %57, null
  br i1 %58, label %61, label %59

59:                                               ; preds = %55
  store i64 76009, ptr %11, align 8, !tbaa !28
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %60, align 8, !tbaa !5
  br label %65

61:                                               ; preds = %55
  %62 = getelementptr inbounds %struct.jbl_vctx, ptr %10, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %63, ptr %64, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %61, %59
  br label %66

66:                                               ; preds = %65, %53
  %67 = load i64, ptr %11, align 8, !tbaa !28
  store i64 %67, ptr %4, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #6
  br label %68

68:                                               ; preds = %66, %38
  %69 = load i64, ptr %4, align 8
  ret i64 %69
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_jbl_get_visitor(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nounwind willreturn memory(none) "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 allocsize(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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(none) }

!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, !12, i64 8}
!10 = !{!"jbl_ptr", !11, i64 0, !12, i64 8, !12, i64 12, !7, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!15, !6, i64 88}
!15 = !{!"jbl", !16, i64 0, !6, i64 88}
!16 = !{!"binn_struct", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !7, i64 80}
!17 = !{!15, !12, i64 4}
!18 = !{!15, !6, i64 56}
!19 = !{!20, !6, i64 0}
!20 = !{!"jbl_vctx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !21, i64 36, !21, i64 37}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!20, !6, i64 8}
!23 = !{!20, !6, i64 16}
!24 = !{!20, !6, i64 24}
!25 = !{!20, !12, i64 32}
!26 = !{!20, !21, i64 36}
!27 = !{!20, !21, i64 37}
!28 = !{!11, !11, 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.jbl_vctx = type { ptr, ptr, ptr, ptr, i32, i8, i8 }

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

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

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbl_at2(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #5 {
  %4 = alloca %struct.jbl_vctx, align 8
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %18

8:                                                ; preds = %3
  %9 = tail call noalias dereferenceable_or_null(96) ptr @malloc(i64 noundef 96) #7
  %.not21 = icmp eq ptr %9, null
  br i1 %.not21, label %10, label %14

10:                                               ; preds = %8
  %11 = tail call ptr @__errno_location() #8
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %12) #9
  br label %26

14:                                               ; preds = %8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(88) %9, ptr noundef nonnull align 8 dereferenceable(88) %0, i64 88, i1 false)
  %15 = getelementptr inbounds i8, ptr %9, i64 88
  store ptr null, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %9, i64 4
  store i32 0, ptr %16, align 4, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %9, i64 56
  store ptr null, ptr %17, align 8, !tbaa !17
  store ptr %9, ptr %2, align 8, !tbaa !18
  br label %26

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #9
  store ptr %0, ptr %4, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %1, ptr %19, align 8, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %4, i64 16
  %21 = getelementptr inbounds i8, ptr %4, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %20, i8 0, i64 16, i1 false)
  store i32 -1, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds i8, ptr %4, i64 36
  store i8 0, ptr %22, align 4, !tbaa !24
  %23 = getelementptr inbounds i8, ptr %4, i64 37
  store i8 0, ptr %23, align 1, !tbaa !25
  %24 = call i64 @_jbl_visit(ptr noundef null, i32 noundef 0, ptr noundef nonnull %4, ptr noundef nonnull @_jbl_get_visitor)
  %.not = icmp eq i64 %24, 0
  %25 = load ptr, ptr %20, align 8
  %.not20 = icmp eq ptr %25, null
  %.22 = select i1 %.not20, i64 76009, i64 0
  %.sink = select i1 %.not, ptr %25, ptr null
  %.0 = select i1 %.not, i64 %.22, i64 %24
  store ptr %.sink, ptr %2, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #9
  br label %26

26:                                               ; preds = %10, %14, %18
  %.1 = phi i64 [ %.0, %18 ], [ 0, %14 ], [ %13, %10 ]
  ret i64 %.1
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_jbl_get_visitor(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { 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, !10, i64 8}
!6 = !{!"jbl_ptr", !7, i64 0, !10, i64 8, !10, i64 12, !8, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !15, i64 88}
!13 = !{!"jbl", !14, i64 0, !15, i64 88}
!14 = !{!"binn_struct", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !15, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !15, i64 40, !10, i64 48, !10, i64 52, !15, i64 56, !15, i64 64, !15, i64 72, !8, i64 80}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!13, !10, i64 4}
!17 = !{!13, !15, i64 56}
!18 = !{!15, !15, i64 0}
!19 = !{!20, !15, i64 0}
!20 = !{!"jbl_vctx", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !10, i64 32, !21, i64 36, !21, i64 37}
!21 = !{!"_Bool", !8, i64 0}
!22 = !{!20, !15, i64 8}
!23 = !{!20, !10, i64 32}
!24 = !{!20, !21, i64 36}
!25 = !{!20, !21, i64 37}


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