; 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_f64(ptr noundef %0, ptr noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4) #6 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %22

17:                                               ; preds = %5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.jbl_node, ptr %18, i32 0, i32 8
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = icmp ult i32 %20, 6
  br i1 %21, label %22, label %23

22:                                               ; preds = %17, %5
  store i64 70017, ptr %6, align 8
  br label %114

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  store i64 0, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  %26 = xor i1 %25, true
  %27 = xor i1 %26, true
  %28 = zext i1 %27 to i32
  %29 = sext i32 %28 to i64
  %30 = call i64 @llvm.expect.i64(i64 %29, i64 1)
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %23
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = call ptr @iwpool_calloc(i64 noundef 64, ptr noundef %33)
  store ptr %34, ptr %13, align 8, !tbaa !5
  br label %37

35:                                               ; preds = %23
  %36 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 64) #9
  store ptr %36, ptr %13, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %35, %32
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %37
  %41 = call ptr @__errno_location() #10
  %42 = load i32, ptr %41, align 4, !tbaa !16
  %43 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %42)
  store i64 %43, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %113

44:                                               ; preds = %37
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.jbl_node, ptr %45, i32 0, i32 8
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = icmp eq i32 %47, 6
  br i1 %48, label %49, label %97

49:                                               ; preds = %44
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  store i64 70017, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %113

53:                                               ; preds = %49
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  %56 = xor i1 %55, true
  %57 = xor i1 %56, true
  %58 = zext i1 %57 to i32
  %59 = sext i32 %58 to i64
  %60 = call i64 @llvm.expect.i64(i64 %59, i64 1)
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %78

62:                                               ; preds = %53
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = call ptr @iwpool_strdup(ptr noundef %63, ptr noundef %64, ptr noundef %12)
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.jbl_node, ptr %66, i32 0, i32 3
  store ptr %65, ptr %67, align 8, !tbaa !17
  %68 = load i64, ptr %12, align 8, !tbaa !14
  %69 = icmp ne i64 %68, 0
  %70 = xor i1 %69, true
  %71 = xor i1 %70, true
  %72 = zext i1 %71 to i32
  %73 = sext i32 %72 to i64
  %74 = call i64 @llvm.expect.i64(i64 %73, i64 0)
  %75 = icmp ne i64 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %62
  br label %111

77:                                               ; preds = %62
  br label %89

78:                                               ; preds = %53
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = call noalias ptr @strdup(ptr noundef %79) #8
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.jbl_node, ptr %81, i32 0, i32 3
  store ptr %80, ptr %82, align 8, !tbaa !17
  %83 = icmp ne ptr %80, null
  br i1 %83, label %88, label %84

84:                                               ; preds = %78
  %85 = call ptr @__errno_location() #10
  %86 = load i32, ptr %85, align 4, !tbaa !16
  %87 = call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %86)
  store i64 %87, ptr %12, align 8, !tbaa !14
  br label %111

88:                                               ; preds = %78
  br label %89

89:                                               ; preds = %88, %77
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.jbl_node, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = call i64 @strlen(ptr noundef %92) #11
  %94 = trunc i64 %93 to i32
  %95 = load ptr, ptr %13, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.jbl_node, ptr %95, i32 0, i32 4
  store i32 %94, ptr %96, align 8, !tbaa !18
  br label %97

97:                                               ; preds = %89, %44
  %98 = load ptr, ptr %13, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.jbl_node, ptr %98, i32 0, i32 8
  store i32 4, ptr %99, align 4, !tbaa !11
  %100 = load double, ptr %9, align 8, !tbaa !9
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.jbl_node, ptr %101, i32 0, i32 9
  store double %100, ptr %102, align 8, !tbaa !19
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = load ptr, ptr %13, align 8, !tbaa !5
  call void @jbn_add_item(ptr noundef %103, ptr noundef %104)
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %110

107:                                              ; preds = %97
  %108 = load ptr, ptr %13, align 8, !tbaa !5
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %108, ptr %109, align 8, !tbaa !5
  br label %110

110:                                              ; preds = %107, %97
  br label %111

111:                                              ; preds = %110, %84, %76
  %112 = load i64, ptr %12, align 8, !tbaa !14
  store i64 %112, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %113

113:                                              ; preds = %111, %52, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  br label %114

114:                                              ; preds = %113, %22
  %115 = load i64, ptr %6, align 8
  ret i64 %115
}

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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 52}
!12 = !{!"jbl_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 36, !6, i64 40, !13, i64 48, !13, i64 52, !7, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !13, i64 32}
!19 = !{!7, !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: 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_f64(ptr noundef %0, ptr noundef %1, double noundef %2, ptr noundef writeonly %3, ptr noundef %4) local_unnamed_addr #5 {
  %6 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %48, label %7

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

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

12:                                               ; preds = %11
  %13 = tail call ptr @iwpool_calloc(i64 noundef 64, ptr noundef nonnull %4) #7
  br label %16

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

16:                                               ; preds = %14, %12
  %.0 = phi ptr [ %13, %12 ], [ %15, %14 ]
  %.not30 = icmp eq ptr %.0, null
  br i1 %.not30, label %17, label %21

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

21:                                               ; preds = %16
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 6
  br i1 %23, label %24, label %41

24:                                               ; preds = %21
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %47, label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds i8, ptr %.0, i64 24
  br i1 %.not29, label %30, label %27, !prof !13

27:                                               ; preds = %25
  %28 = call ptr @iwpool_strdup(ptr noundef nonnull %4, ptr noundef nonnull %1, ptr noundef nonnull %6) #7
  store ptr %28, ptr %26, align 8, !tbaa !15
  %29 = load i64, ptr %6, align 8, !tbaa !11
  %.not33 = icmp eq i64 %29, 0
  br i1 %.not33, label %36, label %45, !prof !16

30:                                               ; preds = %25
  %31 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #7
  store ptr %31, ptr %26, align 8, !tbaa !15
  %.not32 = icmp eq ptr %31, null
  br i1 %.not32, label %32, label %36

32:                                               ; preds = %30
  %33 = tail call ptr @__errno_location() #9
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = tail call i64 @iwrc_set_errno(i64 noundef 70013, i32 noundef %34) #7
  store i64 %35, ptr %6, align 8, !tbaa !11
  br label %45

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

41:                                               ; preds = %36, %21
  %42 = getelementptr inbounds i8, ptr %.0, i64 52
  store i32 4, ptr %42, align 4, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %.0, i64 56
  store double %2, ptr %43, align 8, !tbaa !18
  call void @jbn_add_item(ptr noundef nonnull %0, ptr noundef nonnull %.0)
  %.not34 = icmp eq ptr %3, null
  br i1 %.not34, label %45, label %44

44:                                               ; preds = %41
  store ptr %.0, ptr %3, align 8, !tbaa !19
  br label %45

45:                                               ; preds = %41, %44, %27, %32
  %46 = load i64, ptr %6, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %24, %45, %17
  %.023 = phi i64 [ %46, %45 ], [ %20, %17 ], [ 70017, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %48

48:                                               ; preds = %5, %7, %47
  %.1 = phi i64 [ %.023, %47 ], [ 70017, %7 ], [ 70017, %5 ]
  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}
!18 = !{!8, !8, i64 0}
!19 = !{!7, !7, i64 0}


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