; 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_node = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, %union.anon.0 }
%union.anon.0 = type { 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 allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @jbn_add_item(ptr noundef, ptr noundef) #6

declare ptr @iwpool_calloc(i64 noundef, ptr noundef) #2

declare ptr @iwpool_strdup(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #7

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_add_item_null(ptr noundef %0, ptr noundef %1, ptr noundef %2) #6 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  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
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %18

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.jbl_node, ptr %14, i32 0, i32 8
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = icmp ult i32 %16, 6
  br i1 %17, label %18, label %19

18:                                               ; preds = %13, %3
  store i64 70017, ptr %4, align 8
  br label %101

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 0, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  %22 = xor i1 %21, true
  %23 = xor i1 %22, true
  %24 = zext i1 %23 to i32
  %25 = sext i32 %24 to i64
  %26 = call i64 @llvm.expect.i64(i64 %25, i64 1)
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %19
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call ptr @iwpool_calloc(i64 noundef 64, ptr noundef %29)
  store ptr %30, ptr %9, align 8, !tbaa !5
  br label %33

31:                                               ; preds = %19
  %32 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 64) #9
  store ptr %32, ptr %9, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %31, %28
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %40, label %36

36:                                               ; preds = %33
  %37 = call ptr @__errno_location() #10
  %38 = load i32, ptr %37, align 4, !tbaa !14
  %39 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %38)
  store i64 %39, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %100

40:                                               ; preds = %33
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.jbl_node, ptr %41, i32 0, i32 8
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 6
  br i1 %44, label %45, label %93

45:                                               ; preds = %40
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %49, label %48

48:                                               ; preds = %45
  store i64 70017, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %100

49:                                               ; preds = %45
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  %52 = xor i1 %51, true
  %53 = xor i1 %52, true
  %54 = zext i1 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = call i64 @llvm.expect.i64(i64 %55, i64 1)
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %58, label %74

58:                                               ; preds = %49
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = call ptr @iwpool_strdup(ptr noundef %59, ptr noundef %60, ptr noundef %8)
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.jbl_node, ptr %62, i32 0, i32 3
  store ptr %61, ptr %63, align 8, !tbaa !15
  %64 = load i64, ptr %8, align 8, !tbaa !12
  %65 = icmp ne i64 %64, 0
  %66 = xor i1 %65, true
  %67 = xor i1 %66, true
  %68 = zext i1 %67 to i32
  %69 = sext i32 %68 to i64
  %70 = call i64 @llvm.expect.i64(i64 %69, i64 0)
  %71 = icmp ne i64 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %58
  br label %98

73:                                               ; preds = %58
  br label %85

74:                                               ; preds = %49
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call noalias ptr @strdup(ptr noundef %75) #8
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.jbl_node, ptr %77, i32 0, i32 3
  store ptr %76, ptr %78, align 8, !tbaa !15
  %79 = icmp ne ptr %76, null
  br i1 %79, label %84, label %80

80:                                               ; preds = %74
  %81 = call ptr @__errno_location() #10
  %82 = load i32, ptr %81, align 4, !tbaa !14
  %83 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %82)
  store i64 %83, ptr %8, align 8, !tbaa !12
  br label %98

84:                                               ; preds = %74
  br label %85

85:                                               ; preds = %84, %73
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.jbl_node, ptr %86, i32 0, i32 3
  %88 = load ptr, ptr %87, align 8, !tbaa !15
  %89 = call i64 @strlen(ptr noundef %88) #11
  %90 = trunc i64 %89 to i32
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.jbl_node, ptr %91, i32 0, i32 4
  store i32 %90, ptr %92, align 8, !tbaa !16
  br label %93

93:                                               ; preds = %85, %40
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.jbl_node, ptr %94, i32 0, i32 8
  store i32 1, ptr %95, align 4, !tbaa !9
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  call void @jbn_add_item(ptr noundef %96, ptr noundef %97)
  br label %98

98:                                               ; preds = %93, %80, %72
  %99 = load i64, ptr %8, align 8, !tbaa !12
  store i64 %99, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %100

100:                                              ; preds = %98, %48, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %101

101:                                              ; preds = %100, %18
  %102 = load i64, ptr %4, align 8
  ret i64 %102
}

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

!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, !11, i64 52}
!10 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !7, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 32}


; 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: 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @jbn_add_item(ptr noundef, ptr noundef) local_unnamed_addr #5

declare ptr @iwpool_calloc(i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @iwpool_strdup(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local i64 @jbn_add_item_null(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #5 {
  %4 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %42, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 52
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 6
  br i1 %8, label %42, label %9

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  store i64 0, ptr %4, align 8, !tbaa !11
  %.not23 = icmp eq ptr %2, null
  br i1 %.not23, label %12, label %10, !prof !13

10:                                               ; preds = %9
  %11 = tail call ptr @iwpool_calloc(i64 noundef 64, ptr noundef nonnull %2) #7
  br label %14

12:                                               ; preds = %9
  %13 = tail call noalias dereferenceable_or_null(64) ptr @calloc(i64 noundef 1, i64 noundef 64) #8
  br label %14

14:                                               ; preds = %12, %10
  %.0 = phi ptr [ %11, %10 ], [ %13, %12 ]
  %.not24 = icmp eq ptr %.0, null
  br i1 %.not24, label %15, label %19

15:                                               ; preds = %14
  %16 = tail call ptr @__errno_location() #9
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %17) #7
  br label %41

19:                                               ; preds = %14
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 6
  br i1 %21, label %22, label %39

22:                                               ; preds = %19
  %.not25 = icmp eq ptr %1, null
  br i1 %.not25, label %41, label %23

23:                                               ; preds = %22
  %24 = getelementptr inbounds i8, ptr %.0, i64 24
  br i1 %.not23, label %28, label %25, !prof !13

25:                                               ; preds = %23
  %26 = call ptr @iwpool_strdup(ptr noundef nonnull %2, ptr noundef nonnull %1, ptr noundef nonnull %4) #7
  store ptr %26, ptr %24, align 8, !tbaa !15
  %27 = load i64, ptr %4, align 8, !tbaa !11
  %.not27 = icmp eq i64 %27, 0
  br i1 %.not27, label %34, label %41, !prof !16

28:                                               ; preds = %23
  %29 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #7
  store ptr %29, ptr %24, align 8, !tbaa !15
  %.not26 = icmp eq ptr %29, null
  br i1 %.not26, label %30, label %34

30:                                               ; preds = %28
  %31 = tail call ptr @__errno_location() #9
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %32) #7
  br label %41

34:                                               ; preds = %28, %25
  %35 = phi ptr [ %29, %28 ], [ %26, %25 ]
  %36 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %35) #10
  %37 = trunc i64 %36 to i32
  %38 = getelementptr inbounds i8, ptr %.0, i64 32
  store i32 %37, ptr %38, align 8, !tbaa !17
  br label %39

39:                                               ; preds = %34, %19
  %40 = getelementptr inbounds i8, ptr %.0, i64 52
  store i32 1, ptr %40, align 4, !tbaa !5
  call void @jbn_add_item(ptr noundef nonnull %0, ptr noundef nonnull %.0)
  %.pre = load i64, ptr %4, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %30, %39, %25, %22, %15
  %.018 = phi i64 [ %18, %15 ], [ 70017, %22 ], [ %27, %25 ], [ %.pre, %39 ], [ %33, %30 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %42

42:                                               ; preds = %3, %5, %41
  %.1 = phi i64 [ %.018, %41 ], [ 70017, %5 ], [ 70017, %3 ]
  ret i64 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #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 = { 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 #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite, 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { nounwind willreturn memory(read) }

!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 52}
!6 = !{!"jbl_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 48, !10, i64 52, !8, i64 56}
!7 = !{!"any pointer", !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 = !{!"long", !8, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 24}
!16 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!17 = !{!6, !10, i64 32}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass