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

; 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 i64 @jbn_visit(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_at2(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.jbn_vctx, align 8
  %9 = 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
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.jbl_ptr, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %17

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %15, ptr %16, align 8, !tbaa !5
  store i64 0, ptr %4, align 8
  br label %45

17:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #2
  %18 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 0
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %19, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 1
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %21, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 2
  store ptr null, ptr %22, align 8, !tbaa !17
  %23 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 3
  store ptr null, ptr %23, align 8, !tbaa !18
  %24 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 4
  store i32 -1, ptr %24, align 8, !tbaa !19
  %25 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 5
  store i8 0, ptr %25, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i64 @jbn_visit(ptr noundef %26, i32 noundef 0, ptr noundef %8, ptr noundef @_jbn_get_visitor)
  store i64 %27, ptr %9, align 8, !tbaa !21
  %28 = load i64, ptr %9, align 8, !tbaa !21
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %17
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %31, align 8, !tbaa !5
  br label %43

32:                                               ; preds = %17
  %33 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = icmp ne ptr %34, null
  br i1 %35, label %38, label %36

36:                                               ; preds = %32
  store i64 76009, ptr %9, align 8, !tbaa !21
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %37, align 8, !tbaa !5
  br label %42

38:                                               ; preds = %32
  %39 = getelementptr inbounds %struct.jbn_vctx, ptr %8, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %40, ptr %41, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %38, %36
  br label %43

43:                                               ; preds = %42, %30
  %44 = load i64, ptr %9, align 8, !tbaa !21
  store i64 %44, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #2
  br label %45

45:                                               ; preds = %43, %14
  %46 = load i64, ptr %4, align 8
  ret i64 %46
}

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

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 = { 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, !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 = !{!14, !6, i64 0}
!14 = !{!"jbn_vctx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !15, i64 36}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !12, i64 32}
!20 = !{!14, !15, i64 36}
!21 = !{!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.jbn_vctx = type { ptr, ptr, ptr, ptr, i32, 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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_at2(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca %struct.jbn_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 %9

8:                                                ; preds = %3
  store ptr %0, ptr %2, align 8, !tbaa !11
  br label %16

9:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #3
  store ptr %0, ptr %4, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %1, ptr %10, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %4, i64 16
  %12 = getelementptr inbounds i8, ptr %4, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  store i32 -1, ptr %12, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %4, i64 36
  store i8 0, ptr %13, align 4, !tbaa !18
  %14 = call i64 @jbn_visit(ptr noundef %0, i32 noundef 0, ptr noundef nonnull %4, ptr noundef nonnull @_jbn_get_visitor)
  %.not = icmp eq i64 %14, 0
  %15 = load ptr, ptr %11, align 8
  %.not14 = icmp eq ptr %15, null
  %.15 = select i1 %.not14, i64 76009, i64 0
  %.sink = select i1 %.not, ptr %15, ptr null
  %.0 = select i1 %.not, i64 %.15, i64 %14
  store ptr %.sink, ptr %2, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #3
  br label %16

16:                                               ; preds = %9, %8
  %.011 = phi i64 [ 0, %8 ], [ %.0, %9 ]
  ret i64 %.011
}

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

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

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"jbn_vctx", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !10, i64 32, !15, i64 36}
!15 = !{!"_Bool", !8, i64 0}
!16 = !{!14, !12, i64 8}
!17 = !{!14, !10, i64 32}
!18 = !{!14, !15, i64 36}


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